// :D
+in vec2 aUv;
+in vec4 aNorm;
+in vec3 aCo;
+in vec3 aWorldCo;
+
#include "common_world.glsl"
-vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal )
+float sdLine( vec3 p, vec3 a, vec3 b )
{
- // 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 );
+ vec3 pa = p - a;
+ vec3 ba = b - a;
- float world_shadow = newlight_compute_sun_shadow();
+ float h = clamp( dot(pa,ba)/dot(ba,ba), 0.0, 1.0 );
+ return length( pa - ba*h );
+}
- total_light += world_light * world_shadow;
+float compute_board_shadow()
+{
+ // player shadow
+ float dist_to_player = max( 0.0, sdLine( aWorldCo, g_board_0.xyz,
+ g_board_1.xyz )-0.1 );
+ float player_shadow = max( 1.0-dist_to_player*2.7, 0.0 );
+ player_shadow *= player_shadow*player_shadow*player_shadow;
- // Compute the other lights that exist in the map, not effected by the sun
- // shadow
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- g_point_light_positions[ aLights.x ].xyz,
- g_point_light_colours[ aLights.x ].rgb
- );
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- g_point_light_positions[ aLights.y ].xyz,
- g_point_light_colours[ aLights.y ].rgb
- );
- total_light += newlight_compute_quadratic
- (
- wnormal, halfview,
- g_point_light_positions[ aLights.z ].xyz,
- g_point_light_colours[ aLights.z ].rgb
- );
+ return 1.0 - player_shadow*0.8;
+}
- return apply_fog( diffuse * total_light, fdist );
+vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co )
+{
+ return world_compute_lighting( diffuse, normal, co, compute_board_shadow() );
}