X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fterrain.h;h=460ba9e5d02392e2ad3a2e94ffef59132a13a1d5;hb=f7db507815e2822d971031c30f25e02b45e9c914;hp=9bbb939439e330b0e1e1b9b1d9447deff45bfd09;hpb=3bb0287d544a4cb75de9afe2927ac8e946f3a18e;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/terrain.h b/shaders/terrain.h index 9bbb939..460ba9e 100644 --- a/shaders/terrain.h +++ b/shaders/terrain.h @@ -7,26 +7,47 @@ static struct vg_shader _shader_terrain = { .link = shader_terrain_link, .vs = { -.orig_file = "../shaders/terrain.vs", .static_src = "layout (location=0) in vec3 a_co;\n" "layout (location=1) in vec3 a_norm;\n" -"layout (location=2) in vec4 a_colour;\n" -"layout (location=3) in vec2 a_uv;\n" +"layout (location=2) in vec2 a_uv;\n" +"layout (location=3) in vec4 a_colour;\n" +"layout (location=4) in vec4 a_weights;\n" +"layout (location=5) in ivec4 a_groups;\n" "\n" "#line 2 0 \n" +"#line 1 2 \n" +"out vec3 aMotionVec0;\n" +"out vec3 aMotionVec1;\n" +"\n" +"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" +"{\n" +" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" +" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" +"}\n" +"\n" +"#line 3 0 \n" "\n" -"uniform mat4 uPv;\n" "uniform mat4x3 uMdl;\n" +"uniform mat4 uPv;\n" +"uniform mat4 uPvmPrev;\n" "\n" "out vec4 aColour;\n" "out vec2 aUv;\n" "out vec3 aNorm;\n" "out vec3 aCo;\n" +"out vec3 aWorldCo;\n" "\n" "void main()\n" "{\n" -" gl_Position = uPv * vec4( uMdl * vec4(a_co,1.0), 1.0 );\n" +" vec3 world_pos0 = uMdl * vec4( a_co, 1.0 );\n" +" vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );\n" +" vec4 vproj1 = uPvmPrev * vec4( a_co, 1.0 );\n" +"\n" +" vs_motion_out( vproj0, vproj1 );\n" +"\n" +" gl_Position = vproj0;\n" +" aWorldCo = world_pos0;\n" " aColour = a_colour;\n" " aUv = a_uv;\n" " aNorm = mat3(uMdl) * a_norm;\n" @@ -35,34 +56,156 @@ static struct vg_shader _shader_terrain = { ""}, .fs = { -.orig_file = "../shaders/terrain.fs", .static_src = -"out vec4 FragColor;\n" -"\n" "uniform sampler2D uTexGarbage;\n" "uniform sampler2D uTexGradients;\n" "uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" +"uniform vec3 uSandColour;\n" +"uniform vec2 uBlendOffset;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" +"\n" +"#line 1 1 \n" +"layout (location = 0) out vec4 oColour;\n" +"\n" +"layout (std140) uniform ub_world_lighting\n" +"{\n" +" vec4 g_light_colours[3];\n" +" vec4 g_light_directions[3];\n" +" vec4 g_ambient_colour;\n" "\n" -"float water_depth( vec3 pos, vec3 dir, vec4 plane )\n" +" vec4 g_water_plane;\n" +" vec4 g_depth_bounds;\n" +" float g_water_fog;\n" +" int g_light_count;\n" +" int g_light_preview;\n" +" int g_shadow_samples;\n" +"};\n" +"\n" +"uniform sampler2D g_world_depth;\n" +"\n" +"// Standard diffuse + spec models\n" +"// ==============================\n" +"\n" +"vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n" "{\n" -" float d = dot( plane.xyz, dir );\n" -" float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;\n" -" return t*0.04;\n" +" vec3 vtotal = g_ambient_colour.rgb;\n" +"\n" +" for( int i=0; i