mirror of
https://github.com/elasota/Aerofoil.git
synced 2025-09-23 06:53:43 +00:00
Use Fant filter to resize to intermediate resolutions.
This commit is contained in:
@@ -9,14 +9,36 @@ struct SDrawQuadPixelOutput
|
||||
float4 color : SV_TARGET;
|
||||
};
|
||||
|
||||
float3 SamplePixel(int2 texCoord)
|
||||
{
|
||||
uint surfaceColor = surfaceTexture.Load(int3(texCoord, 0)).r;
|
||||
return paletteTexture.Load(int2(surfaceColor, 0)).rgb;
|
||||
}
|
||||
|
||||
SDrawQuadPixelOutput PSMain(SDrawQuadPixelInput input)
|
||||
{
|
||||
int2 texCoord = input.texCoord.xy;
|
||||
float dx = ddx(input.texCoord.x);
|
||||
float dy = ddy(input.texCoord.y);
|
||||
|
||||
uint surfaceColor = surfaceTexture.Load(int3(texCoord, 0)).r;
|
||||
float3 paletteColor = paletteTexture.Load(int2(surfaceColor, 0)).rgb;
|
||||
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(paletteColor.rgb, 1.0);
|
||||
result.color = float4(interpolatedColor, 1.0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Reference in New Issue
Block a user