Determine pixel-to-texel ratio for each sprite individually.

This fixes rendering artifacts when sprites are scaled > 1.
This commit is contained in:
Paul Chote
2024-10-29 21:50:47 +00:00
committed by Gustas
parent 42989c74aa
commit 09063d23da
4 changed files with 16 additions and 13 deletions

View File

@@ -253,9 +253,9 @@ namespace OpenRA.Graphics
shader.SetVec("DepthPreviewParams", contrast, offset);
}
public void SetAntialiasingPixelsPerTexel(float pxPerTx)
public void EnablePixelArtScaling(bool enabled)
{
shader.SetVec("AntialiasPixelsPerTexel", pxPerTx);
shader.SetBool("EnablePixelArtScaling", enabled);
}
}
}

View File

@@ -294,10 +294,10 @@ namespace OpenRA
(int)(-screenSprite.Bounds.Height / scale) / worldSprite.Size.Y,
1f);
SpriteRenderer.SetAntialiasingPixelsPerTexel(Window.SurfaceSize.Height * 1f / worldSprite.Bounds.Height);
SpriteRenderer.EnablePixelArtScaling(true);
RgbaSpriteRenderer.DrawSprite(worldSprite, float3.Zero, bufferScale);
Flush();
SpriteRenderer.SetAntialiasingPixelsPerTexel(0);
SpriteRenderer.EnablePixelArtScaling(false);
}
else
{
@@ -499,7 +499,7 @@ namespace OpenRA
throw new InvalidOperationException($"EndFrame called with renderType = {renderType}, expected RenderType.UI.");
Flush();
SpriteRenderer.SetAntialiasingPixelsPerTexel(Window.EffectiveWindowScale);
SpriteRenderer.EnablePixelArtScaling(true);
}
public void DisableAntialiasingFilter()
@@ -508,7 +508,7 @@ namespace OpenRA
throw new InvalidOperationException($"EndFrame called with renderType = {renderType}, expected RenderType.UI.");
Flush();
SpriteRenderer.SetAntialiasingPixelsPerTexel(0);
SpriteRenderer.EnablePixelArtScaling(false);
}
public void GrabWindowMouseFocus()