Skip to content

Commit ac85358

Browse files
committed
FieldEnv. altered Pond Coastal Ripples
Adjusted ripples to get a direction driven UV from a map with a "coastal" blue channel from 0-1 Coastal channel offsets where in the ripples texture the value is read, which does cause some artifacts from jpeg compression and 8bit limits
1 parent 63b8e8a commit ac85358

File tree

5 files changed

+22
-24
lines changed

5 files changed

+22
-24
lines changed
21.8 KB
Loading
-75.2 KB
Binary file not shown.
-44.9 KB
Binary file not shown.

docs/js/pxlRooms/FieldEnvironment/FieldEnvironment.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class FieldEnvironment extends RoomEnvironment{
3434
constructor( roomName='FieldEnvironment', assetPath=null, msRunner=null, camera=null, scene=null, cloud3dTexture=null ){
3535
super( roomName, assetPath, msRunner, camera, scene, cloud3dTexture );
3636

37-
this.assetPath=assetPath+"Assets/";
37+
this.assetPath= assetPath + "Assets/";
3838
this.sceneFile = this.assetPath+"FieldEnvironment.fbx";
3939

4040
// Environment Shader
@@ -623,7 +623,7 @@ export class FieldEnvironment extends RoomEnvironment{
623623
}]
624624
)
625625
creekWaterUniforms.dataTexture.value = this.pxlUtils.loadTexture( this.assetPath+"CreekWater_Data.jpg" );
626-
creekWaterUniforms.rippleTexture.value = this.pxlUtils.loadTexture( this.assetPath+"WaterRipplesA.jpg" );
626+
creekWaterUniforms.rippleTexture.value = this.pxlUtils.loadTexture( this.assetPath+"WaterRipples_CoastalB.jpg" );
627627
creekWaterUniforms.noiseTexture.value = this.pxlUtils.loadTexture( this.assetPath+"Noise_UniformWebbing.jpg" );
628628

629629
let creekWaterMat=this.pxlFile.pxlShaderBuilder( creekWaterUniforms, creekWaterVert(), creekWaterFrag() );
@@ -653,7 +653,7 @@ export class FieldEnvironment extends RoomEnvironment{
653653
//
654654
// -- -- --
655655

656-
let fieldFbxLoader = this.pxlFile.loadRoomFBX( this ); // , null, null, true );
656+
let fieldFbxLoader = this.pxlFile.loadRoomFBX( this ) ;//, null, null, true );
657657

658658
// -- -- -- -- -- -- -- -- -- -- -- -- -- //
659659

docs/js/pxlRooms/FieldEnvironment/Shaders.js

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ export function pondWaterVert(){
703703
export 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

Comments
 (0)