- float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) ),
- falloff = max( 0.0,( spot_theta - light_dir.w ) / (1.0-light_dir.w) );
+ return l;
+}
+
+vec3 world_compute_lighting( vec3 diffuse, vec3 normal, vec3 co,
+ float light_mask )
+{
+ if( g_light_preview == 1 )
+ diffuse = vec3(0.75);
+
+ // Lighting
+ vec3 halfview = uCamera - co;
+ float fdist = length(halfview);
+ halfview /= fdist;
+
+ float world_shadow = newlight_compute_sun_shadow( g_sun_dir.xyz
+ * (1.0/(max(g_sun_dir.y,0.0)+0.2)) );
+
+ vec3 total_light = clearskies_lighting(
+ normal, min( light_mask, world_shadow ), halfview );
+
+ vec3 cube_coord = (co - g_cube_min.xyz) * g_cube_inv_range.xyz;
+ cube_coord = floor( cube_coord );
+
+ if( g_debug_indices == 1 )
+ {
+ return rand33(cube_coord);
+ }
+
+ if( g_debug_complexity == 1 )
+ {
+ ivec3 coord = ivec3( cube_coord );
+ uvec4 index_sample = texelFetch( uLightsIndex, coord, 0 );
+
+ uint light_count = (index_sample.x & 0x3u) + (index_sample.y & 0x3u);
+ return vec3( float(light_count)*(1.0/6.0), 0.0, 0.5 );
+ }