X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fterrain.h;h=4ad91ea8f6f864fd5d7d2dae5126a496be24673b;hb=60b0d8af679396c857f8c5f9a7a518b092a2f416;hp=983e0ba350b100f4b82ebdd68268547639a6d213;hpb=dfee9022b3513fddec36f7ea70867ee5961a44da;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/terrain.h b/shaders/terrain.h index 983e0ba..4ad91ea 100644 --- a/shaders/terrain.h +++ b/shaders/terrain.h @@ -7,7 +7,7 @@ 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" @@ -23,46 +23,145 @@ 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" "uniform sampler2D uTexGarbage;\n" "uniform sampler2D uTexGradients;\n" "uniform vec3 uCamera;\n" -"uniform vec4 uPlane;\n" "\n" "in vec4 aColour;\n" "in vec2 aUv;\n" "in vec3 aNorm;\n" "in vec3 aCo;\n" +"in vec3 aWorldCo;\n" "\n" -"float water_depth( vec3 pos, vec3 dir, vec4 plane )\n" +"#line 1 1 \n" +"layout (std140) uniform ub_world_lighting\n" "{\n" -" float d = dot( plane.xyz, dir );\n" -" float t = dot((plane.xyz*plane.w - pos),plane.xyz) / d;\n" -" return t*0.05;\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" +"\n" +"// Standard diffuse + spec models\n" +"// ==============================\n" +"\n" +"vec3 do_light_diffuse( vec3 vfrag, vec3 wnormal )\n" +"{\n" +" vec3 vtotal = g_ambient_colour.rgb;\n" +"\n" +" for( int i=0; i