Jump to content

  • Log In with Google      Sign In   
  • Create Account


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


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Sasstraliss   Members   -  Reputation: 105

Like
0Likes
Like

Posted 14 October 2012 - 08:22 PM

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]

Sponsor:

#2 Starnick   Members   -  Reputation: 1176

Like
0Likes
Like

Posted 14 October 2012 - 09:10 PM

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 blog post. Also there is an official normal mapping tutorial from the app hub website that uses the process described in the blog post.

#3 Sasstraliss   Members   -  Reputation: 105

Like
0Likes
Like

Posted 14 October 2012 - 10:06 PM

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.


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, 14 October 2012 - 10:23 PM.


#4 Starnick   Members   -  Reputation: 1176

Like
0Likes
Like

Posted 15 October 2012 - 06:17 AM

Take a look at the MSDN documentation for BasicEffect. To enable diffuse textures, you need to set "TexturesEnabled" to true and set the diffuse map (should be a texture2d) to "Texture".




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS