[Scummvm-git-logs] scummvm master -> 9778a07def8fda13cd9715860bd4b110b04eb217
aquadran
aquadran at gmail.com
Mon Oct 18 05:43:46 UTC 2021
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9778a07def STARK: Cleanup actor light shader code
Commit: 9778a07def8fda13cd9715860bd4b110b04eb217
https://github.com/scummvm/scummvm/commit/9778a07def8fda13cd9715860bd4b110b04eb217
Author: PaweÅ KoÅodziejski (aquadran at gmail.com)
Date: 2021-10-18T07:43:42+02:00
Commit Message:
STARK: Cleanup actor light shader code
Changed paths:
engines/stark/shaders/stark_actor.vertex
diff --git a/engines/stark/shaders/stark_actor.vertex b/engines/stark/shaders/stark_actor.vertex
index aa08a2e80a..dbfd0893dc 100644
--- a/engines/stark/shaders/stark_actor.vertex
+++ b/engines/stark/shaders/stark_actor.vertex
@@ -60,12 +60,17 @@ vec3 directionalLight(vec3 direction, vec3 color) {
vec3 spotLight(vec3 position, vec3 color, float falloffNear, float falloffFar, vec3 direction, float cosInnerAngle, float cosOuterAngle) {
vec3 vertexToLight = position - eyePosition.xyz;
+
+ float dist = length(vertexToLight);
+ float attn = clamp((falloffFar - dist) / max(0.001, falloffFar - falloffNear), 0.0, 1.0);
+
vertexToLight = normalize(vertexToLight);
+ float incidence = max(0.0, dot(eyeNormal, vertexToLight));
float cosAngle = max(0.0, dot(vertexToLight, -direction));
float cone = clamp((cosAngle - cosInnerAngle) / max(0.001, cosOuterAngle - cosInnerAngle), 0.0, 1.0);
- return pointLight(position, color, falloffNear, falloffFar) * cone;
+ return color * attn * incidence * cone;
}
void main()
@@ -105,7 +110,7 @@ void main()
lightColor += directionalLight(lights[i].direction, lights[i].color);
} else if (type == lightTypeSpot) {
lightColor += spotLight(lights[i].position.xyz, lights[i].color, lights[i].params.x, lights[i].params.y,
- lights[i].direction, lights[i].params.z, lights[i].params.w);
+ lights[i].direction, lights[i].params.z, lights[i].params.w);
}
}
More information about the Scummvm-git-logs
mailing list