mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2025-04-28 13:27:58 +03:00
Apply half pixel offset in the vertex shader. (#1391)
This commit is contained in:
parent
7866765ab0
commit
41fd1761b1
5 changed files with 12 additions and 5 deletions
|
@ -43,7 +43,7 @@ void main(
|
||||||
out float4 oColor0 : COLOR0,
|
out float4 oColor0 : COLOR0,
|
||||||
out float4 oColor1 : COLOR1)
|
out float4 oColor1 : COLOR1)
|
||||||
{
|
{
|
||||||
oPos.xy = (iPosition0.xy - 0.5) * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
|
oPos.xy = iPosition0.xy * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
|
||||||
oPos.z = g_Z.x;
|
oPos.z = g_Z.x;
|
||||||
oPos.w = 1.0;
|
oPos.w = 1.0;
|
||||||
oTexCoord0 = iColor0.wxyz;
|
oTexCoord0 = iColor0.wxyz;
|
||||||
|
|
|
@ -44,7 +44,7 @@ void main(
|
||||||
out float4 oColor0 : COLOR0,
|
out float4 oColor0 : COLOR0,
|
||||||
out float4 oColor1 : COLOR1)
|
out float4 oColor1 : COLOR1)
|
||||||
{
|
{
|
||||||
oPos.xy = (iPosition0.xy - 0.5) * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
|
oPos.xy = iPosition0.xy * g_ViewportSize.zw * float2(2.0, -2.0) + float2(-1.0, 1.0);
|
||||||
oPos.z = g_Z.x;
|
oPos.z = g_Z.x;
|
||||||
oPos.w = 1.0;
|
oPos.w = 1.0;
|
||||||
oTexCoord0 = iColor0.wxyz;
|
oTexCoord0 = iColor0.wxyz;
|
||||||
|
|
|
@ -4,6 +4,7 @@ Interpolators main(in VertexShaderInput In)
|
||||||
{
|
{
|
||||||
Interpolators Out;
|
Interpolators Out;
|
||||||
Out.ProjPos = In.ObjPos;
|
Out.ProjPos = In.ObjPos;
|
||||||
|
Out.ProjPos.xy += g_HalfPixelOffset * Out.ProjPos.w;
|
||||||
Out.UV = In.UV;
|
Out.UV = In.UV;
|
||||||
return Out;
|
return Out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,6 +163,8 @@ struct SharedConstants
|
||||||
uint32_t samplerIndices[16]{};
|
uint32_t samplerIndices[16]{};
|
||||||
uint32_t booleans{};
|
uint32_t booleans{};
|
||||||
uint32_t swappedTexcoords{};
|
uint32_t swappedTexcoords{};
|
||||||
|
float halfPixelOffsetX{};
|
||||||
|
float halfPixelOffsetY{};
|
||||||
float alphaThreshold{};
|
float alphaThreshold{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3089,8 +3091,6 @@ static void FlushViewport()
|
||||||
if (g_dirtyStates.viewport)
|
if (g_dirtyStates.viewport)
|
||||||
{
|
{
|
||||||
auto viewport = g_viewport;
|
auto viewport = g_viewport;
|
||||||
viewport.x += 0.5f;
|
|
||||||
viewport.y += 0.5f;
|
|
||||||
|
|
||||||
if (viewport.minDepth > viewport.maxDepth)
|
if (viewport.minDepth > viewport.maxDepth)
|
||||||
std::swap(viewport.minDepth, viewport.maxDepth);
|
std::swap(viewport.minDepth, viewport.maxDepth);
|
||||||
|
@ -3514,6 +3514,12 @@ static void SetFramebuffer(GuestSurface* renderTarget, GuestSurface* depthStenci
|
||||||
g_framebuffer = nullptr;
|
g_framebuffer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (g_framebuffer != nullptr)
|
||||||
|
{
|
||||||
|
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.halfPixelOffsetX, 1.0f / float(g_framebuffer->getWidth()));
|
||||||
|
SetDirtyValue(g_dirtyStates.sharedConstants, g_sharedConstants.halfPixelOffsetY, -1.0f / float(g_framebuffer->getHeight()));
|
||||||
|
}
|
||||||
|
|
||||||
g_dirtyStates.renderTargetAndDepthStencil = settingForClear;
|
g_dirtyStates.renderTargetAndDepthStencil = settingForClear;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 855a5a8c51ea5f84baecbf4fc87c182795d482c9
|
Subproject commit 4897cf7ef2070120310c28a1a672b427d745dad8
|
Loading…
Add table
Add a link
Reference in a new issue