Blender to XNA: Skinned Model Renders Black
#1 Members - Reputation: 167
Posted 13 September 2012 - 11:54 PM
I am trying to import a skinned model into the Skinned Sample from Microsoft. The model was built in Blender 2.63a with an animation, a material, and a texture. The model renders perfectly with Blender, but once exported, the model loses all reference to the texture. The model renders black in XNA, and VS doesn't complain about the missing texture in the folder. Anyone know why Blender is not exporting the texture or at least a reference to it? I tried recreating the material and the texture, but to no avail.
#2 Members - Reputation: 1671
Posted 14 September 2012 - 08:06 AM
Also, does VS give you any warnings about the loaded assets?
if you put the associated texture into the <Projectname>Content folder of your project, do you get a warning that it's being compiled twice?
#3 Members - Reputation: 167
Posted 14 September 2012 - 09:20 AM
Edited by Drakken255, 14 September 2012 - 09:22 AM.
#4 Members - Reputation: 623
Posted 14 September 2012 - 09:27 AM
Usually the compiler would give an error in the model processing phase of the build when it looks for a texture that is not found. Otherwise, the content processor you're using has a way to handle missing textures and just puts a default one in its place.
Coincidentally, I was fixing up a third-party model I exported from Blender yesterday in trying to get its textures to load too. I didn't export the animations but it was an .fbx format. When done incorrectly, exporting as .fbx would cause the model's texture to have "untitled" in its file path, so you will end up with nothing. You need to check the image list in the UV image editor. Select your mesh, go into Edit Mode and press A to highlight all the vertices. In the UV editor window, choose the image you want to associate the mesh with. Then save the file and export.
There's a chance you also have some unused image datablocks named "untitled" possibly followed with a number, which you will see in the list of images in the UV editor. Shift-click to unlink and remove these, save, and re-open the blend file. It was kind of tricky trying to figure this out myself, I was also struggling for hours figuring out why the model's texture wasn't showing.
Edit: Yep, I checked my original model again and you will get references to "untitled" in the exported file (search for this string in the file with quotes included). You gotta remove any references to those image files as I've mentioned before.
Edited by CC Ricers, 14 September 2012 - 09:59 AM.
#5 Members - Reputation: 167
Posted 14 September 2012 - 10:10 AM
EDIT: I saved, closed, reopened, and exported and now there is a reference to textures... And it does point to the correct file... I don't just get it... Lemme provide a link to the fbx and blend files:
https://dl.dropbox.com/u/10337688/SteveIdle01.blend
https://dl.dropbox.com/u/10337688/SteveIdle01.fbx
Edited by Drakken255, 14 September 2012 - 10:24 AM.
#6 Members - Reputation: 623
Posted 14 September 2012 - 11:47 AM
#8 Members - Reputation: 623
Posted 14 September 2012 - 01:24 PM
#11 Members - Reputation: 167
Posted 15 September 2012 - 12:10 PM
Edited by Drakken255, 15 September 2012 - 12:14 PM.
#13 Members - Reputation: 415
Posted 17 September 2012 - 11:17 AM
- Add a breakpoint during the render of your model, check that the texture is actually loaded in the first place.
- Make sure when you export your FBX file through blender that you tick the option: XNA Strict Options
- As your model is skinned, make sure that the textures are placed where XNA expects them, you can check this by opening up the fbx file and looking for the texture references.
- Make sure (and I know this is obvious but it's worth checking) that you have UV mapped your mesh and not just applied a texture material, because generated UV's don't automatically export.
- If none of the above fix the issue, then it's possible there is something wrong with the rendering code you are using, if you are using a custom shader to display
the model, let us see what you have so that we can better help. If you have your own lighting system, perhaps the model is simply not being lit.
Aimee
#14 Members - Reputation: 167
Posted 17 September 2012 - 04:23 PM
1: I may be using custom code, but even using the Skinned Sample by MS with no changes other than the model and animation name strings, it stays black.
2: I am always sure to correctly export the model.
3: My texture is placed in the right spot and when it isn't, VS complains like it is supposed to.
4: Wait... Blender doesn't export my UV map? I did make my own... This sounds like a part of the problem, but I don't know...
5: Similar to 1.
EDIT: My models did work ok with Blender 2.6, whereas now I am using 2.63a. Is this an issue?
Edited by Drakken255, 17 September 2012 - 04:28 PM.
#15 Members - Reputation: 623
Posted 18 September 2012 - 10:17 AM
Things that you may want to keep in mind: The SkinnedModelProcessor is not where the problem is. Something seems to be up with the way Blender prepares textures in your model upon export.
I opened your Blend file, scrapped the extra textures, and just exported the Steve mesh with one texture. In XNA he appears tiny (probably just the size the model was made) and indeed appears black. Then it hit me... Did you choose to pre-multiply Alpha in your texture processor? My guess it's set to True by default in the Skinned sample. Try turning it off. Had the same problem when I dug up an SSAO shader I made many months ago and for some reason the randomized normals texture was rendering in black making the AO look weird. The alpha channel of the texture was black, so I had to disable pre-multiply alpha to get it working again.
Edited by CC Ricers, 18 September 2012 - 10:21 AM.
#17 Members - Reputation: 623
Posted 18 September 2012 - 08:08 PM
With this window open, click on the little arrow or plus sign next to Content Processor and then you should see an option called "Premultiply Texture Alpha". Set it to false.
#18 Members - Reputation: 167
Posted 18 September 2012 - 09:59 PM
EDIT: Setting the pre-multiply alpha setting on either the model or the texture didn't work...
Not even removing all transparency options in Blender works...
Edited by Drakken255, 19 September 2012 - 04:49 AM.
#19 Members - Reputation: 415
Posted 20 September 2012 - 11:03 PM
After that I exported as I mentioned, and it works fine, to prove it here is a screenie of your model running in our engine Phobius (this is an XNA engine):

The issue is entirely down to making sure that your model is properly UV mapped, so try have another pop. If you still have problems PM me and I'll send you the modified blend file so you can see what I did.
Aimee.






