X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fscene_route.fs;fp=shaders%2Fscene_route.fs;h=5bb973d380e81b753493e1d4a9682ad9e70a58a0;hb=aa4c26eae2208872824e0eb5b71bc05c16d43242;hp=0000000000000000000000000000000000000000;hpb=3e8fda9c7cbc50d1ae95195905c953bdeedf71b9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/scene_route.fs b/shaders/scene_route.fs new file mode 100644 index 0000000..5bb973d --- /dev/null +++ b/shaders/scene_route.fs @@ -0,0 +1,53 @@ +uniform sampler2D uTexGarbage; +uniform sampler2D uTexGradients; +uniform vec3 uCamera; +uniform vec4 uColour; +uniform vec3 uBoard0; +uniform vec3 uBoard1; + +in vec2 aUv; +in vec4 aNorm; +in vec3 aCo; +in vec3 aWorldCo; +flat in ivec4 aLights; + +#include "common_scene.glsl" +#include "motion_vectors_fs.glsl" + +void main() +{ + compute_motion_vectors(); + + vec3 vfrag = vec3(0.5,0.5,0.5); + + // ws modulation + vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 ); + + // Creating normal patches + vec3 modnorm = (wgarbage.rgb-0.4) * 1.4; + vec3 qnorm = normalize(floor(aNorm.xyz*4.0+modnorm)*0.25); + qnorm += vec3(0.001,0.0,0.0); + + vec3 tangent0 = normalize(cross(qnorm,vec3(0.0,1.0,0.0))); + vec3 tangent1 = cross(qnorm,tangent0); + vec2 uvdiffuse = vec2( dot(tangent0,aCo), dot(tangent1,aCo) ) * 0.035; + + // Patch local noise + vec4 rgarbage = texture( uTexGarbage, uvdiffuse ); + + vfrag = pow(uColour.rgb,vec3(1.0/2.2)); + vfrag -= rgarbage.a*0.1; + + if( wgarbage.g < 0.3 ) + discard; + + if( g_light_preview == 1 ) + { + vfrag = vec3(0.5); + } + + // Lighting + + vfrag = scene_do_lighting( vfrag, qnorm ); + oColour = vec4(vfrag, 1.0); +}