diff --git a/OpenRA.Game/Graphics/Sprite.cs b/OpenRA.Game/Graphics/Sprite.cs index 102fce3dd9..d3c57321a4 100644 --- a/OpenRA.Game/Graphics/Sprite.cs +++ b/OpenRA.Game/Graphics/Sprite.cs @@ -41,10 +41,15 @@ namespace OpenRA.Graphics FractionalOffset = Size.Z != 0 ? offset / Size : new float3(offset.X / Size.X, offset.Y / Size.Y, 0); - Left = (float)Math.Min(bounds.Left, bounds.Right) / sheet.Size.Width; - Top = (float)Math.Min(bounds.Top, bounds.Bottom) / sheet.Size.Height; - Right = (float)Math.Max(bounds.Left, bounds.Right) / sheet.Size.Width; - Bottom = (float)Math.Max(bounds.Top, bounds.Bottom) / sheet.Size.Height; + // Some GPUs suffer from precision issues when rendering into non 1:1 framebuffers that result + // in rendering a line of texels that sample outside the sprite rectangle. + // Insetting the texture coordinates by a small fraction of a pixel avoids this + // with negligible impact on the 1:1 rendering case. + var inset = 1 / 128f; + Left = (Math.Min(bounds.Left, bounds.Right) + inset) / sheet.Size.Width; + Top = (Math.Min(bounds.Top, bounds.Bottom) + inset) / sheet.Size.Height; + Right = (Math.Max(bounds.Left, bounds.Right) - inset) / sheet.Size.Width; + Bottom = (Math.Max(bounds.Top, bounds.Bottom) - inset) / sheet.Size.Height; } }