@@ -703,6 +703,7 @@ export function pondWaterVert(){
703703export function pondWaterFrag ( ) {
704704 let ret = shaderHeader ( ) ;
705705 ret += `
706+
706707 uniform vec2 time;
707708 uniform float intensity;
708709 uniform float rate;
@@ -739,15 +740,17 @@ export function pondWaterFrag(){
739740 // -- -- --
740741
741742 // Sample Coast Line Distance texture
742- vec2 sampleOffset = vec2( .0015 );
743- float coastInf= ( texture2D( coastLineTexture, vUv ).r +
744- texture2D( coastLineTexture, vUv + sampleOffset + nCd.rg*.015 ).r +
745- texture2D( coastLineTexture, vUv - sampleOffset ).r ) * .3333333333;
746-
747- uv = vec2( pos.x*.1 - coastInf*.1, pos.z*.10-timer*.05-coastInf*.05 );
748- vec3 vertCd = ( texture2D(noiseTexture,uv).rgb*.5 +
749- texture2D(noiseTexture,uv+sampleOffset).rgb*.25 +
750- texture2D(noiseTexture,uv-sampleOffset).rgb*.15 );
743+ vec2 sampleOffset = vec2( .001 );
744+ uv = vUv + (nCd.rg-.5)*.001;
745+ vec3 rippleUVs= texture2D( coastLineTexture, uv ).rgb *.5 +
746+ texture2D( coastLineTexture, uv + sampleOffset ).rgb * .25 +
747+ texture2D( coastLineTexture, uv - sampleOffset ).rgb * .25 ;
748+
749+ rippleUVs.rg = abs(rippleUVs.rg-.5) * 1.5;
750+ float coastInf= pow( clamp( (length( rippleUVs.rg )), 0.0, 1.0), 3.0);
751+ float coastInfInv = (1.0-coastInf);
752+
753+ nCd *= (1.0-coastInf*.5);
751754
752755 // -- -- --
753756
@@ -761,29 +764,24 @@ export function pondWaterFrag(){
761764 // -- -- --
762765
763766 // Generate coastal ripples
764- coastInf = max( 0.0, coastInf*coastInf*coastInf - (vertCd.r+vertCd.g+vertCd.b)*coastInf*0.28 );
765- vec2 rippleUV = vec2( coastInf ) ;
766- rippleUV = fract( rippleUV + (-time.x*0.06 ) );
767-
768-
769- rippleUV = ( rippleUV * coastInf);
770- float rippleInf=texture2D( rippleTexture, rippleUV ).r * coastInf * coastInf *.5 ;
767+ rippleUVs.xy = ( rippleUVs.xy*vec2(1.0,.65*(coastInf*.6+.65)) + vec2( rippleUVs.b * .3, -time*.03 ) ) ;
768+ float rippleInf = texture2D( rippleTexture, rippleUVs.xy ).r * coastInf;
771769
772770
773771 // -- -- --
774772
775773 // Color + Coastal Mix
776774
777- Cd.rgb *= mix( max(nCd.g*(nCd.r*.5+1.0)*.7+.3,nCd.b*alpha)*.8+.1,
778- rippleInf+0.50 ,
779- min(1.0,(coastInf*.5+.5)+ rippleInf)
775+ Cd.rgb *= mix( max(nCd.g*(nCd.r*.5+1.0)*.7*coastInfInv +.3,nCd.b*alpha)*.8*coastInfInv +.1,
776+ rippleInf*.2 +0.7 ,
777+ min(1.0,(nCd.g*nCd.b)+coastInf+ rippleInf*.3 )
780778 );
781779
782780 float angleInf = clamp( (1.0-min(1.0, length( vToCam )*.00135 ))*1.85, 0.0, 1.0 );
783781 angleInf *= angleInf;
784- float angleIncidence = 1.0 - clamp( dot( normalize( vToCam ), normalize(vN * nCd) )*3.50-.5, 0.0, 1.0)*(1.0-coastInf*.3 -nCd.g*.3 ) * angleInf ;
782+ float angleIncidence = 1.0 - clamp( dot( normalize( vToCam ), normalize(vN * nCd) )*3.50-.5, 0.0, 1.0)*(1.0-coastInf-nCd.g*.4 ) * angleInf ;
785783
786- Cd.a = mix(Cd.a*angleIncidence, Cd.a-min(1.0, (1.0-rippleInf)*.35 ), coastInf*.35 );
784+ Cd.a = mix(Cd.a*angleIncidence, Cd.a-min(1.0, (1.0-rippleInf)*.035 ), coastInf+rippleInf );
787785
788786
789787 gl_FragColor=Cd;
0 commit comments