grid based
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / model_sky.h
index 2fb62ff6564cd9fa84d5cb21c294957046ec21f4..8fe64c41dd373ad3e294a3964a7139b9d801624f 100644 (file)
@@ -79,6 +79,9 @@ static struct vg_shader _shader_model_sky = {
 "\n"
 "layout (std140) uniform ub_world_lighting\n"
 "{\n"
+"   vec4 g_cube_min;\n"
+"   vec4 g_cube_inv_range;\n"
+"\n"
 "   vec4 g_light_colours[3];\n"
 "   vec4 g_light_directions[3];\n"
 "   vec4 g_ambient_colour;\n"
@@ -194,16 +197,19 @@ static struct vg_shader _shader_model_sky = {
 "   return pow(max(dot( halfview, specdir ), 0.0), exponent);\n"
 "}\n"
 "\n"
-"vec3 newlight_compute_quadratic( vec3 wnormal, vec3 halfview, \n"
+"vec3 newlight_compute_quadratic( vec3 wnormal, float max_dist,\n"
 "                                 vec3 light_colour, vec3 light_pos )\n"
 "{\n"
-"   vec3 light_delta = (light_pos-aWorldCo) * 10.0;\n"
+"   vec3 light_delta = light_pos-aWorldCo;\n"
 "\n"
-"   float quadratic = dot(light_delta,light_delta);\n"
-"   float attenuation = 1.0f/( 1.0f + quadratic );\n"
-"   attenuation *= max( 0.0, dot( normalize(light_delta), wnormal ) );\n"
+"   float dist2 = dot(light_delta,light_delta);\n"
+"\n"
+"   float quadratic = dist2*100.0;\n"
+"   float attenuation  = 1.0f/( 1.0f + quadratic );\n"
+"         attenuation *= max( dot( normalize(light_delta), wnormal ), 0.0 );\n"
 "\n"
-"   return light_colour*attenuation;\n"
+"   float falloff = max( 0.0, 1.0-(dist2*max_dist) );\n"
+"   return light_colour * attenuation * falloff;\n"
 "}\n"
 "\n"
 "vec3 newlight_compute_spot( vec3 wnormal, vec3 halfview, \n"