layout (std140) uniform ub_world_lighting
{
+ vec4 g_cube_min;
+ vec4 g_cube_inv_range;
+
vec4 g_light_colours[3];
vec4 g_light_directions[3];
vec4 g_ambient_colour;
int g_light_preview;
int g_shadow_samples;
+ int g_debug_indices;
+ int g_debug_complexity;
+
// g_time ?
//vec4 g_point_light_positions[32];
return pow(max(dot( halfview, specdir ), 0.0), exponent);
}
-vec3 newlight_compute_quadratic( vec3 wnormal, vec3 halfview,
+vec3 newlight_compute_quadratic( vec3 wnormal, float max_dist,
vec3 light_colour, vec3 light_pos )
{
- vec3 light_delta = (light_pos-aWorldCo) * 10.0;
+ vec3 light_delta = light_pos-aWorldCo;
- float quadratic = dot(light_delta,light_delta);
- float attenuation = 1.0f/( 1.0f + quadratic );
- attenuation *= max( 0.0, dot( normalize(light_delta), wnormal ) );
+ float dist2 = dot(light_delta,light_delta);
+
+ float quadratic = dist2*100.0;
+ float attenuation = 1.0f/( 1.0f + quadratic );
+ attenuation *= max( dot( normalize(light_delta), wnormal ), 0.0 );
- return light_colour*attenuation;
+ float falloff = max( 0.0, 1.0-(dist2*max_dist) );
+ return light_colour * attenuation * falloff;
}
vec3 newlight_compute_spot( vec3 wnormal, vec3 halfview,