From 9f349f361694482562858a3578361c703c678a2e Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Sat, 10 Aug 2024 10:53:16 +0200 Subject: [PATCH] cleanup flesh cube --- Assets/raymarched/Raymarching.unity | 2 +- Assets/raymarched/flesh_cube.shader | 46 ++++++++--------------------- 2 files changed, 14 insertions(+), 34 deletions(-) diff --git a/Assets/raymarched/Raymarching.unity b/Assets/raymarched/Raymarching.unity index 7139b27..d531bcd 100644 --- a/Assets/raymarched/Raymarching.unity +++ b/Assets/raymarched/Raymarching.unity @@ -3109,7 +3109,7 @@ MonoBehaviour: m_EditorClassIdentifier: type: 3 objectId: 4e7f3dcf-e925-473a-89e2-dfe6cfe7eac5 - randomNum: 77268264 + randomNum: 67221367 unityVersion: 2021.3.41f1 cckVersion: 3.10:132 --- !u!114 &2089314931 diff --git a/Assets/raymarched/flesh_cube.shader b/Assets/raymarched/flesh_cube.shader index f20816b..2a8ef2a 100644 --- a/Assets/raymarched/flesh_cube.shader +++ b/Assets/raymarched/flesh_cube.shader @@ -1,12 +1,6 @@ Shader "CrispyPin/FleshCube2" { - Properties - { - [Header(Raymarcher Properties)] - _MaxSteps ("Max steps", Integer) = 128 - _MaxDist ("Max distance", Float) = 128 - _SurfDist ("Surface distance threshold", Range(.0001, .05)) = .001 - } + Properties {} SubShader { Tags { "RenderType"="Opaque" } @@ -19,46 +13,32 @@ Shader "CrispyPin/FleshCube2" #pragma vertex vert #pragma fragment frag - int _MaxSteps; - float _MaxDist; - float _SurfDist; - #define MAX_STEPS _MaxSteps - #define MAX_DIST _MaxDist - #define SURF_DIST _SurfDist - + #define MAX_STEPS 128 + #define MAX_DIST 128 + #define SURF_DIST 0.01 #define SCENE_FN main - //#define LIGHT_FN lighting - #define SCENE_SCALE 0.04 #define REFLECTIONS 2 - #define DISCARD_ON_MISS #include "lib/libgarbage.cginc" - #define SPEED 1.5 - SurfacePoint main(float3 p) { Material mRed = mat(.95, 0.1, 0.1, 0.4); - Material mCut = mat(.7, 0.2, 0.1, 0.4); - + Material mEdge = mat(.7, 0.2, 0.1, 0.4); SurfacePoint d; - // base - float3 bias = -pow(sin(_Time*60 + p.y*0.1), 8)*.5+1.3; - d = mGyroid(p, .5, bias, 0.2, mCut); - + float3 bias = -pow(sin(_Time*60 + p.y*0.1), 8) * .5 + 1.3; + d = mGyroid(p, .5, bias, 0.2, mEdge); float3 gp = p + sin(_Time + p*0.1); - d.dist -= sdGyroid(gp, 1.63, .5, 0.2) * 0.3; - d.dist += sdGyroid(gp, 3.327, 0, 0.2) * 0.1; - d.dist += sdGyroid(gp, 7.351, .5, 0.2) * 0.1; - d.dist -= sdGyroid(gp, 17.351, .5, 0.2) * 0.05; - d.dist -= sdGyroid(gp, 23.521, .2, 0.2) * 0.05; + d.dist -= sdGyroid(gp, 1.63, .5, .2) * .3; + d.dist += sdGyroid(gp, 3.327, 0, .2) * .1; + d.dist += sdGyroid(gp, 7.351, .5, .2) * .1; + d.dist -= sdGyroid(gp, 17.351, .5, .2) * .05; + d.dist -= sdGyroid(gp, 23.521, .2, .2) * .05; d = qUnion(d, mSphere(p, 6 + bias*3, mRed), 5); - - d = qIntersect(d, mBox(p, 25, mRed)); - + d = qIntersect(d, mBox(p, 25, mRed), 0.8); return d; } ENDCG