I found a very odd glitch with my game this morning. XNA doesn't render certain textured models properly, while other models are completely unaffected. And it's not even like my models are made incorrectly - even one of my spheres doesn't render properly at certain zoom levels. Agh, it's hard to explain, here's a picture:
The arrow on the left is in blender. The right two pictures are from within my game. At first, I thought that this was some sort of bleeding / collision issue of the arrow and the space-y background. But when I removed the background, the issue was still there.
So what are all those weird pink dots and seams? This is what my texture looks like:
Oddly enough, all of the other models in my game render correctly, except for the space sphere you see behind the arrow. (It only looks incorrect at other zoom levels, although no pink dots, just more black seams)
So I tried to find a similarity between the two malfunctioning objects, the arrow and the sphere. It occurred to me that they were the only objects whose textures did not cover the entire model, but instead were tiled. So like the UV unwrapping was not totally contained in the texture... here's a picture of what the UV looks like in blender:
Based off of this, I concluded that somehow XNA is not tiling the texture properly when it maps it to the objects. Since blender renders the model correctly and XNA doesn't, I'm assuming the problem is with XNA. (although correct me if I'm wrong)
So finally, my question is: I'm totally lost - does anybody know how to fix this?
Thanks!
EDIT: As requested in comments, here is my drawing code. It's nothing special, just your basic model draw code.
class OrderedDrawModel
{
Model M;
Matrix Transform;
float Transparency;
Vector3 Ambience;
public float Distance;
float Reflect;
public OrderedDrawModel(Model M, float Transparency, Vector3 Ambience, Matrix Transform, float Distance, float Reflectivity)
{
this.M = M;
this.Transparency = Transparency;
this.Ambience = Ambience;
this.Distance = Distance;
this.Transform = Transform;
Reflect = Reflectivity;
}
public void Draw(GraphicsDeviceManager graphics, Camera_Edit C)
{
Matrix[] T = new Matrix[M.Bones.Count];
M.CopyAbsoluteBoneTransformsTo(T);
foreach (ModelMesh mesh in M.Meshes)
{
foreach (BasicEffect basicEffect in mesh.Effects)
{
basicEffect.World = T[mesh.ParentBone.Index] * Transform;
basicEffect.View = C.view;
basicEffect.Projection = C.projection;
basicEffect.LightingEnabled = true;
basicEffect.AmbientLightColor = Ambience;
basicEffect.DirectionalLight0.DiffuseColor = Color.White.ToVector3();
basicEffect.DirectionalLight0.Direction = Vector3.Normalize(new Vector3(-3, -3, 1));
basicEffect.DirectionalLight0.SpecularColor = new Vector3(Reflect, Reflect, Reflect);
graphics.GraphicsDevice.BlendState = BlendState.AlphaBlend;
basicEffect.Alpha = Transparency;
}
mesh.Draw();
}
}
}
I create the object with this line:
DrawModel(Arrow, 1.0f, Matrix.CreateScale(5f), new Vector3(0, 0, 0), 0.4f);
//Model alpha transform_matrix ambience specular
Which adds it to a list of back-to-front ordered models that get drawn by calling their draw method.