X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fterrain.h;h=063566282c27bb944818e249f5e1df702f784954;hb=c33e4f46d864b2fde0c5938bf5a9388b1e8b5c04;hp=ce834d42cd3ba2c8a8f0788a2dd1d29a0e2e05a2;hpb=ecc4dfbfb3adf91d2dfc03ba0ec9a821fcc2390c;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/terrain.h b/shaders/terrain.h index ce834d4..0635662 100644 --- a/shaders/terrain.h +++ b/shaders/terrain.h @@ -7,12 +7,14 @@ static struct vg_shader _shader_terrain = { .link = shader_terrain_link, .vs = { -.orig_file = "../shaders/terrain.vs", +.orig_file = "../../shaders/standard.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" "\n" @@ -23,19 +25,22 @@ static struct vg_shader _shader_terrain = { "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_pos = uMdl * vec4(a_co,1.0);\n" +" gl_Position = uPv * vec4( world_pos, 1.0 );\n" " aColour = a_colour;\n" " aUv = a_uv;\n" " aNorm = mat3(uMdl) * a_norm;\n" " aCo = a_co;\n" +" aWorldCo = world_pos;\n" "}\n" ""}, .fs = { -.orig_file = "../shaders/terrain.fs", +.orig_file = "../../shaders/terrain.fs", .static_src = "out vec4 FragColor;\n" "\n" @@ -47,16 +52,20 @@ static struct vg_shader _shader_terrain = { "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" "\n" "#line 1 1 \n" "layout (std140) uniform ub_world_lighting\n" "{\n" -" vec3 g_directional;\n" -" vec3 g_sun_colour;\n" -" vec3 g_shadow_colour;\n" +" vec4 g_light_colours[3];\n" +" vec4 g_light_directions[3];\n" +" vec4 g_ambient_colour;\n" +"\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" "};\n" "\n" "uniform sampler2D g_world_depth;\n" @@ -66,15 +75,28 @@ static struct vg_shader _shader_terrain = { "\n" "vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n" "{\n" -" float flight = dot( g_directional, wnormal )*0.5+0.5;\n" -" return vfrag * mix( g_shadow_colour, g_sun_colour, flight );\n" +" vec3 vtotal = g_ambient_colour.rgb;\n" +"\n" +" for( int i=0; i