- // Lighting
- vec3 halfview = uCamera - aWorldCo;
- float fdist = length(halfview);
- halfview /= fdist;
-
- vec3 total_light = newlight_compute_ambient();
-
- // Compute world lighting contribution and apply it according to the
- // shadow map
- //
- vec3 world_light = newlight_compute_world_diffuse( wnormal );
- world_light += newlight_compute_sun_spec( wnormal, halfview, 0.1 );
-
- float world_shadow = newlight_compute_sun_shadow();
- float board_shadow = compute_board_shadow();
-
- total_light += world_light * min( board_shadow, world_shadow );
-
- // Compute the other lights that exist in the map, not effected by the sun
- // shadow
-
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- light_positions[0].xyz,
- light_colours[0].rgb
- ) * board_shadow;
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- light_positions[1].xyz,
- light_colours[1].rgb
- ) * board_shadow;
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- light_positions[2].xyz,
- light_colours[2].rgb
- ) * board_shadow;
-
- return apply_fog( diffuse * total_light, fdist );