@@ -71,12 +71,9 @@ static float2 swRotate2D(float2 p, float a) {
7171 return float2 (c * p.x - s * p.y , s * p.x + c * p.y );
7272}
7373
74- static float3 swFold (float3 p, float time) {
75- p.xz = swRotate2D (p.xz , time * 0 .22f + p.y * 0 .08f );
76- p.xy = swRotate2D (p.xy , time * -0 .17f + sin (p.z * 0 .5f ) * 0 .6f );
77- p = abs (p) - float3 (1 .15f , 0 .85f , 1 .15f );
78- p.yz = swRotate2D (p.yz , 0 .75f + sin (time * 0 .33f ) * 0 .4f );
79- return p;
74+ static float swRoundBox (float3 p, float3 b, float r) {
75+ float3 q = abs (p) - b;
76+ return length (max (q, 0 .0f )) + min (max (q.x , max (q.y , q.z )), 0 .0f ) - r;
8077}
8178
8279static float swGyroid (float3 p) {
@@ -114,23 +111,18 @@ static float2 swFaceUV(float3 p) {
114111static SWHit swMap (float3 p, float time) {
115112 SWHit hit;
116113
117- float3 q = p * 2 .35f ;
118- q = swFold (q, time);
114+ float3 q = p * 1 .55f ;
115+ q.xz = swRotate2D (q.xz , time * 0 .2f );
116+ q.yz = swRotate2D (q.yz , 0 .65f + sin (time * 0 .33f ) * 0 .25f );
119117
120- float gyroid = swGyroid (q * 1 . 55f + time * 0 . 7f );
121- float bandsA = sin (q. x * 6 . 0f + sin (q. z * 2 . 0f - time * 1 . 6f ) * 1 . 6f );
122- float bandsB = sin (q.y * 7 .0f - cos (q.x * 2 .6f + time * 1 . 2f ) * 1 . 4f );
123- float bandsC = sin (q. z * 6 . 8f + q. x * 1 . 8f - time * 0 .9f ) ;
124- float ribbons = abs (bandsA + bandsB * 0 . 75f + bandsC * 0 . 6f + gyroid * 0 . 55f ) - 0 . 24f ;
118+ float core = swRoundBox (q, float3 ( 0 . 7f ), 0 . 28f );
119+ float gyroid = swGyroid (q * 3 . 1f + time * 0 . 7f );
120+ float grooves = sin (q.x * 7 .0f ) + sin (q.y * 7 .6f ) + sin (q. z * 6 . 8f );
121+ float detail = ( abs (gyroid) - 0 . 24f ) * 0 . 045f + grooves * 0 .012f ;
122+ float sdf = core + detail ;
125123
126- float shellRadius = length (q.xz ) - (1 .35f + 0 .22f * sin (q.y * 3 .0f - time * 1 .1f ));
127- float shell = abs (shellRadius) - (0 .11f + 0 .04f * sin (q.y * 8 .0f + time * 1 .9f ));
128-
129- float knots = length (float2 (abs (gyroid), ribbons)) - 0 .2f ;
130- float sdf = min (ribbons * 0 .16f , min (shell * 0 .24f , knots * 0 .22f ));
131-
132- float edgeSignal = abs (ribbons) + abs (shell) * 0 .35f + abs (gyroid) * 0 .25f ;
133- float colorPhase = 0 .16f * q.y + 0 .08f * q.z + sin (time * 0 .45f ) * 0 .2f ;
124+ float edgeSignal = abs (detail) + abs (gyroid) * 0 .08f ;
125+ float colorPhase = 0 .14f * q.y + 0 .1f * q.z + sin (time * 0 .45f ) * 0 .2f ;
134126
135127 hit.distance = 0 .0f ;
136128 hit.sdf = sdf;
@@ -179,7 +171,7 @@ fragment float4 saturdayWeirdnessFragment(
179171 }
180172
181173 float tStart = insideBox ? 0 .0f : max (tBox.x , 0 .0f );
182- float3 ro = (eye + rd * (tStart + SW_HIT_EPSILON )) * 3 . 5f ;
174+ float3 ro = (eye + rd * (tStart + SW_HIT_EPSILON )) * 2 . 0f ;
183175
184176 float travel = 0 .0f ;
185177 SWHit state = swMap (ro, uniforms.time );
@@ -189,7 +181,7 @@ fragment float4 saturdayWeirdnessFragment(
189181 if (abs (state.sdf ) < SW_HIT_EPSILON || travel > SW_MAX_DIST ) {
190182 break ;
191183 }
192- travel += clamp (abs (state.sdf ), 0 .01f , 0 .18f );
184+ travel += clamp (abs (state.sdf ), 0 .008f , 0 .14f );
193185 }
194186
195187 if (travel > SW_MAX_DIST || abs (state.sdf ) >= 0 .02f ) {
0 commit comments