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:
@@ -348,11 +348,19 @@ public:
|
||||
|
||||
void AdjustRequestedResolution(uint32_t &physicalWidth, uint32_t &physicalHeight, uint32_t &virtualWidth, uint32_t &virtualHeight, float &pixelScaleX, float &pixelScaleY) override
|
||||
{
|
||||
if (physicalWidth < 640)
|
||||
physicalWidth = 640;
|
||||
|
||||
if (physicalHeight < 480)
|
||||
physicalHeight = 480;
|
||||
|
||||
double xMul = static_cast<double>(physicalWidth) / 640;
|
||||
double yMul = static_cast<double>(physicalHeight) / 480;
|
||||
|
||||
xMul = floor(xMul);
|
||||
yMul = floor(yMul);
|
||||
double granularity = 4.0;
|
||||
|
||||
xMul = floor(xMul * granularity) / granularity;
|
||||
yMul = floor(yMul * granularity) / granularity;
|
||||
|
||||
double minMul = std::max<double>(1.0, std::min(xMul, yMul));
|
||||
|
||||
|
@@ -1,8 +1,8 @@
|
||||
static unsigned char gs_shaderData[] = {
|
||||
68, 88, 66, 67, 96, 46, 192, 91, 73, 216, 92, 145, 77, 166, 215,
|
||||
215, 59, 255, 4, 67, 1, 0, 0, 0, 240, 2, 0, 0, 5, 0,
|
||||
68, 88, 66, 67, 231, 194, 75, 38, 6, 25, 110, 45, 187, 225, 136,
|
||||
211, 34, 239, 174, 118, 1, 0, 0, 0, 44, 6, 0, 0, 5, 0,
|
||||
0, 0, 52, 0, 0, 0, 224, 0, 0, 0, 56, 1, 0, 0, 108,
|
||||
1, 0, 0, 116, 2, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
1, 0, 0, 176, 5, 0, 0, 82, 68, 69, 70, 164, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 28, 0, 0,
|
||||
0, 0, 4, 255, 255, 0, 137, 0, 0, 122, 0, 0, 0, 92, 0,
|
||||
0, 0, 2, 0, 0, 0, 4, 0, 0, 0, 4, 0, 0, 0, 255,
|
||||
@@ -23,33 +23,88 @@ static unsigned char gs_shaderData[] = {
|
||||
78, 44, 0, 0, 0, 1, 0, 0, 0, 8, 0, 0, 0, 32, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0,
|
||||
0, 0, 0, 15, 0, 0, 0, 83, 86, 95, 84, 65, 82, 71, 69,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 0, 1, 0, 0, 64, 0, 0,
|
||||
0, 64, 0, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0,
|
||||
84, 0, 171, 171, 83, 72, 68, 82, 60, 4, 0, 0, 64, 0, 0,
|
||||
0, 15, 1, 0, 0, 88, 24, 0, 4, 0, 112, 16, 0, 0, 0,
|
||||
0, 0, 68, 68, 0, 0, 88, 16, 0, 4, 0, 112, 16, 0, 1,
|
||||
0, 0, 0, 85, 85, 0, 0, 98, 16, 0, 3, 50, 16, 16, 0,
|
||||
1, 0, 0, 0, 101, 0, 0, 3, 242, 32, 16, 0, 0, 0, 0,
|
||||
0, 104, 0, 0, 2, 1, 0, 0, 0, 27, 0, 0, 5, 50, 0,
|
||||
16, 0, 0, 0, 0, 0, 70, 16, 16, 0, 1, 0, 0, 0, 54,
|
||||
0, 0, 8, 194, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||
0, 104, 0, 0, 2, 5, 0, 0, 0, 11, 0, 0, 5, 18, 0,
|
||||
16, 0, 0, 0, 0, 0, 10, 16, 16, 0, 1, 0, 0, 0, 12,
|
||||
0, 0, 5, 34, 0, 16, 0, 0, 0, 0, 0, 26, 16, 16, 0,
|
||||
1, 0, 0, 0, 50, 0, 0, 13, 194, 0, 16, 0, 0, 0, 0,
|
||||
0, 6, 4, 16, 128, 65, 0, 0, 0, 0, 0, 0, 0, 2, 64,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 63, 0,
|
||||
0, 0, 63, 6, 20, 16, 0, 1, 0, 0, 0, 52, 0, 0, 10,
|
||||
194, 0, 16, 0, 0, 0, 0, 0, 166, 14, 16, 0, 0, 0, 0,
|
||||
0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 51, 0, 0, 10, 50, 0, 16, 0, 1,
|
||||
0, 0, 0, 70, 0, 16, 0, 0, 0, 0, 0, 2, 64, 0, 0,
|
||||
0, 0, 128, 63, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 7, 50, 0, 16, 0, 1, 0, 0, 0, 230, 10,
|
||||
16, 0, 0, 0, 0, 0, 70, 0, 16, 0, 1, 0, 0, 0, 65,
|
||||
0, 0, 5, 194, 0, 16, 0, 0, 0, 0, 0, 166, 14, 16, 0,
|
||||
0, 0, 0, 0, 27, 0, 0, 5, 50, 0, 16, 0, 2, 0, 0,
|
||||
0, 230, 10, 16, 0, 0, 0, 0, 0, 65, 0, 0, 5, 194, 0,
|
||||
16, 0, 0, 0, 0, 0, 6, 4, 16, 0, 1, 0, 0, 0, 0,
|
||||
0, 0, 8, 50, 0, 16, 0, 1, 0, 0, 0, 230, 10, 16, 128,
|
||||
65, 0, 0, 0, 0, 0, 0, 0, 70, 0, 16, 0, 1, 0, 0,
|
||||
0, 27, 0, 0, 5, 50, 0, 16, 0, 3, 0, 0, 0, 230, 10,
|
||||
16, 0, 0, 0, 0, 0, 14, 32, 0, 7, 50, 0, 16, 0, 0,
|
||||
0, 0, 0, 70, 0, 16, 0, 1, 0, 0, 0, 70, 0, 16, 0,
|
||||
0, 0, 0, 0, 54, 0, 0, 5, 66, 0, 16, 0, 2, 0, 0,
|
||||
0, 1, 64, 0, 0, 0, 0, 0, 0, 54, 0, 0, 5, 194, 0,
|
||||
16, 0, 3, 0, 0, 0, 86, 9, 16, 0, 2, 0, 0, 0, 45,
|
||||
0, 0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 15, 16, 0,
|
||||
3, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 45, 0, 0,
|
||||
7, 242, 0, 16, 0, 4, 0, 0, 0, 134, 15, 16, 0, 3, 0,
|
||||
0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 5, 130,
|
||||
0, 16, 0, 2, 0, 0, 0, 26, 0, 16, 0, 3, 0, 0, 0,
|
||||
45, 0, 0, 7, 242, 0, 16, 0, 3, 0, 0, 0, 198, 10, 16,
|
||||
0, 2, 0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 45, 0,
|
||||
0, 7, 242, 0, 16, 0, 2, 0, 0, 0, 70, 10, 16, 0, 2,
|
||||
0, 0, 0, 70, 126, 16, 0, 0, 0, 0, 0, 54, 0, 0, 8,
|
||||
226, 0, 16, 0, 1, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0,
|
||||
0, 7, 242, 0, 16, 0, 1, 0, 0, 0, 70, 14, 16, 0, 1,
|
||||
0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 56, 0, 0, 7,
|
||||
114, 0, 16, 0, 1, 0, 0, 0, 6, 0, 16, 0, 0, 0, 0,
|
||||
0, 70, 2, 16, 0, 1, 0, 0, 0, 54, 0, 0, 8, 226, 0,
|
||||
16, 0, 3, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0, 7,
|
||||
242, 0, 16, 0, 3, 0, 0, 0, 70, 14, 16, 0, 3, 0, 0,
|
||||
0, 70, 126, 16, 0, 1, 0, 0, 0, 0, 0, 0, 11, 194, 0,
|
||||
16, 0, 0, 0, 0, 0, 6, 4, 16, 128, 65, 0, 0, 0, 0,
|
||||
0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 128, 63, 0, 0, 128, 63, 50, 0, 0, 9, 114, 0, 16,
|
||||
0, 1, 0, 0, 0, 166, 10, 16, 0, 0, 0, 0, 0, 70, 2,
|
||||
16, 0, 3, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 56,
|
||||
0, 0, 7, 114, 0, 16, 0, 1, 0, 0, 0, 86, 5, 16, 0,
|
||||
0, 0, 0, 0, 70, 2, 16, 0, 1, 0, 0, 0, 54, 0, 0,
|
||||
8, 226, 0, 16, 0, 4, 0, 0, 0, 2, 64, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45,
|
||||
0, 0, 7, 242, 0, 16, 0, 3, 0, 0, 0, 70, 14, 16, 0,
|
||||
4, 0, 0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 56, 0, 0,
|
||||
7, 114, 0, 16, 0, 3, 0, 0, 0, 6, 0, 16, 0, 0, 0,
|
||||
0, 0, 70, 2, 16, 0, 3, 0, 0, 0, 54, 0, 0, 8, 226,
|
||||
0, 16, 0, 2, 0, 0, 0, 2, 64, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 45, 0, 0,
|
||||
7, 242, 0, 16, 0, 2, 0, 0, 0, 70, 14, 16, 0, 2, 0,
|
||||
0, 0, 70, 126, 16, 0, 1, 0, 0, 0, 50, 0, 0, 9, 114,
|
||||
0, 16, 0, 0, 0, 0, 0, 166, 10, 16, 0, 0, 0, 0, 0,
|
||||
70, 2, 16, 0, 2, 0, 0, 0, 70, 2, 16, 0, 3, 0, 0,
|
||||
0, 50, 0, 0, 9, 114, 32, 16, 0, 0, 0, 0, 0, 246, 15,
|
||||
16, 0, 0, 0, 0, 0, 70, 2, 16, 0, 0, 0, 0, 0, 70,
|
||||
2, 16, 0, 1, 0, 0, 0, 54, 0, 0, 5, 130, 32, 16, 0,
|
||||
0, 0, 0, 0, 1, 64, 0, 0, 0, 0, 128, 63, 62,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0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0,
|
||||
0, 0, 0, 0, 0,
|
||||
};
|
||||
|
||||
namespace GpBinarizedShaders
|
||||
|
@@ -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