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