7 flat in vec4 light_colours[3];
8 flat in vec4 light_positions[3];
10 #include "common_world.glsl"
12 float sdLine( vec3 p, vec3 a, vec3 b )
17 float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
18 return length( pa - ba*h );
21 float compute_board_shadow()
24 float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 );
25 float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );
26 player_shadow *= player_shadow*player_shadow*player_shadow;
28 return 1.0 - player_shadow*0.8;
31 vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )
34 vec3 halfview = uCamera - aWorldCo;
35 float fdist = length(halfview);
38 vec3 total_light = newlight_compute_ambient();
40 // Compute world lighting contribution and apply it according to the
43 vec3 world_light = newlight_compute_world_diffuse( wnormal );
44 world_light += newlight_compute_sun_spec( wnormal, halfview, 0.1 );
46 float world_shadow = newlight_compute_sun_shadow();
47 float board_shadow = compute_board_shadow();
49 total_light += world_light * min( board_shadow, world_shadow );
51 // Compute the other lights that exist in the map, not effected by the sun
54 total_light += newlight_compute_quadratic
57 light_positions[0].xyz,
60 total_light += newlight_compute_quadratic
63 light_positions[1].xyz,
66 total_light += newlight_compute_quadratic
69 light_positions[2].xyz,
73 return apply_fog( diffuse * total_light, fdist );