- float dist = pow(fdist*0.0010,0.78);
- return mix( vfrag, colour, min( 1.0, dist ) );
-}
-
-vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )
-{
- world_info world;
- scene_state( g_time, world );
-
- // Lighting
- vec3 halfview = uCamera - aWorldCo;
- float fdist = length(halfview);
- halfview /= fdist;
-
- vec3 total_light = vec3(0.0);
-
-
- float world_shadow = newlight_compute_sun_shadow( world.sun_dir
- * (1.0/(max(world.sun_dir.y,0.0)+0.2)) );
- float board_shadow = compute_board_shadow();
-
- total_light += scene_lighting( wnormal, min( board_shadow, world_shadow ),
- halfview, world );
-
- //total_light += scene_lighting_old( wnormal, world );
-
- // Compute the other lights that exist in the map, not effected by the sun
- // shadow
-
- // read lights
- vec4 light_colour_0 = texelFetch( uLightsArray, light_indices.x*3+0 );
- vec4 light_colour_1 = texelFetch( uLightsArray, light_indices.y*3+0 );
- vec4 light_colour_2 = texelFetch( uLightsArray, light_indices.z*3+0 );
- vec4 light_co_0 = texelFetch( uLightsArray, light_indices.x*3+1 );
- vec4 light_co_1 = texelFetch( uLightsArray, light_indices.y*3+1 );
- vec4 light_co_2 = texelFetch( uLightsArray, light_indices.z*3+1 );
- vec4 light_dir_0 = texelFetch( uLightsArray, light_indices.x*3+2 );
- vec4 light_dir_1 = texelFetch( uLightsArray, light_indices.y*3+2 );
- vec4 light_dir_2 = texelFetch( uLightsArray, light_indices.z*3+2 );
-
- //return vec3(fract(distance(light_co_0.xyz,aWorldCo)),
- // fract(distance(light_co_1.xyz,aWorldCo)),
- // fract(distance(light_co_2.xyz,aWorldCo)));
-
- // return vec3(fract(light_indices.x * 0.125), fract(light_indices.y*0.125),
- // fract(light_indices.z * 0.125 ));
-
- total_light += newlight_compute_spot
- (
- wnormal, halfview,
- light_colour_0.rgb,
- light_co_0.xyz,
- light_dir_0
- ) * board_shadow;
-
- total_light += newlight_compute_spot
- (
- wnormal, halfview,
- light_colour_1.rgb,
- light_co_1.xyz,
- light_dir_1
- ) * board_shadow;
- total_light += newlight_compute_spot
- (
- wnormal, halfview,
- light_colour_2.rgb,
- light_co_2.xyz,
- light_dir_2
- ) * board_shadow;
-
- vec3 fog_colour = scene_sky( -halfview, world );
-
- return scene_apply_fog( diffuse * total_light, fog_colour, fdist );