Implement optimized pixel-art antialiasing mode for non-integer world zoom.

This commit is contained in:
Paul Chote
2019-11-24 15:27:51 +00:00
committed by tovl
parent cd368b43df
commit 860117daf9
3 changed files with 47 additions and 1 deletions

View File

@@ -172,5 +172,10 @@ namespace OpenRA.Graphics
{
shader.SetBool("EnableDepthPreview", enabled);
}
public void SetAntialiasingPixelsPerTexel(float pxPerTx)
{
shader.SetVec("AntialiasPixelsPerTexel", pxPerTx);
}
}
}

View File

@@ -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
{