From 1d745d632ab9f4774bc38782cd688a5fa48bc097 Mon Sep 17 00:00:00 2001 From: Jules Blok Date: Fri, 8 May 2015 14:26:48 +0200 Subject: [PATCH] PixelShaderGen: Clamp zCoord to the depth range. --- Source/Core/VideoCommon/PixelShaderGen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/Core/VideoCommon/PixelShaderGen.cpp b/Source/Core/VideoCommon/PixelShaderGen.cpp index 975b8e7f71..562cb9be07 100644 --- a/Source/Core/VideoCommon/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/PixelShaderGen.cpp @@ -570,6 +570,7 @@ static inline void GeneratePixelShader(T& out, DSTALPHA_MODE dstAlphaMode, API_T // the screen space depth value = far z + (clip z / clip w) * z range out.Write("\tint zCoord = " I_ZBIAS"[1].x + int((clipPos.z / clipPos.w) * float(" I_ZBIAS"[1].y));\n"); } + out.Write("\tzCoord = clamp(zCoord, " I_ZBIAS"[1].x - " I_ZBIAS"[1].y, " I_ZBIAS"[1].x);\n"); // depth texture can safely be ignored if the result won't be written to the depth buffer (early_ztest) and isn't used for fog either const bool skip_ztexture = !per_pixel_depth && !bpmem.fog.c_proj_fsel.fsel;