mirror of
https://github.com/overte-org/overte.git
synced 2025-04-17 06:46:22 +02:00
Merge pull request #7945 from Geenz/20901
20901: Add Range Based Light Attenuation
This commit is contained in:
commit
b76cda3c89
2 changed files with 10 additions and 2 deletions
|
@ -98,10 +98,18 @@ float getLightShowContour(Light l) {
|
|||
return l._control.w;
|
||||
}
|
||||
|
||||
// Light is the light source its self, d is the light's distance calculated as length(unnormalized light vector).
|
||||
float evalLightAttenuation(Light l, float d) {
|
||||
float radius = getLightRadius(l);
|
||||
float denom = d / radius + 1.0;
|
||||
float attenuation = min(1.0, 1.0 / (denom * denom));
|
||||
float attenuation = 1.0 / (denom * denom);
|
||||
|
||||
float cutoff = getLightCutoffRadius(l);
|
||||
|
||||
// "Fade" the edges of light sources to make things look a bit more attractive.
|
||||
// Note: this tends to look a bit odd at lower exponents.
|
||||
attenuation *= min(1, max(0, -(d - cutoff)));
|
||||
|
||||
return attenuation;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ void main(void) {
|
|||
vec3 fragEyeDir = normalize(fragEyeVector.xyz);
|
||||
vec4 shading = evalFragShading(fragNormal, fragLightDir, fragEyeDir, frag.metallic, frag.specular, frag.roughness);
|
||||
|
||||
// Eval attenuation
|
||||
// Eval attenuation
|
||||
float radialAttenuation = evalLightAttenuation(light, fragLightDistance);
|
||||
|
||||
// Final Lighting color
|
||||
|
|
Loading…
Reference in a new issue