2 Replies - 3859 Views - Last Post: 16 October 2012 - 09:04 AM

#1 Sasstraliss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-September 12

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

Posted 14 October 2012 - 07:20 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:

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;

Is This A Good Question/Topic? 0
  • +

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

#2 BBeck  Icon User is offline

  • Here to help.
  • member icon

Reputation: 779
  • View blog
  • Posts: 1,871
  • Joined: 24-April 12

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

Posted 15 October 2012 - 05:25 AM

Honestly, I don't know. The name of the texture file goes into the .fbx or .x file. Then you usually put it in the content folder with the model. I "think" the .fbx file can point to multiple texture files, but I'm not sure exactly how that would work. On the other hand, I kind of doubt that content manager or the model class know what to do with any of those map files (which are likely going to have to be in a picture file format that XNA can read). You may have to extend both the content manager and the model class. I'm about 99% certain that XNA doesn't know how to use normal, diffuse, specular, or hardly any other map type. I'm not even sure what a diffuse map is other than a standard texture (which of course XNA handles).

You can probably find some tutorials on bump mapping. I'm almost ready to study that myself, but I've got distracted trying to figure out how to handle a large number of omni-lights and their shadows. More than that, I'm trying to read a book on C# right now in order to do a book review of it. So, I keep getting further and further from learning how to use maps.

Anyway, I'm pretty certain that XNA can't handle map files out of the box. The built in shader can handle a dual layer multi-texture. I'm not sure if you could use that for bump mapping.

But I think bump mapping, paralax mapping, specular mapping, etc. requires High Level Shader Language. XNA supports HLSL, but you're likely to have write your own shader to handle those files.

I know there are some books for XNA that cover bump mapping. There's probably an internet tutorial on it somewhere. I would think that you would use a normal map for paralax mapping where you combine a height map and a normal map to do more "extensive" bump mapping. I've read some discussions on how to do it, but haven't done it myself. A lot of that wasn't for XNA though. It was HLSL, at best, and definitely didn't cover how to import them in with the model.

It's probably going to be a tough one figuring out how to get those into XNA. I'm guessing you'll have to extend XNA's capabilities a fair bit.

Oh. And if you find an answer on this one beyond what I've said, let me know. I would be interested in knowing the answer to this one.

This post has been edited by BBeck: 15 October 2012 - 05:30 AM

Was This Post Helpful? 0
  • +
  • -

#3 bonyjoe  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 178
  • View blog
  • Posts: 548
  • Joined: 08-September 10

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

Posted 16 October 2012 - 09:04 AM

You will have to start writing your own effect files as BBeck says. BasicEffect is as the name suggests, basic. You can apply your diffuse texture to the basic effect using the members Texture and TextureEnabled, however for specular and normal maps you will need to write your own shader to take advantage of them.

Normal maps can be used for simply retrieving a normal vector for each individual pixel rather than using interpolated values from the vertex shader, or you can go deeper and get into the realms of parallax and parallax occlusion mapping.

For starters I suggest going for something simple like this http://rbwhitaker.wi...lighting-shader and once you have figured that out you can read into specular and parallax maps. But don't get ahead of yourself as it can be a very complex subject.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1