Lighter: No specular from a light behind the surface

The shaders and the software renderer only add specular when N.L >= 0,
as the GE does (gpu/lighting/specular); the CPU lighter, used for points,
lines and rectangles, didn't check.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Henrik RydgårdandClaude Opus 5.5 committed 2026-09-30 15:47:16 -06:00
1 parent d7a96875fb
commit 48f3d5c907
1 file changed
+3 -1
+3 -1
View File
@@ -117,6 +117,8 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
toLight /= distanceToLight;
dot = Dot(toLight, norm);
}
// Specular only applies when the light is in front of the surface.
const bool facingLight = dot >= 0.0f;
// Clamp dot to zero.
if (dot < 0.0f) dot = 0.0f;
@@ -151,7 +153,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
// Better specular
// Vec3f toViewer = (viewer - pos).NormalizedOr001(cpu_info.bSSE4_1);
if (doSpecular) {
if (doSpecular && facingLight) {
Vec3f halfVec = (toLight + toViewer).NormalizedOr001(cpu_info.bSSE4_1);
dot = Dot(halfVec, norm);