0
\$\begingroup\$

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.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ Are you setting any lighting values to your model? \$\endgroup\$
    – r2d2rigo
    Feb 23, 2012 at 10:44
  • \$\begingroup\$ Yes, I have just swapped in this model in place of another model which works great. \$\endgroup\$
    – danbystrom
    Feb 23, 2012 at 10:52
  • 1
    \$\begingroup\$ 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"). \$\endgroup\$
    – bummzack
    Feb 23, 2012 at 12:19
  • \$\begingroup\$ The normals are there, I'm afraid. Thank's for the tip, though! \$\endgroup\$
    – danbystrom
    Feb 23, 2012 at 12:30

1 Answer 1

1
\$\begingroup\$

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)

\$\endgroup\$
4
  • \$\begingroup\$ 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 \$\endgroup\$
    – danbystrom
    Feb 23, 2012 at 14:48
  • \$\begingroup\$ @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? \$\endgroup\$
    – bummzack
    Feb 23, 2012 at 14:58
  • \$\begingroup\$ 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! \$\endgroup\$
    – danbystrom
    Feb 23, 2012 at 15:01
  • \$\begingroup\$ No. :-( It is saving out the diffuse map. \$\endgroup\$
    – danbystrom
    Feb 23, 2012 at 15:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .