# Texture in model not rendered by BasicEffect

UPDATE: It is apparently the BasicEffect that is the culprit here. I tried to use another effect (which I coded myself) and then it works!?!? )I kinda like the EnableDefaultLighting, though...)

So this question is now rephrased to: "what in the model exported by Blender can cause BasicEffect to fail to render the texture?".

I have imported this model into Blender and exported it to an .fbx file and imported it into my XNA project. The problem is that the model is pitch black (just as it is in Blender when I look at it in object mode) when drawn in XNA. I have verified that the texture really is there (and that only one iteration is made):

       foreach (var mesh in _model.Meshes)
foreach (var part in mesh.MeshParts)
if (part.Effect is BasicEffect)
{
var be = part.Effect as BasicEffect;
using ( var stream = File.Create(@"c:\test.jpg") )
be.Texture.SaveAsJpeg(stream,2048,2048);
}


I have followed exactly the same procedure with other models and it has worked. Since the model looks good in Blender and the textures really makes it into XNA... what can be wrong here?

For what it's worth: one difference from what I'm used to is that these textures are not stored inside the .fbx but in a separate subfolder, but the XNA content importer finds them (I get an error if I try to remove them).

UPDATE: it may be important to mention that this model actually has three textures: diffuse, specular and normal maps. However, ONE of them should be projected by the BasicEffect, right?

UPDATE: a screen shot from Blender.

• Are you setting any lighting values to your model? Feb 23 '12 at 10:44
• Yes, I have just swapped in this model in place of another model which works great. Feb 23 '12 at 10:52
• Did you check the normals in blender? (While in edit-mode press N to bring up the transform-panel, scroll down to "Normals" and enable "Face" normals. That way you'll see if normals point in the right direction. Otherwise you might want to do a "Recalculate normals"). Feb 23 '12 at 12:19
• The normals are there, I'm afraid. Thank's for the tip, though! Feb 23 '12 at 12:30

I would guess that the problems is with the UV mapping.

Is your texture mapping in blender set to UV with the correct map?

When blender export FBX it uses the txt version of FBX (not the binary one). Try to open open the FBX file in a text editor to see if something looks wierd (if the UVs or Normals are all zeros)

• Nothing strikes me as odd... wouldn't notice if something is missing - but no large amounts of repeated zeros. I have uploaded a screen shot from Blender. Note that in object mode the model is pitch black. That may be a clue? :s Feb 23 '12 at 14:48
• @danbystrom I just opened that model in Blender. It's black, beacuse the "diffuse" color of the material is set to black. So most likely your textures aren't being imported and the model just shows with its default diffuse color? Feb 23 '12 at 14:58
• Well... as I wrote - the effect is clearly "seeing" a texture of size 2048x2048 - which is correct... I'll have to copy it out and look if it is black or not! Thanks! Feb 23 '12 at 15:01
• No. :-( It is saving out the diffuse map. Feb 23 '12 at 15:16