add motion vectors to all shaders
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / route.fs
1 uniform sampler2D uTexGarbage;
2 uniform sampler2D uTexGradients;
3 uniform vec3 uCamera;
4 uniform vec4 uColour;
5
6 in vec4 aColour;
7 in vec2 aUv;
8 in vec3 aNorm;
9 in vec3 aCo;
10 in vec3 aWorldCo;
11
12 #include "common_world.glsl"
13 #include "motion_vectors_fs.glsl"
14
15 void main()
16 {
17 compute_motion_vectors();
18
19 vec3 vfrag = vec3(0.5,0.5,0.5);
20
21 // ws modulation
22 vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );
23
24 // Creating normal patches
25 vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;
26 vec3 qnorm = normalize(floor(aNorm*4.0+modnorm)*0.25) + vec3(0.001,0.0,0.0);
27
28 vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0)));
29 vec3 tangent1 = cross(qnorm,tangent0);
30 vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.035;
31
32 // Patch local noise
33 vec4 rgarbage = texture( uTexGarbage, uvdiffuse );
34
35 vfrag = pow(uColour.rgb,vec3(1.0/2.2));
36 vfrag -= rgarbage.a*0.1;
37
38 if( wgarbage.g < 0.3 )
39 discard;
40
41 if( g_light_preview == 1 )
42 {
43 vfrag = vec3(0.5);
44 }
45
46 // Lighting
47 vec3 halfview = uCamera - aWorldCo;
48 float fdist = length( halfview );
49 halfview /= fdist;
50
51 vfrag = do_light_diffuse( vfrag, qnorm );
52 vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 );
53 vfrag = do_light_shadowing( vfrag );
54 vfrag = apply_fog( vfrag, fdist );
55
56 oColour = vec4(vfrag, 1.0 );
57 }