X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fwater.h;h=ca3ab47340ffdb343247e88a65d8c3d312083aa3;hb=bdac014448b6ec968fe645f1581f321144f07dba;hp=67b07454cbb3eb7a22117bc0d51a49feba8c56de;hpb=dfee9022b3513fddec36f7ea70867ee5961a44da;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/water.h b/shaders/water.h index 67b0745..ca3ab47 100644 --- a/shaders/water.h +++ b/shaders/water.h @@ -7,120 +7,234 @@ static struct vg_shader _shader_water = { .link = shader_water_link, .vs = { -.orig_file = "../shaders/water.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" -"uniform mat4 uPv;\n" "uniform mat4x3 uMdl;\n" -"uniform vec4 uDepthBounds;\n" +"uniform mat4 uPv;\n" "\n" -"out vec4 aUv;\n" +"out vec4 aColour;\n" +"out vec2 aUv;\n" +"out vec3 aNorm;\n" "out vec3 aCo;\n" -"out float aDepth;\n" +"out vec3 aWorldCo;\n" "\n" "void main()\n" "{\n" -" vec3 world_pos = uMdl * vec4( a_co, 1.0 );\n" -" gl_Position = uPv * vec4(world_pos,1.0);\n" -"\n" -" vec2 depth_coords = (world_pos.xz-uDepthBounds.xy)*uDepthBounds.zw;\n" -" aUv = vec4(world_pos.xz*0.01,depth_coords);\n" -" aCo = world_pos;\n" -"\n" -" aDepth = gl_Position.z;\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/water.fs", +.orig_file = "../../shaders/water.fs", .static_src = "out vec4 FragColor;\n" "\n" "uniform sampler2D uTexMain;\n" "uniform sampler2D uTexDudv;\n" -"uniform sampler2D uTexDepth;\n" "uniform sampler2D uTexBack;\n" "\n" "uniform vec2 uInvRes;\n" "uniform float uTime;\n" -"\n" "uniform vec3 uCamera;\n" "uniform float uSurfaceY;\n" "\n" -"in vec4 aUv;\n" +"in vec4 aColour;\n" +"in vec2 aUv;\n" +"in vec3 aNorm;\n" "in vec3 aCo;\n" -"in float aDepth;\n" +"in vec3 aWorldCo;\n" "\n" -"void main()\n" +"#line 1 1 \n" +"layout (std140) uniform ub_world_lighting\n" "{\n" -" // Reflected and warped texture\n" -" vec2 ssuv = gl_FragCoord.xy*uInvRes;\n" +" vec4 g_light_colours[3];\n" +" vec4 g_light_directions[3];\n" +" vec4 g_ambient_colour;\n" "\n" -" vec4 dudva = texture( uTexDudv, aUv.xy - vec2(uTime*0.004f,uTime*0.003f) );\n" -" vec4 dudvb = texture( uTexDudv, aUv.xy*0.7 - vec2(uTime*0.01,uTime*0.0054) );\n" -" vec2 distortamt = (dudva.rg-0.5) * (dudvb.ba-0.5) * 0.6;\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" -" vec4 reflected = texture( uTexMain, ssuv+distortamt );\n" -" \n" -" // Surface colour composite\n" -" float depthvalue = texture( uTexDepth, aUv.zw ).r;\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