diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PSTextureEncoder.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PSTextureEncoder.cpp index aad3bfdff8..582b8bd351 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PSTextureEncoder.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PSTextureEncoder.cpp @@ -204,27 +204,14 @@ static const char EFB_ENCODE_PS[] = "float4 Fetch_3(uint2 coord)\n" "{\n" "float2 texCoord = CalcTexCoord(coord);\n" - // Ref: - // Ref: - "float depth = 255.99998474121094 * EFBTexture.Sample(EFBSampler, texCoord).r;\n" - "float4 result = depth.rrrr;\n" - "result.a = floor(result.a);\n" // bits 31..24 - - "result.rgb -= result.a;\n" - "result.rgb *= 256.0;\n" - "result.r = floor(result.r);\n" // bits 23..16 - - "result.gb -= result.r;\n" - "result.gb *= 256.0;\n" - "result.g = floor(result.g);\n" // bits 15..8 - - "result.b -= result.g;\n" - "result.b *= 256.0;\n" - "result.b = floor(result.b);\n" // bits 7..0 - - "result = float4(result.arg / 255.0, 1.0);\n" - "return result;\n" + "uint depth24 = 0xFFFFFF * EFBTexture.Sample(EFBSampler, texCoord).r;\n" + "uint4 bytes = uint4(\n" + "(depth24 >> 16) & 0xFF,\n" // r + "(depth24 >> 8) & 0xFF,\n" // g + "depth24 & 0xFF,\n" // b + "255);\n" // a + "return bytes / 255.0;\n" "}\n" "#ifdef DYNAMIC_MODE\n" diff --git a/Source/Plugins/Plugin_VideoDX11/Src/TextureEncoder.h b/Source/Plugins/Plugin_VideoDX11/Src/TextureEncoder.h index d3f8ee531b..4f5413e0e2 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/TextureEncoder.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/TextureEncoder.h @@ -68,7 +68,8 @@ namespace DX11 // Format: B - G8 R8 // Used in Wind Waker for depth-of-field. Usually used with srcFormat 3 to -// render depth textures. +// render depth textures. The bytes are swapped, so games have to correct it +// in RAM before using it as a texture. // Format: C - B8 G8 // FIXME: Unseen.