// --------------------- Terrain material ------------------------ // IN varying vec3 vUv; // OUT // UNIFORM uniform float uLightY; uniform sampler2D uAmbientMap; uniform sampler2D uTex0; uniform sampler2D uTex1; void main(void) { float AmbientColor = texture2D(uAmbientMap,vUv.xy).r; float AmbientLight = AmbientColor * (0.8-0.8*clamp(-(uLightY-0.15)*4.0, 0.0, 1.0)+0.115); vec3 Tex0 = texture2D(uTex0,vUv.xy*200.0).xyz; vec3 Tex1 = texture2D(uTex1,vUv.xy*200.0).xyz; gl_FragColor = vec4(AmbientLight * mix(Tex1, Tex0, clamp(-AmbientColor*4.0+4.5*(vUv.z/1000.0), 0.0, 1.0)), 1.0); }