Hey all,
This one has me stumped and I hope someone else has come across the issue. Whenever I scale my sprite (my own quad, not the sprite interface), if I use a fairly "odd" number, the texture begins to bleed from the top or left side, depending on which way I'm scaling.
Here's a picture:
Top Scale: 2,2
Middle Scale: 2.15, 2
Bottom Scale: 2, 2.15
Here's a copy of the sprite sheet I'm using (I didn't add all these funky borders until I realized it was bleeding):
I'm using Matrix.Transformation2D() to manually transform the vertices.
Here's a basic snippet:
mat = DirectX.Matrix.Transformation2D(new DirectX.Vector2(renderInformation.Corners.Width / 2, renderInformation.Corners.Height / 2), 0, renderInformation.Scale, new DirectX.Vector2(renderInformation.Corners.Width / 2, renderInformation.Corners.Height / 2), 0f, new DirectX.Vector2(renderInformation.X, renderInformation.Y));
// Bottom Left Vertex For Example
vector.X = renderInformation.Corners.Left;
vector.Y = renderInformation.Corners.Bottom;
vector.TransformCoordinate(mat);
// Add this information to the VB
vbData[polygon].X = vector.X;
vbData[polygon].Y = vector.Y;
vbData[polygon].Tu = renderInformation.TexturePoints.Left;
vbData[polygon].Tv = renderInformation.TexturePoints.Bottom;
I'm 99% certain it's not related to my code (or atleast, this snippet) because the texture coordinates are calculated at the beginning when the animations are loaded. Here's that snippet if it's going to help:
_texture = VideoTask.Instance.GetTexture(texture);
using(Direct3D.Surface surface = _texture.GetTexture().GetSurfaceLevel(0))
{
_textureRect = new FloatRectangle((float)top / surface.Description.Height, (float)left / surface.Description.Width, (float)bottom / surface.Description.Height, (float)right / surface.Description.Width);
}
Any ideas? I'm completely baffled on this one. It almost seems like a floating point error but the texture coordinates aren't dependent on scale!