Saturday, February 16, 2013

XNA Normal Mapping and Lighting

02/16/2013

After a long struggle with trying to get normal mapping and lighting shaders to work in our game I finally got it working where I can show off the results.

I set it up so that our artists will be able to select which shader each model will be drawn with.

For transparency I used our artists transparent shader. For Normal Mapping I setup a Normal Mapping Pipeline similar to the one shown off in the Xbox Live Indie Games Code Samples. One of the problems I was running into was caused by the ASCII FBX exports from Maya. For each model that we wanted normal mapping for I would have to go in and find the section for each model and add a normal map tag, for example:

P: "NormalMap", "Enum", "", "A+U",0, "../SourceImages/Brick3_normal.png"

I would then have to find all other references to the NormalMap and remove them. Once I did this the normal mapping would be displayed. With the normal mapping we have the following variables we can configure; light position, light color, ambient light color, shininess, specular power.

Below are examples of the shaders...

Transparent lamp next to the rectangle:


Normal Mapping on different models:





Example of the same barrel model with Normal Mapping on or off:


Video examples of the Normal Mapping:



Testing lighting so that it looks like the light on the two arches is coming from the lamp between them:

No comments:

Post a Comment