X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=shaders%2Fcommon_world.glsl;h=5c06d73db33caf07636035c02042dd0a7a7388da;hb=a1056ed8198f0f5be0e0f341da8bd49aa6c47198;hp=57b45411a1e924f7f581cd75b96c8784c3bfed1e;hpb=2e4531dfd7bd0d9a0776fda1a62653806d85eb3b;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/shaders/common_world.glsl b/shaders/common_world.glsl index 57b4541..5c06d73 100644 --- a/shaders/common_world.glsl +++ b/shaders/common_world.glsl @@ -19,6 +19,7 @@ layout (std140) uniform ub_world_lighting float g_water_fog; float g_time; + float g_realtime; float g_shadow_length; float g_shadow_spread; @@ -122,13 +123,13 @@ vec3 scene_calculate_light( int light_index, float falloff = max( 0.0, 1.0-(dist2*light_co.w) ); - if( light_dir.w < 0.999999 ) - { + if( light_dir.w < 0.999999 ){ float spot_theta = max( 0.0, dot( light_delta, -light_dir.xyz ) ); falloff *= max( 0.0, (spot_theta - light_dir.w) / (1.0-light_dir.w) ); } - return light_colour.rgb * attenuation * falloff; + return light_colour.rgb * attenuation * falloff + * step( g_day_phase, light_colour.w ); } vec3 scene_calculate_packed_light_patch( uint packed_index, @@ -138,20 +139,17 @@ vec3 scene_calculate_packed_light_patch( uint packed_index, vec3 l = vec3(0.0); - if( light_count >= 1u ) - { + if( light_count >= 1u ){ int index_0 = int( ((packed_index >> 2u) & 0x3ffu) * 3u ); int index_1 = int( ((packed_index >> 12u) & 0x3ffu) * 3u ); int index_2 = int( ((packed_index >> 22u) & 0x3ffu) * 3u ); l += scene_calculate_light( index_0, halfview, co, normal ); - if( light_count >= 2u ) - { + if( light_count >= 2u ){ l += scene_calculate_light( index_1, halfview, co, normal ); - if( light_count >= 3u ) - { + if( light_count >= 3u ){ l += scene_calculate_light( index_2, halfview, co, normal ); } }