[Scummvm-git-logs] scummvm master -> 5ddae536c2a3018c9119f983c2b85263e938fd78

klusark noreply at scummvm.org
Tue Nov 10 23:49:37 UTC 2026


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .

Summary:
5ddae536c2 EMI: Fix spotlights and empty falloff ranges in the actor shader


Commit: 5ddae536c2a3018c9119f983c2b85263e938fd78
    https://github.com/scummvm/scummvm/commit/5ddae536c2a3018c9119f983c2b85263e938fd78
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-10T18:46:38-05:00

Commit Message:
EMI: Fix spotlights and empty falloff ranges in the actor shader

EMI stores the spot direction pointing back towards the light, so the
cosine of the angle to the vertex had the wrong sign and spotlights lit
the wrong side. A light whose falloff near and far distances are equal
is at full intensity up to that distance and off beyond it, as in the
software lighting, instead of always off.

Assisted-by: Claude:claude-sonnet-5.5

Changed paths:
    engines/grim/shaders/emi_actorlights.vertex


diff --git a/engines/grim/shaders/emi_actorlights.vertex b/engines/grim/shaders/emi_actorlights.vertex
index 156c7f261c8..f30101f5343 100644
--- a/engines/grim/shaders/emi_actorlights.vertex
+++ b/engines/grim/shaders/emi_actorlights.vertex
@@ -83,13 +83,16 @@ void main() {
 				vertexToLight = lightsPosition[i].xyz - pos.xyz;
 				float dist = length(vertexToLight);
 				if (falloffFar == falloffNear) {
-					intensity = 0.0;
+					// no falloff range: full intensity within the distance, none beyond (as in the software lighting)
+					if (dist > falloffFar)
+						intensity = 0.0;
 				} else {
 					intensity *= clamp(1.0 - (dist - falloffNear) / (falloffFar - falloffNear), 0.0, 1.0);
 				}
 				if (lightsDirection[i].w > -1.0) { // Spotlight
 					// See DirectX spotlight documentation
-					float cosAngle = -dot(normalize(vertexToLight), normalize(lightsDirection[i].xyz)); // rho
+					// EMI stores the spot direction pointing back towards the light
+					float cosAngle = dot(normalize(vertexToLight), normalize(lightsDirection[i].xyz)); // rho
 					float cosPenumbra = clamp(lightsParams[i].w, 0.0, 1.0); // cos(theta / 2)
 					float cosUmbra = clamp(lightsParams[i].z, 0.0, cosPenumbra); // cos(phi / 2)
 					if (cosAngle <= cosPenumbra) {




More information about the Scummvm-git-logs mailing list