Skip to content

Commit 421e3b3

Browse files
Apply half pixel offset in the vertex shader. (#16)
1 parent b15b5e4 commit 421e3b3

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

XenosRecomp/shader_common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ struct PushConstants
2828

2929
#define g_Booleans vk::RawBufferLoad<uint>(g_PushConstants.SharedConstants + 256)
3030
#define g_SwappedTexcoords vk::RawBufferLoad<uint>(g_PushConstants.SharedConstants + 260)
31-
#define g_AlphaThreshold vk::RawBufferLoad<float>(g_PushConstants.SharedConstants + 264)
31+
#define g_HalfPixelOffset vk::RawBufferLoad<float2>(g_PushConstants.SharedConstants + 264)
32+
#define g_AlphaThreshold vk::RawBufferLoad<float>(g_PushConstants.SharedConstants + 272)
3233

3334
[[vk::constant_id(0)]] const uint g_SpecConstants = 0;
3435

@@ -39,7 +40,8 @@ struct PushConstants
3940
#define DEFINE_SHARED_CONSTANTS() \
4041
uint g_Booleans : packoffset(c16.x); \
4142
uint g_SwappedTexcoords : packoffset(c16.y); \
42-
float g_AlphaThreshold : packoffset(c16.z) \
43+
float2 g_HalfPixelOffset : packoffset(c16.z); \
44+
float g_AlphaThreshold : packoffset(c17.x);
4345

4446
uint g_SpecConstants();
4547

XenosRecomp/shader_recompiler.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,6 +1826,10 @@ void ShaderRecompiler::recompile(const uint8_t* shaderData, const std::string_vi
18261826
out += '}';
18271827
#endif
18281828
}
1829+
else
1830+
{
1831+
out += "\toPos.xy += g_HalfPixelOffset * oPos.w;\n";
1832+
}
18291833

18301834
if (simpleControlFlow)
18311835
{

0 commit comments

Comments
 (0)