|XNA 4.0 Parallax Normal Mapping Demo.
This Windows XNA application demonstrates tangent space parallax normal mapping. An effect (.fx) file is provided that implements tangent space parallax normal mapping using a series of HLSL shaders. The lighting models implemented are: directional lighting, point lighting, and spotlight lighting.
Parallax mapping is a method for approximating the correct appearance of uneven surfaces by modifying the texture coordinate for each pixel. Normal mapping is commonly used to provide surfaces with very detailed shading without requiring additional geometry to be added to the polygonal model. However such normal mapped surfaces often still appear flat. Parallax mapping corrects this by providing the illusion of depth to such surfaces. Parallax mapping is commonly used in conjunction with normal mapping because parallax mapping is a relatively inexpensive means to enhance the normal mapping effect.
The original idea for parallax mapping came from a paper by Tomomichi Kaneko et al (2001) titled "Detailed Shape Representation with Parallax Mapping". Later Terry Welsh (2004) introduced an offset limiting term to the original parallax mapping technique in his paper titled "Parallax Mapping with Offset Limiting: A Per Pixel Approximation of Uneven Surfaces".
To learn more about normal mapping in XNA check out the XNA 4.0 Normal Mapping Demo.
1. This demo requires shader model 2.0 or higher support.
2. This demo is provided in source form only. No pre built binaries are supplied.
Download source, assets, and XNA Game Studio 4.0 solution files.
15 January 2011.
Initial release of demo for XNA Game Studio 4.0. The previous XNA Game Studio 3.0 version of the demo is no longer supported and is now only available upon request.
16 November 2008.
Initial release of demo for XNA Game Studio 3.0. The previous XNA Game Studio 2.0 version of the demo is no longer supported and is now only available upon request.
27 January 2008.
Initial release of demo for XNA Game Studio 2.0. The original XNA Game Studio Express 1.0 Refresh version of the demo is no longer supported and is now only available upon request.
4 January 2008.
Demo.cs: Removed attenuation field from the Light structure. Added light radius field to the Light structure. Added camera setting constants: CAMERA_FOVY, CAMERA_ZNEAR, CAMERA_ZFAR. Added constants for the cube: CUBE_DOLLY_MIN, CUBE_DOLLY_MAX, CUBE_SIZE, CUBE_SPEED_DOLLYING, CUBE_SPEED_ROTATING, CUBE_SPEED_TRACKING. Added constant for the light radius. Added a field for the cube position. Added a field to store cube x and y axis rotations. Added fields to support a simple frame rate counter. Changed ProcessMouse() method to manipulate the cube instead of the camera. Added ToggleFullScreen() method. The UpdateEffect() method now includes a translation transformation for the world matrix. Added a simple frame rate counter. Implementation is in the UpdateFrameRate() method. This method is called once per frame in the Draw() method.
parallax_normal_mapping.fx: Switched to a new light attenuation method based on a light radius. Added light attenuation comments. Changed vector outputs from the vertex shaders to float3. Fixed bug in vertex shaders where the worldInverseTransposeMatrix was not being cast to a float3x3. Updated the pixel shaders to use the float3 vector outputs from the vertex shaders.
8 November 2007.
Program.cs: Removed file. Contents have been merged into the Demo.cs file.
Demo.cs: Added Light and Material structures. Refactored existing light and material fields into these structures. These structures match the ones in the effect file (normal_mapping.fx). Rewrote the keyboard and mouse processing methods.
NormalMappingUtils.cs: Replaced the NormalMappedVertex.CalcTangentSpaceVectors() method with the NormalMappedVertex.CalcTangent() method. Removed the bitangent field from the NormalMappedVertex structure. Removed the debugging methods in the NormalMappedCube class that draws the tangent space basis vectors.
parallax_normal_mapping.fx: Fixed a bug in the vertex shaders where the tbnMatrix was being incorrectly calculated. The vertex shaders now calculate the bitangent vectors. The vertex shaders now use the handedness stored in the tangent vectors when calculating the bitangent vectors. Removed the no texturing techniques. Added techniques for parallax normal mapping and normal mapping.
28 April 2007.
Demo.cs: Now uses the XNA default clockwise triangle winding order.
NormalMappingUtils.cs: Updated the NormalMappedCube class to use XNA's default clockwise triangle winding order. Changed the namespace to Dhpoware.
24 January 2007.
Updated solution so that Content is no longer copied to the output directory.
NormalMappingUtils.cs: Moved NormalMappedCube.CalcTangentSpaceVectors() method to NormalMappedVertex structure. Updated CalcTangentSpaceVectors() method to check if the texture has been mapped backwards onto the triangle.