Fix some SpotLight3D issues (clustering artifacts, light leak)

This commit is contained in:
Hendrik Brucker 2023-01-24 01:08:32 +01:00
parent c3539b4561
commit 4bd01a93dc
5 changed files with 101 additions and 65 deletions

View file

@ -690,7 +690,8 @@ void light_compute(vec3 N, vec3 L, vec3 V, float A, vec3 light_color, float atte
#endif
#if defined(LIGHT_RIM_USED)
float rim_light = pow(max(0.0, 1.0 - cNdotV), max(0.0, (1.0 - roughness) * 16.0));
// Epsilon min to prevent pow(0, 0) singularity which results in undefined behavior.
float rim_light = pow(max(1e-4, 1.0 - cNdotV), max(0.0, (1.0 - roughness) * 16.0));
diffuse_light += rim_light * rim * mix(vec3(1.0), albedo, rim_tint) * light_color;
#endif
}