accommodate inspector change
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_route.fs
1 uniform sampler2D uTexGarbage;
2 uniform sampler2D uTexGradients;
3 uniform vec3 uCamera;
4 uniform vec4 uColour;
5
6 #include "light_clearskies_stddef.glsl"
7 #include "common_scene.glsl"
8 #include "motion_vectors_fs.glsl"
9
10 float filtered_stripe( in float p, in float ddx, in float ddy )
11 {
12 float w = max(abs(ddx), abs(ddy)) + 0.02;
13 float i = (abs(fract((p-0.5*w)/2.0)-0.5)-abs(fract((p+0.5*w)/2.0)-0.5))/w;
14 return 0.5 - i;
15 }
16
17 void main()
18 {
19 compute_motion_vectors();
20
21 vec3 vfrag = vec3(0.5,0.5,0.5);
22
23 // ws modulation
24 vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );
25
26 // Creating normal patches
27 vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;
28 vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25);
29 qnorm += vec3(0.001,0.0,0.0);
30
31 vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0)));
32 vec3 tangent1 = cross(qnorm,tangent0);
33 vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.035;
34
35 // Patch local noise
36 vec4 rgarbage = texture( uTexGarbage, uvdiffuse );
37
38 vfrag = pow(uColour.rgb,vec3(1.0/2.2));
39 vfrag -= rgarbage.a*0.1;
40
41 if( wgarbage.g < 0.1 )
42 discard;
43
44 float movep = (aUv.x + abs(aUv.y-0.5)*0.4 - g_realtime)*2.0;
45 float stripe = filtered_stripe( movep, dFdx(movep), dFdy(movep) );
46 vfrag *= 0.9+stripe*uColour.a;
47
48 if( g_light_preview == 1 )
49 {
50 vfrag = vec3(0.5);
51 }
52
53 // Lighting
54 oColour = vec4( scene_compute_lighting( vfrag, qnorm, aWorldCo ), 1.0 );
55 }