[Scummvm-git-logs] scummvm master -> 929be8852be275b23c1cf9a8b036d262a236e8af
klusark
noreply at scummvm.org
Wed Nov 11 14:35:53 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:
929be8852b GRIM: Read the z-buffer exactly in the OpenGL shaders renderer
Commit: 929be8852be275b23c1cf9a8b036d262a236e8af
https://github.com/scummvm/scummvm/commit/929be8852be275b23c1cf9a8b036d262a236e8af
Author: Joel Teichroeb (joel at teichroeb.net)
Date: 2026-11-11T09:35:11-05:00
Commit Message:
GRIM: Read the z-buffer exactly in the OpenGL shaders renderer
The z-buffer texture was sampled with linear filtering at texel corners,
averaging each depth with its neighbours, so thin background objects hid
too much of the actors behind them. Sample the texel itself and compare
as the fixed pipeline's GL_LESS test does.
To reproduce, walk Manny behind the fence by the crane in ew.
Assisted-by: Claude:claude-opus-5-5
Changed paths:
engines/grim/gfx_opengl_shaders.cpp
engines/grim/shaders/grim_object.fragment
diff --git a/engines/grim/gfx_opengl_shaders.cpp b/engines/grim/gfx_opengl_shaders.cpp
index 2bd508540b0..f3435300c49 100644
--- a/engines/grim/gfx_opengl_shaders.cpp
+++ b/engines/grim/gfx_opengl_shaders.cpp
@@ -262,8 +262,8 @@ void GfxOpenGLS::setupZBuffer() {
glBindTexture(GL_TEXTURE_2D, _zBufTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, format, nextHigher2((int)width), nextHigher2((int)height), 0, format, ztype, nullptr);
glActiveTexture(GL_TEXTURE0);
diff --git a/engines/grim/shaders/grim_object.fragment b/engines/grim/shaders/grim_object.fragment
index da120ba5a86..8ffd2997d6f 100644
--- a/engines/grim/shaders/grim_object.fragment
+++ b/engines/grim/shaders/grim_object.fragment
@@ -14,11 +14,11 @@ const float offsetY = 0.0;
OUTPUT
void checkZBuffer() {
- vec2 zCoord = vec2((gl_FragCoord.x - 0.5) / screenSize.x, 1.0 - (gl_FragCoord.y - offsetY - 0.5) / screenSize.y);
- vec2 sampled = texture(texZBuf, zCoord * texcropZBuf).ra;
- float sceneZ = sampled.y + sampled.x / 256.0;
+ vec2 zCoord = vec2(gl_FragCoord.x / screenSize.x, 1.0 - (gl_FragCoord.y - offsetY) / screenSize.y);
+ vec2 sampled = floor(texture(texZBuf, zCoord * texcropZBuf).ra * 255.0 + 0.5);
+ float sceneZ = sampled.y * 256.0 + sampled.x;
- if (gl_FragCoord.z * 1.0039 > sceneZ)
+ if (gl_FragCoord.z * 65535.0 >= sceneZ)
discard;
}
More information about the Scummvm-git-logs
mailing list