sand alpha, addon reg
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_terrain.fs
1 uniform sampler2D uTexGarbage;
2 uniform sampler2D uTexGradients;
3 uniform vec3 uCamera;
4 uniform vec4 uSandColour;
5 uniform vec2 uBlendOffset;
6
7 #include "light_clearskies_stddef.glsl"
8 #include "common_scene.glsl"
9 #include "motion_vectors_fs.glsl"
10
11 void main()
12 {
13 compute_motion_vectors();
14
15 // Colour
16 // ------
17 vec3 vfrag = vec3(0.5,0.5,0.5);
18
19 // ws modulation
20 vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );
21
22 // Creating normal patches
23 vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;
24 vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);
25 qnorm += vec3(0.001,0.0,0.0);
26
27 vec2 dir = normalize(qnorm.xz);
28 vec2 uvdiffuse = aCo.xz * 0.02;
29 uvdiffuse = mat2(dir.y, dir.x, -dir.x, dir.y) * uvdiffuse;
30
31 // Patch local noise
32 vec4 rgarbage = texture( uTexGarbage, uvdiffuse );
33
34 // Colour blending
35 float amtgrass = step(qnorm.y,0.6);
36 float amtsand = clamp( max((aCo.y - 10.0) * -0.1,0.0)*qnorm.y, 0.0, 1.0 );
37 vec2 uvgradients = aUv + vec2( amtgrass + rgarbage.a*0.8 )*uBlendOffset;
38 vfrag = texture( uTexGradients, uvgradients ).rgb;
39 vfrag = mix( vfrag, uSandColour.rgb, amtsand*uSandColour.a );
40 qnorm = mix( qnorm, aNorm.xyz, amtsand );
41
42 if( g_light_preview == 1 )
43 {
44 vfrag = vec3(0.5);
45 }
46
47 vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );
48 oColour = vec4(vfrag, 1.0);
49 }