views:

635

answers:

1

Hello. I'm using the standard .fbx importer with custom shaders in XNA. The .fbx model is UV wrapped properly and is textured appropriately when I use BasicEffect. However when I use my custom effect I have to load the texture in as a parameter, and it is not mapped correctly.

Questions: 1) How can I texture my .fbx model properly using the included texture's coordinates with custom effects? 2) Is there a way to access the texture from the loaded .fbx model object? Where does this texture go?

Note: I've studied custom content pipelines and don't believe writing my own Fbx importer/processor will be efficient. However if someone can descriptively supply me with firsthand experience of this being the answer than I will use the custom pipeline.

Thank you for your time and for reading this post.

A: 

The reason it's not working is because you have to set the effect's parameters manually instead of relying on the basiceffect (which would have had the shader parameters set in the content pipeline). Now, I'm not familiar with your shader so I couldn't prescribe code to solve your problem ...

To answer your second question, you can get around it in a roundabout sort of way. Because the model loads in the content pipeline with basiceffect by default, the texture is imported and assigned to the shader's parameters inside of the pipeline. So if you want to access it you'd have to look at the modelmeshpart's default effect property. Here is a forum post that describes this process.

The more correct answer would be a compromise between a full on custom importer and just using the default. You can make a custom modelprocessor that inherits from the existing one. In there, you can import your own custom effect, along with your custom textures and whatever parameters you need to set. and set it on the modelcontent. There was an article (either on Shawn Hargreave's blog, or on msdn) that showed how to do this, but I'm failing to find it at the moment unfortunately.

good luck!

Joel Martinez
Is this the process you would use to reproduce the effects from 3DS max in the FBX file?
Chris Ridenour
Yes it is ......
Joel Martinez