From 931c869ca9a61dd6957ca603d30caed33e521d68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 26 Oct 2022 13:40:13 +0200 Subject: [PATCH] Fix for stereo with textureProj (emulated projection). --- GPU/Common/FragmentShaderGenerator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/GPU/Common/FragmentShaderGenerator.cpp b/GPU/Common/FragmentShaderGenerator.cpp index 93b1e20464..879552e253 100644 --- a/GPU/Common/FragmentShaderGenerator.cpp +++ b/GPU/Common/FragmentShaderGenerator.cpp @@ -663,7 +663,10 @@ bool GenerateFragmentShader(const FShaderID &id, char *buffer, const ShaderLangu // Used for stereo rendering. const char *arrayIndex = useStereo ? "float(gl_ViewIndex)" : "0.0"; if (doTextureProjection) { - WRITE(p, " vec4 t = %sProj(tex, vec4(%s, %s));\n", compat.texture, texcoord, arrayIndex); + // There's no textureProj for array textures, so we need to emulate it. + // Should be fine on any Vulkan-compatible hardware. + WRITE(p, " vec2 uv_proj = (%s.xy) / (%s.z);\n", texcoord, texcoord); + WRITE(p, " vec4 t = %s(tex, vec3(uv_proj, %s));\n", compat.texture, texcoord, arrayIndex); } else { WRITE(p, " vec4 t = %s(tex, vec3(%s.xy, %s));\n", compat.texture, texcoord, arrayIndex); }