mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-12-14 12:09:36 +00:00
Scale quads after rendering to a screen texture instead of scaling directly. Fixes discontinuities in room editor and menu edges.
This commit is contained in:
@@ -17,28 +17,8 @@ float3 SamplePixel(int2 texCoord)
|
||||
|
||||
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
|
||||
{
|
||||
float dx = ddx(input.texCoord.x);
|
||||
float dy = ddy(input.texCoord.y);
|
||||
|
||||
float2 pixelTopLeftCoord = max(0.0, input.texCoord.xy - float2(dx, dy) * 0.5);
|
||||
float2 pixelBottomRightCoord = pixelTopLeftCoord + min(float2(1.0, 1.0), float2(dx, dy));
|
||||
|
||||
int2 topLeftCoordInteger = int2(floor(pixelTopLeftCoord));
|
||||
int2 bottomRightCoordInteger = int2(floor(pixelBottomRightCoord));
|
||||
|
||||
float2 interpolators = saturate((pixelBottomRightCoord - float2(bottomRightCoordInteger)) / float2(dx, dy));
|
||||
|
||||
float3 topLeftColor = SamplePixel(topLeftCoordInteger);
|
||||
float3 topRightColor = SamplePixel(int2(bottomRightCoordInteger.x, topLeftCoordInteger.y));
|
||||
float3 bottomLeftColor = SamplePixel(int2(topLeftCoordInteger.x, bottomRightCoordInteger.y));
|
||||
float3 bottomRightColor = SamplePixel(bottomRightCoordInteger);
|
||||
|
||||
float3 topColor = (1.0 - interpolators.x) * topLeftColor + interpolators.x * topRightColor;
|
||||
float3 bottomColor = (1.0 - interpolators.x) * bottomLeftColor + interpolators.x * bottomRightColor;
|
||||
float3 interpolatedColor = (1.0 - interpolators.y) * topColor + interpolators.y * bottomColor;
|
||||
|
||||
SDrawQuadPixelOutput result;
|
||||
result.color = float4(interpolatedColor, 1.0);
|
||||
result.color = float4(SamplePixel(int2(floor(input.texCoord.xy))), 1.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user