From f33b07115222af13016e1a70ae8f3350093d8612 Mon Sep 17 00:00:00 2001 From: NULL511 Date: Thu, 2 May 2024 13:06:48 -0400 Subject: [PATCH] fix floodfill lightmap fallback --- shaders/dimensions/composite1.fsh | 8 ++++++-- shaders/lib/diffuse_lighting.glsl | 16 ++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index 498829a..56f7d5e 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -1267,9 +1267,13 @@ void main() { #endif - vec3 lpvPos = GetLpvPosition(feetPlayerPos) + 0.5*viewToWorld(FlatNormals); + #ifdef IS_LPV_ENABLED + vec3 lpvPos = GetLpvPosition(feetPlayerPos) + 0.5*viewToWorld(FlatNormals); + #else + const vec3 lpvPos = vec3(0.0); + #endif // vec3 lpvPos = GetLpvPosition(feetPlayerPos) - 0.5*FlatNormals + slopednormal; - + Indirect_lighting = DoAmbientLightColor(lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy); Indirect_lighting *= Absorbtion; diff --git a/shaders/lib/diffuse_lighting.glsl b/shaders/lib/diffuse_lighting.glsl index 760d0e2..fd033ab 100644 --- a/shaders/lib/diffuse_lighting.glsl +++ b/shaders/lib/diffuse_lighting.glsl @@ -13,15 +13,19 @@ vec3 DoAmbientLightColor( vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight); // do torch lighting. + // float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1)); + // TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5; + + float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5); + vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333))); + #if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store vec4 lpvSample = SampleLpvLinear(lpvPos); - vec3 TorchLight = GetLpvBlockLight(lpvSample); - #else - // float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1)); - // TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5; + vec3 LpvTorchLight = GetLpvBlockLight(lpvSample); - float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5); - vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333))); + // TODO: needs work, just binary transition for now + float LpvFadeF = clamp(lpvPos, vec3(0.0), LpvSize3 - 1.0) == lpvPos ? 1.0 : 0.0; + TorchLight = mix(TorchLight, LpvTorchLight, LpvFadeF); #endif return IndirectLight + TorchLight;