uniform sampler2D uTexGarbage; uniform sampler2D uTexGradients; uniform vec3 uCamera; uniform vec4 uColour; in vec4 aColour; in vec2 aUv; in vec3 aNorm; in vec3 aCo; in vec3 aWorldCo; #include "common_world.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*4.0+modnorm)*0.25) + 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 vec3 halfview = uCamera - aWorldCo; float fdist = length( halfview ); halfview /= fdist; vfrag = do_light_diffuse( vfrag, qnorm ); vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 ); vfrag = do_light_shadowing( vfrag ); vfrag = apply_fog( vfrag, fdist ); oColour = vec4(vfrag, 1.0 ); }