fix da bugs
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_depth.h
index 53b2bfafaf22ebf33896abb1e4cc4dbef2050fcf..ce1a818cf6ade704fe7536771cb553efcadc1cf0 100644 (file)
@@ -76,6 +76,9 @@ static struct vg_shader _shader_scene_depth = {
 "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"
@@ -202,6 +205,51 @@ static struct vg_shader _shader_scene_depth = {
 "   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"
@@ -219,9 +267,9 @@ static struct vg_shader _shader_scene_depth = {
 "\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( aWorldCo.y, 0.0, 0.0,depth );\n"
 "}\n"
 ""},
 };