X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fterrain.h;h=8db464d8961e5e7fdf283d7aba2669f661646d65;hb=c52e639cdcf6d21f69caa9625238afded7513ca4;hp=460ba9e5d02392e2ad3a2e94ffef59132a13a1d5;hpb=f7db507815e2822d971031c30f25e02b45e9c914;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/terrain.h b/shaders/terrain.h index 460ba9e..8db464d 100644 --- a/shaders/terrain.h +++ b/shaders/terrain.h @@ -17,11 +17,19 @@ static struct vg_shader _shader_terrain = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.01;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" // This magically solves some artifacting errors!\n" +" //\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -177,6 +185,10 @@ static struct vg_shader _shader_terrain = { "\n" "#line 14 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.01;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -187,7 +199,8 @@ static struct vg_shader _shader_terrain = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 15 0 \n" @@ -200,27 +213,12 @@ static struct vg_shader _shader_terrain = { " // ------\n" " vec3 vfrag = vec3(0.5,0.5,0.5);\n" "\n" -" // ws modulation\n" -" vec4 wgarbage = texture( uTexGarbage, aCo.xz * 0.015 );\n" -" \n" -" // Creating normal patches\n" -" vec3 modnorm = (wgarbage.rgb-0.4) * 1.4;\n" -" vec3 qnorm = normalize(floor(aNorm*4.0+modnorm)*0.25) + vec3(0.001,0.0,0.0);\n" -" vec2 dir = normalize(qnorm.xz);\n" -" vec2 uvdiffuse = aCo.xz * 0.02;\n" -" uvdiffuse = mat2(dir.y, dir.x, -dir.x, dir.y) * uvdiffuse;\n" -" \n" -" // Patch local noise\n" -" vec4 rgarbage = texture( uTexGarbage, uvdiffuse );\n" -"\n" " // Colour blending\n" -" float amtgrass = step(qnorm.y,0.6);\n" -" float amtsand = min(max((aCo.y - 10.0) * -0.1,0.0)*qnorm.y,1.0);\n" -" vec2 uvgradients = aUv + vec2( amtgrass + rgarbage.a*0.8 )*uBlendOffset;\n" +" float amtgrass = step(aNorm.y,0.6);\n" +" float amtsand = min(max((aCo.y - 10.0) * -0.1,0.0)*aNorm.y,1.0);\n" +" vec2 uvgradients = aUv + vec2( amtgrass )*uBlendOffset;\n" " vfrag = texture( uTexGradients, uvgradients ).rgb;\n" " vfrag = mix( vfrag, uSandColour, amtsand );\n" -"\n" -" qnorm = mix( qnorm, aNorm, amtsand );\n" " \n" " if( g_light_preview == 1 )\n" " {\n" @@ -232,8 +230,8 @@ static struct vg_shader _shader_terrain = { " float fdist = length( halfview );\n" " halfview /= fdist;\n" "\n" -" vfrag = do_light_diffuse( vfrag, qnorm );\n" -" vfrag = do_light_spec( vfrag, qnorm, halfview, 0.1 );\n" +" vfrag = do_light_diffuse( vfrag, aNorm );\n" +" vfrag = do_light_spec( vfrag, aNorm, halfview, 0.1 );\n" " vfrag = do_light_shadowing( vfrag );\n" " vfrag = apply_fog( vfrag, fdist );\n" "\n"