|OpenGL 2.0 Shading Language Parallax Normal Mapping Demo.
This Windows demo implements tangent space parallax normal mapping using a series of OpenGL Shading Language (GLSL) shader programs. Separate parallax normal mapping shader programs are provided for each of the three OpenGL light types: directional, point, and spot lights.
This demo extends the OpenGL 2.0 Shading Language Normal Mapping demo by adding parallax mapping with offset limiting.
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".
1. This is an OpenGL 2.0 demo. This demo will not run on OpenGL 1.x hardware.
2. This demo requires the Visual C++ 2010 Library Runtimes. Download instructions can be found here.
Download executable, source, and Visual C++ 2010 solution files.
10 July 2010.
Added missing .vcxproj.filters file to the project.
13 June 2010.
Updated solution to Microsoft Visual Studio 2010.
1 April 2008.
gl_font.cpp: Fixed bug in drawTextEnd() method where the vertex buffer was not being unmapped when there's no text to draw. Thanks goes to Ari Ohvo for spotting this bug.
2 February 2008.
Updated solution to Microsoft Visual Studio 2008.
11 January 2008.
main.cpp: Renamed functions DrawCube() and DrawFrame() to RenderCube() and RenderFrame(). Added text rendering support. Added RenderText() function. Updated to use light radius based attenuation.
parallax_normal_mapping_point.glsl: Replaced attenuation calculations with one based on a light radius. Added a lightRadius uniform variable.
parallax_normal_mapping_spot.glsl: Replaced attenuation calculations with one based on a light radius. Added a lightRadius uniform variable.
5 November 2007.
main.cpp: Updated the tangent member of the Vertex structure to include a 'w' component that stores the handedness of the local tangent space coordinate system at that vertex. The CalcTangentVector() function has been updated to calculate the handedness.
All of the shaders have been updated to use the handedness stored in the tangent vertex attribute.
Please note that these shaders have been written to use normal maps with the y-axis oriented bottom to top (as per OpenGL conventions). When generating normal maps for use with these shaders please ensure that you invert the y-axis before generating the normal maps in your content creation applications.
23 October 2007.
main.cpp: Fixed a bug in CalcTangentVector() where the inverse of the determinant should have been used to calculate the tangent vector instead of the determinant.
21 October 2007.
This is a major rewrite of the OpenGL 2.0 Shading Language Parallax Bump Mapping demo. The demo has now been renamed to OpenGL 2.0 Shading Language Parallax Normal Mapping demo to more accurately describe the shader technique that it implements. This new demo contains many critical bug fixes.
main.cpp: The cube model no longer contains a bitangent vertex attribute. The bitangent is now calculated in the vertex shader. Only the tangent vector is calculated and stored in the cube now. The demo is now Vista friendly.
Fixed a bug in all three shaders where the tbnMatrix rotation matrix was being incorrectly calculated. This was causing the parallax normal mapped surface to be incorrectly lit.
24 August 2007.
main.cpp: Changed the default value of g_parallaxHeightBias from -0.02f to -0.03f. This reduces the amount of visible artifacts. Refactored the WinMain() function's main message loop.
Updated all three shaders to include the #version 110 directive. Updated the conditional logic in all three fragment shaders to address an issue with recent AMD ATI Catalyst drivers. The GLSL implementation on AMD ATI Catalyst 7.8 drivers seems to require the if test to explicitly check against a boolean literal. The same behavior does not appear to manifest itself on NVIDIA hardware.
4 January 2007.
Fixed a bug in all three shaders where the parallax corrected texture coordinates were being incorrectly calculated. The decal texture map lookup was also using the original texture coordinates passed into the fragment shader rather than the parallax corrected texture coordinates. These fixes now make each stone brick stick out even further from the wall thereby considerably enhancing the parallax effect.
The included executable is now built using Visual C++ 2005 with Visual Studio 2005 Service Pack 1 applied.
8 December 2006.
main.cpp: Changed the clear color to CornflowerBlue.