X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fcommon_scene.glsl;h=91dc6a19cf7116cae9b1a1e5a110418ab4dbc1ae;hb=791f807111a1f740f745c67db642aa7a8bee56e8;hp=2cf00b9878d0427d386964f645e99463f0fb60bd;hpb=e61356f70eddb79f05d7b9e329e91963ec74f817;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/common_scene.glsl b/shaders/common_scene.glsl index 2cf00b9..91dc6a1 100644 --- a/shaders/common_scene.glsl +++ b/shaders/common_scene.glsl @@ -72,35 +72,57 @@ vec3 scene_do_lighting( vec3 diffuse, vec3 wnormal ) 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; + if( g_debug_indices == 1 ) + { + float rings = min( fract(distance(light_co_0.xyz,aWorldCo)), + min( 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 )) + (rings-0.5) * 0.25; + } + + if( g_debug_complexity == 1 ) + { + return vec3(1.0,0.0,0.0) * ( light_indices.w/3.0 ); + } + + if( light_indices.w >= 1 ) + { + total_light += newlight_compute_spot + ( + wnormal, halfview, + light_colour_0.rgb, + light_co_0.xyz, + light_dir_0 + ) * board_shadow + * step( world.day_phase, light_colour_0.w ); + + if( light_indices.w >= 2 ) + { + total_light += newlight_compute_spot + ( + wnormal, halfview, + light_colour_1.rgb, + light_co_1.xyz, + light_dir_1 + ) * board_shadow + * step( world.day_phase, light_colour_1.w ); + + if( light_indices.w >= 3 ) + { + total_light += newlight_compute_spot + ( + wnormal, halfview, + light_colour_2.rgb, + light_co_2.xyz, + light_dir_2 + ) * board_shadow + * step( world.day_phase, light_colour_2.w ); + } + } + } vec3 fog_colour = scene_sky( -halfview, world );