diff --git a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp index f9c0a7e187..4eec853e77 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/D3D12/D3D12CommonDecompiler.cpp @@ -185,13 +185,16 @@ void insert_d3d12_legacy_function(std::ostream& OS) OS << " return unpackSnorm2x16(val) * 6.1E+5;\n"; OS << "}\n\n"; + //NOTE: After testing with GOW, the w component is either the original depth or wraps around to the x component + //Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed) + //TODO: This function does not work as intended on DX12 OS << "float4 texture2DReconstruct(float depth_value)\n"; OS << "{\n"; OS << " uint value = round(depth_value * 16777215);\n"; OS << " uint b = (value & 0xff);\n"; OS << " uint g = (value >> 8) & 0xff;\n"; OS << " uint r = (value >> 16) & 0xff;\n"; - OS << " return float4(r/255., g/255., b/255., 1.);\n"; + OS << " return float4(r/255., g/255., b/255., depth_value);\n"; OS << "}\n\n"; } #endif diff --git a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp index 92935f695f..da099c5414 100644 --- a/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/GL/GLCommonDecompiler.cpp @@ -121,6 +121,8 @@ void insert_glsl_legacy_function(std::ostream& OS) OS << "}\n\n"; //NOTE: We lose precision if we just store depth value into 8-bit textures i.e (depth, 0, 0) + //NOTE2: After testing with GOW, the w component is either the original depth or wraps around to the x component + //Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed) OS << "vec4 texture2DReconstruct(sampler2D tex, vec2 coord)\n"; OS << "{\n"; OS << " float depth_value = texture(tex, coord.xy).r;\n"; @@ -128,6 +130,6 @@ void insert_glsl_legacy_function(std::ostream& OS) OS << " uint b = (value & 0xff);\n"; OS << " uint g = (value >> 8) & 0xff;\n"; OS << " uint r = (value >> 16) & 0xff;\n"; - OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., 1.);\n"; + OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., depth_value);\n"; OS << "}\n\n"; } diff --git a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp index f607dc98e8..f8be66576f 100644 --- a/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp +++ b/rpcs3/Emu/RSX/VK/VKCommonDecompiler.cpp @@ -117,13 +117,15 @@ namespace vk OS << " return result;\n"; OS << "}\n\n"; + //NOTE: After testing with GOW, the w component is either the original depth or wraps around to the x component + //Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed) OS << "vec4 decodeLinearDepth(float depth_value)\n"; OS << "{\n"; OS << " uint value = uint(depth_value * 16777215);\n"; OS << " uint b = (value & 0xff);\n"; OS << " uint g = (value >> 8) & 0xff;\n"; OS << " uint r = (value >> 16) & 0xff;\n"; - OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., 1.);\n"; + OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., depth_value);\n"; OS << "}\n\n"; OS << "vec4 texture2DReconstruct(sampler2D tex, vec2 coord)\n";