Implement optimized pixel-art antialiasing mode for non-integer world zoom.
This commit is contained in:
@@ -172,5 +172,10 @@ namespace OpenRA.Graphics
|
||||
{
|
||||
shader.SetBool("EnableDepthPreview", enabled);
|
||||
}
|
||||
|
||||
public void SetAntialiasingPixelsPerTexel(float pxPerTx)
|
||||
{
|
||||
shader.SetVec("AntialiasPixelsPerTexel", pxPerTx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,6 +181,9 @@ namespace OpenRA
|
||||
|
||||
// Render the world into a framebuffer at 1:1 scaling to allow the depth buffer to match the artwork at all zoom levels
|
||||
worldBuffer = Context.CreateFrameBuffer(worldBufferSize);
|
||||
|
||||
// Pixel art scaling mode is a customized bilinear sampling
|
||||
worldBuffer.Texture.ScaleFilter = TextureScaleFilter.Linear;
|
||||
}
|
||||
|
||||
if (worldSprite == null || worldViewport.Size != worldSprite.Bounds.Size)
|
||||
@@ -217,8 +220,11 @@ namespace OpenRA
|
||||
|
||||
var scale = Window.WindowScale;
|
||||
var bufferSize = new Size((int)(screenSprite.Bounds.Width / scale), (int)(-screenSprite.Bounds.Height / scale));
|
||||
|
||||
SpriteRenderer.SetAntialiasingPixelsPerTexel(Window.SurfaceSize.Height * 1f / worldSprite.Bounds.Height);
|
||||
RgbaSpriteRenderer.DrawSprite(worldSprite, float3.Zero, new float2(bufferSize));
|
||||
Flush();
|
||||
SpriteRenderer.SetAntialiasingPixelsPerTexel(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user