我有一张 512x512 的图像,需要平铺作为背景。
我通过SamplerState.LinearWrap
在图像上设置和设置更大的源矩形来做到这一点。
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearWrap, DepthStencilState.Default, RasterizerState.CullNone);
spriteBatch.Draw(texture, bounds, bounds, Color.White);
spriteBatch.End();
bounds
是new Rectangle(0, 0, 1024, 768)
现在它看起来像这样:
这些线是平铺图像的位置。原始 png 的边缘没有任何线条(我放大并在 Photoshop 中检查了它)。
这是怎么回事? 这是 DropBox 上的示例项目。
我尝试使用非二次幂纹理,但它在SamplerState
.