From ec27e60284511a11ce9f775f2b4d27f5548cfd7e Mon Sep 17 00:00:00 2001 From: "glassmancody.info" Date: Sat, 27 Mar 2021 23:41:22 -0700 Subject: [PATCH] Cutoff conditional in light shader --- files/settings-default.cfg | 2 +- files/shaders/lighting.glsl | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/files/settings-default.cfg b/files/settings-default.cfg index b74d3ce02..102c1aa66 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -448,7 +448,7 @@ lighting method = experimental # Sets the bounding sphere multiplier of light sources, which are used to determine if an object should # receive lighting. Higher values will allow for smoother transitions of light sources, but may have a performance cost and # requires a higher number of 'max lights' set. It is recommended to keep this at 1.0 with 'legacy' lighting enabled. -light bounds multiplier = 2.0 +light bounds multiplier = 1.0 # The distance from the camera at which lights fade away completely. Set to 0 to disable fading. maximum light distance = 8192 diff --git a/files/shaders/lighting.glsl b/files/shaders/lighting.glsl index 257c0513a..4b7e23314 100644 --- a/files/shaders/lighting.glsl +++ b/files/shaders/lighting.glsl @@ -101,6 +101,17 @@ void perLightPoint(out vec3 ambientOut, out vec3 diffuseOut, int lightIndex, vec vec3 lightDir = getLight[lightIndex].position.xyz - viewPos; float lightDistance = length(lightDir); + +#if !@ffpLighting + // This has a *considerable* performance uplift where GPU is a bottleneck + if (lightDistance > getLight[lightIndex].attenuation.w * 2.0) + { + ambientOut = vec3(0.0); + diffuseOut = vec3(0.0); + return; + } +#endif + lightDir = normalize(lightDir); #if @ffpLighting