Use SV_POSITION instead to compute pixel coordinates instead of fiddling with the polygon. This should fix the image being offset by 1 pixel.

This commit is contained in:
elasota
2020-11-12 19:15:50 -05:00
parent 2c073937c3
commit 801408077a
4 changed files with 95 additions and 91 deletions

View File

@@ -5,7 +5,7 @@ Texture2D<float3> surfaceTexture : register(t0);
cbuffer SScaleQuadPixelConstants : register(b0)
{
float4 dxdy_Unused;
float4 dxdy_InvPixelScale;
};
struct SDrawQuadPixelOutput
@@ -20,10 +20,10 @@ float3 SamplePixel(int2 coord)
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
{
float dx = dxdy_Unused.x;
float dy = dxdy_Unused.y;
float dx = dxdy_InvPixelScale.x;
float dy = dxdy_InvPixelScale.y;
float2 pixelTopLeftCoord = max(0.0, input.texCoord.xy - float2(dx, dy) * 0.5);
float2 pixelTopLeftCoord = max(0.0, (input.pos.xy - float2(0.5, 0.5)) * dxdy_InvPixelScale.zw);
float2 pixelBottomRightCoord = pixelTopLeftCoord + min(float2(1.0, 1.0), float2(dx, dy));
int2 topLeftCoordInteger = int2(floor(pixelTopLeftCoord));