Skip to content

Commit de51bb3

Browse files
committed
Reduce High Freq ripples around Crystals
There was a high frequency ripple due to reading from the `vPos.y` in flatter areas. So reduced the `vPos` influence when under water `vCd.g`
1 parent 241761a commit de51bb3

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

docs/js/pxlRooms/SaltFlatsEnvironment/Shaders.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ export function envGroundFrag(){
284284
vec3 snCd = texture2D(smoothNoiseTexture,nUv).rgb;
285285
vec3 snCdFit = texture2D(smoothNoiseTexture,nUv).rgb*2.0-1.0;
286286
287+
float glowInf = vCd.g*vCd.g*vCd.g;
288+
287289
288290
// -- -- -- -- -- -- -- --
289291
// -- Normal Map Calc - -- --
@@ -313,17 +315,16 @@ export function envGroundFrag(){
313315
float facingDown = dot( normalize( nMap ), vec3(0.0,1.0,0.0) ) *.45 +.55;
314316
facingDown = clamp( (facingDown*facingDown)*1.4, 0.0, 1.0 );
315317
316-
//lights = mix( vec3(0.0), lights*facingDown, max( 0.0, nCd*vCd.g*.75 + vCd.r*.5 ) );
318+
//lights = mix( vec3(0.0), lights*facingDown, max( 0.0, nCd*glowInf*.75 + vCd.r*.5 ) );
317319
318320
// Add blue lighting around some of the crystals
319321
crystalGlow *= (nCd);
320322
lights = (lights + vec3( 0.4038, 0.643, 0.779 ) * (crystalGlow * nCd )) * 1.5;
321323
322-
float scalar = sin( plantGrowth*2. + time.x*1.5 + vPos.z*.2 + vPos.x*.2 - vPos.y*.2 + snCd.x*2. + snCd.y*4. + snCd.z*5. )+1.0;
323-
scalar = cos( scalar*2. - time.x*.3 + vPos.y*2. + snCd.x + snCd.y + snCd.z )*0.5 + scalar;
324-
scalar = clamp( (scalar*scalar*snCd.r+.5) * plantGrowth * 2. * vCd.y* vCd.y, 0.0, 1.0);
324+
float scalar = sin( plantGrowth*2. + time.x*1.5 + vPos.z*.2 + vPos.x*.2 - vPos.y*.2*glowInf + snCd.x*2. + snCd.y*4. + snCd.z*5. )+1.0;
325+
scalar = cos( scalar*2. - time.x*.3 + vPos.y*glowInf + snCd.x + snCd.y + snCd.z )*0.5 + scalar;
326+
scalar = clamp( (scalar*scalar*snCd.r+.5) * plantGrowth * 2. * glowInf, 0.0, 1.0);
325327
Cd.rgb += vec3( 0.4038, 0.643, 0.779 ) * ( (depthFade*.85)* scalar) ;
326-
//Cd.rgb = vec3( scalar ) ;
327328
328329
gl_FragColor=Cd;
329330
}`;

0 commit comments

Comments
 (0)