"flat in ivec4 aLights;\n"
"\n"
"#line 1 1 \n"
+"// :D\n"
+"\n"
+"#line 1 1 \n"
"layout (location = 0) out vec4 oColour;\n"
"\n"
"layout (std140) uniform ub_world_lighting\n"
" return texture( g_world_depth, depth_coord ).r;\n"
"}\n"
"\n"
+"float world_water_depth( vec3 pos )\n"
+"{\n"
+" vec2 depth_coord = (pos.xz - g_depth_bounds.xy) * g_depth_bounds.zw; \n"
+" float ref_depth = g_water_plane.y*g_water_plane.w;\n"
+" return texture( g_world_depth, depth_coord ).g - ref_depth;\n"
+"}\n"
+"\n"
"float shadow_sample( vec3 vdir )\n"
"{\n"
" vec3 sample_pos = aWorldCo + vdir;\n"
" return light_colour*attenuation;\n"
"}\n"
"\n"
+"#line 4 0 \n"
+"\n"
+"vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )\n"
+"{\n"
+" // Lighting\n"
+" vec3 halfview = uCamera - aWorldCo;\n"
+" float fdist = length(halfview);\n"
+" halfview /= fdist;\n"
+"\n"
+" vec3 total_light = newlight_compute_ambient();\n"
+" \n"
+" // Compute world lighting contribution and apply it according to the\n"
+" // shadow map\n"
+" //\n"
+" vec3 world_light = newlight_compute_world_diffuse( wnormal );\n"
+" world_light += newlight_compute_sun_spec( wnormal, halfview, 0.1 );\n"
+"\n"
+" float world_shadow = newlight_compute_sun_shadow();\n"
+"\n"
+" total_light += world_light * world_shadow;\n"
+"\n"
+" // Compute the other lights that exist in the map, not effected by the sun\n"
+" // shadow\n"
+" total_light += newlight_compute_quadratic\n"
+" ( \n"
+" wnormal, halfview,\n"
+" g_point_light_positions[ aLights.x ].xyz,\n"
+" g_point_light_colours[ aLights.x ].rgb \n"
+" );\n"
+" total_light += newlight_compute_quadratic\n"
+" ( \n"
+" wnormal, halfview,\n"
+" g_point_light_positions[ aLights.y ].xyz,\n"
+" g_point_light_colours[ aLights.y ].rgb \n"
+" );\n"
+" total_light += newlight_compute_quadratic\n"
+" ( \n"
+" wnormal, halfview,\n"
+" g_point_light_positions[ aLights.z ].xyz,\n"
+" g_point_light_colours[ aLights.z ].rgb \n"
+" );\n"
+"\n"
+" return apply_fog( diffuse * total_light, fdist );\n"
+"}\n"
+"\n"
"#line 14 0 \n"
"\n"
"// Water blending\n"
"\n"
"void main()\n"
"{\n"
-" vec3 halfview = normalize( uCamera - aCo );\n"
-" vec3 world_pos = vec3( aCo.y, aCo.x, aCo.z );\n"
-" FragColor = vec4( world_pos, water_depth( aCo, halfview ) );\n"
+" vec3 halfview = normalize( uCamera - aWorldCo );\n"
+" float depth = water_depth( aWorldCo, halfview );\n"
+" FragColor = vec4( depth, 0.0, 0.0, 0.0 );\n"
"}\n"
""},
};