Lighting GLSL library: use inverse square falloff for lighting in sRGB mode
- It is a slightly modified equation that actually terminates the light's influence at the light radius
This commit is contained in:
parent
4e7d7fd2f1
commit
9d715cdd2b
@ -11,7 +11,12 @@ void lightComputeDir(in vec3 worldPos, in float ligthType, in vec4 position, out
|
||||
vec3 tempVec = position.xyz * sign(posLight - 0.5) - (worldPos * posLight);
|
||||
lightVec = tempVec;
|
||||
float dist = length(tempVec);
|
||||
#ifdef SRGB
|
||||
lightDir.w = (1.0 - position.w * dist) / (1.0 + position.w * dist * dist);
|
||||
lightDir.w = clamp(lightDir.w, 0.0, 1.0);
|
||||
#else
|
||||
lightDir.w = clamp(1.0 - position.w * dist * posLight, 0.0, 1.0);
|
||||
#endif
|
||||
lightDir.xyz = tempVec / vec3(dist);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user