X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;ds=sidebyside;f=shaders%2Fscene_terrain.fs;fp=shaders%2Fscene_terrain.fs;h=7f7648a045a5c8a90eb1a97207917039de294cce;hb=aa4c26eae2208872824e0eb5b71bc05c16d43242;hp=0000000000000000000000000000000000000000;hpb=3e8fda9c7cbc50d1ae95195905c953bdeedf71b9;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/scene_terrain.fs b/shaders/scene_terrain.fs new file mode 100644 index 0000000..7f7648a --- /dev/null +++ b/shaders/scene_terrain.fs @@ -0,0 +1,57 @@ +uniform sampler2D uTexGarbage; +uniform sampler2D uTexGradients; +uniform vec3 uCamera; +uniform vec3 uSandColour; +uniform vec2 uBlendOffset; +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(); + + // Colour + // ------ + 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); + + vec2 dir = normalize(qnorm.xz); + vec2 uvdiffuse = aCo.xz * 0.02; + uvdiffuse = mat2(dir.y, dir.x, -dir.x, dir.y) * uvdiffuse; + + // Patch local noise + vec4 rgarbage = texture( uTexGarbage, uvdiffuse ); + + // Colour blending + float amtgrass = step(qnorm.y,0.6); + float amtsand = min(max((aCo.y - 10.0) * -0.1,0.0)*qnorm.y,1.0); + vec2 uvgradients = aUv + vec2( amtgrass + rgarbage.a*0.8 )*uBlendOffset; + vfrag = texture( uTexGradients, uvgradients ).rgb; + vfrag = mix( vfrag, uSandColour, amtsand ); + + qnorm = mix( qnorm, aNorm.xyz, amtsand ); + + if( g_light_preview == 1 ) + { + vfrag = vec3(0.5); + } + + vfrag = scene_do_lighting( vfrag, qnorm ); + oColour = vec4(vfrag, 1.0); +}