Sign in to follow this  

C# XNA Normals, Diffuse, and Specular for a Model?

This topic is 1920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm a beginner in XNA, trying my luck at a basic 3D game.

I have some very talented 3D modellers backing me, and while I have on issue importing the .fbx files (the models themselves) into my basic 3D universe in XNA, I have no idea how include the normal maps, diffuse, and specular that they've included with their models.

The normal, diffuse and specular are all in .tga image file format, and I don't know how I can add those to the drawing of my model.

Right now my code for drawing the 3D object is as follows:

[source lang="csharp"] private void DrawObject(Model spaceStation, Matrix world, Matrix view, Matrix projection)
{
foreach (ModelMesh mesh in spaceStation.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
effect.World = world;
effect.View = view;
effect.Projection = projection;
}
mesh.Draw();
}
}[/source]

Share this post


Link to post
Share on other sites
Two things need to happen:

1. You need an Effect that supports normal mapping. The default BasicEffect in XNA doesn't handle normal or specular maps, just diffuse.

2. You need to have those extra textures go through your content pipeline much like the diffuse texture. And set them to your effect when you're rendering your model.

I recall back when XNA 3.0 was released, the FBX importer was enhanced to allow for multiple textures. See this [url="http://blogs.msdn.com/b/shawnhar/archive/2008/09/18/fbx-improvements-in-xna-game-studio-3-0.aspx"]blog post[/url]. Also there is an [url="http://xbox.create.msdn.com/en-US/education/catalog/sample/normal_mapping"]official normal mapping tutorial[/url] from the app hub website that uses the process described in the blog post.

Share this post


Link to post
Share on other sites
[quote name='Starnick' timestamp='1350270618' post='4990226']
Two things need to happen:

1. You need an Effect that supports normal mapping. The default BasicEffect in XNA doesn't handle normal or specular maps, just diffuse.

[/quote]

How can I do just the diffuse then with the BasicEffect? All the tutorials for BasicEffect I've found only use Diffuse as a DiffuseColor Vector. I actually have an image map for it, which I can't find resources on how to use with BasicEffect.

Also, if I need an effect other than BasicEffect, where can I find resources for it?

I checked out the Normal Mapping example on MSDN, the one with the lizard. Looks mighty complicated. Edited by Sasstraliss

Share this post


Link to post
Share on other sites
Take a look at the MSDN documentation for[url="http://msdn.microsoft.com/en-us/library/microsoft.xna.framework.graphics.basiceffect_members.aspx"] BasicEffect[/url]. To enable diffuse textures, you need to set "TexturesEnabled" to true and set the diffuse map (should be a texture2d) to "Texture".

Share this post


Link to post
Share on other sites
Sign in to follow this