From 4897cf7ef2070120310c28a1a672b427d745dad8 Mon Sep 17 00:00:00 2001 From: Skyth <19259897+blueskythlikesclouds@users.noreply.github.com> Date: Sat, 15 Mar 2025 21:41:52 +0300 Subject: [PATCH] Apply half pixel offset in the vertex shader. --- XenosRecomp/shader_common.h | 6 ++++-- XenosRecomp/shader_recompiler.cpp | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/XenosRecomp/shader_common.h b/XenosRecomp/shader_common.h index 7ce0d8a..c9ef6ff 100644 --- a/XenosRecomp/shader_common.h +++ b/XenosRecomp/shader_common.h @@ -25,7 +25,8 @@ struct PushConstants #define g_Booleans vk::RawBufferLoad(g_PushConstants.SharedConstants + 256) #define g_SwappedTexcoords vk::RawBufferLoad(g_PushConstants.SharedConstants + 260) -#define g_AlphaThreshold vk::RawBufferLoad(g_PushConstants.SharedConstants + 264) +#define g_HalfPixelOffset vk::RawBufferLoad(g_PushConstants.SharedConstants + 264) +#define g_AlphaThreshold vk::RawBufferLoad(g_PushConstants.SharedConstants + 272) [[vk::constant_id(0)]] const uint g_SpecConstants = 0; @@ -36,7 +37,8 @@ struct PushConstants #define DEFINE_SHARED_CONSTANTS() \ uint g_Booleans : packoffset(c16.x); \ uint g_SwappedTexcoords : packoffset(c16.y); \ - float g_AlphaThreshold : packoffset(c16.z) \ + float2 g_HalfPixelOffset : packoffset(c16.z); \ + float g_AlphaThreshold : packoffset(c17.x); uint g_SpecConstants(); diff --git a/XenosRecomp/shader_recompiler.cpp b/XenosRecomp/shader_recompiler.cpp index e59879f..c73483c 100644 --- a/XenosRecomp/shader_recompiler.cpp +++ b/XenosRecomp/shader_recompiler.cpp @@ -1782,6 +1782,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi indent(); out += '}'; } + else + { + out += "\toPos.xy += g_HalfPixelOffset * oPos.w;\n"; + } if (simpleControlFlow) {