X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fcommon_scene.glsl;h=76658f2151aa1176439cea0d1489673131037d9d;hb=74b2136d5b41b18e2eec698f1fd11b503aa1100a;hp=c71f5e2dbb4dbbd3359be1afa933eaaf5ba6f1c3;hpb=409edea2cf6271956137918e4e0b4f1c2addf620;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/common_scene.glsl b/shaders/common_scene.glsl index c71f5e2..76658f2 100644 --- a/shaders/common_scene.glsl +++ b/shaders/common_scene.glsl @@ -4,8 +4,6 @@ in vec2 aUv; in vec4 aNorm; in vec3 aCo; in vec3 aWorldCo; -flat in vec4 light_colours[3]; -flat in vec4 light_positions[3]; #include "common_world.glsl" @@ -21,54 +19,15 @@ float sdLine( vec3 p, vec3 a, vec3 b ) float compute_board_shadow() { // player shadow - float dist_to_player = max( 0.0, sdLine( aWorldCo, uBoard0, uBoard1 )-0.1 ); + 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; return 1.0 - player_shadow*0.8; } -vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal ) +vec3 scene_compute_lighting( vec3 diffuse, vec3 normal, vec3 co ) { - // 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 ); + return world_compute_lighting( diffuse, normal, co, compute_board_shadow() ); }