Determine pixel-to-texel ratio for each sprite individually.
This fixes rendering artifacts when sprites are scaled > 1.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user