ATI SDK

ATI Product Information

Support for Alternate OS's

Hardware partners

Software partners

RenderMonkey

Drivers


 
 

Highlights


GPU MeshMapper (V1.0)

GPU PerfStudio (V1.2)

Samples: CrossFire Detect (update)

Samples: PostTonemapResolve

The Compressonator (version 1.41)

GPU Shader Analyzer (V1.42)

RenderMonkey™
(version 1.81) (New)


ATI Compress (version 1.6)

AMD Tootle 2.0 (New)

AMD OpenGL ES 2.0 Emulator (V1.1) (New)

HLSL2GLSL (V0.9)

AMD at GDC 2007

ATI SDK


 
 
ATI Developer - Source Code
 
Combine3 Specular Mapping With Dotproduct3 Bump mapping and 3D Lightmapping on the Radeon®

The RadeonCombine3SpecMap sample uses ATIX_texture_env_combine3, ATIX_texture_env_route, EXT_texture_env_dot3, ATI_texture_mirror_once, ARB_texture_cube_map, and EXT_texture3D to demonstrate per-pixel lighting effects possible in OpenGL®. It demonstrates Combine3 Specular Mapping, DOT3 Bumpmapping, and 3D Lightmapping. For more information on the DOT3 Bumpmapping and 3D Lightmapping techniques employed by this demo, see the Dotproduct3 Bump Mapping with 3D Lightmapping demo.

For more on 3D light mapping as well as 3D texturing in general, check out the Radeon® 3D Texture Mapping Tutorial.


Here is the basic idea behind this demo:
___________________________________
3 pass algorithm for performing realistic lighting.

PASS 1 : calculate attenuation via 3D light map
using ATI_texture_mirror_once extension.
PASS 2 : diffuse lighting with DOT3 bump mapping
(EXT_texture_env_dot3) and cube map normalization.
PASS 3 : specular lighting (using ATIX_texture_env_combine3
and ATIX_texture_env_route) and cube map normalization.

[(AMBIENT + (N.L)*BASE_MAP) + (N.H)k]*ATTENUATION

PASS 1 = ATTENUATION
PASS 2 = PASS1 * (AMBIENT + ((N.L)*BASE_MAP))
PASS 3 = PASS2 + PASS1*(N.H)16
Figure 1 shows the final result.

 
Figure 1 - Final Specular Map with Dot3 Bumps and 3D Lightmap
 
Pass 2 begins by taking the vector from each vertex to the light converting it into tangent space (the coordinate space of the base texture). We use a cube map for vector normalization with the light vector placed in the texture coordinates. These coordinates are used to reach into a pre-computed cube map in which each face of the cube contains a normalized vector pointing outward from the center of the cube. The results of these computations are shown in Figure 3. The dot product of this light vector and a pre-filtered height map (the normals in texture space, shown in Figure 4 as color) is computed using ATIX_texture_env_dot3 to produce the diffuse lighting term (N.L). Figure 5 shows the results of the DOT3.
 
Figure 2 - Result of 3D lightmapping
 
All of this is then modulated with the Basemap (Figure 6) and the results from pass 1 (attenuation term shown in Figure 1).

 
Figure 3 - Light Vector displayed as color
 
Figure 4 - Pre-filtered height map
 
Pass 3 begins by taking the vector from each vertex to the viewer converting it into tangent space (the coordinate space of the base texture) and calculating a halfway vector. We use a cube map for vector normalization with the halfway vector placed in the texture coordinates. These coordinates are then used to reach into a pre-computed cube map in which each face of the cube contains a normalized vector pointing outward from the center of the cube. The dot product is then found between the halfway vector and the normal vector (as stored in the height map Figure 4). We now have our specular term (N.H) and we raise it to the 16th power using an approximation ((N.H)2 - 0.75)*2.0); this is done with the help of ATIX_texture_env_combine3 and ATIX_texture_env_route. We now have our specular map (shown in Figure 7). This is then modulated with the results of pass 1 and then added to the results of pass 2. The final image is shown above (Figure 1).
 
Figure 5 - Results of DOT3 between light vector and heightmap
 
Figure 6 - Base Texture
Figure 7 - Specular Map
 
RadeonCombine3SpecMap Controls
  • M - Show stages of bump,lightmap and spec. map process
  • T - Cycle through the different textures
  • V - Toggle display of light per-vertex vectors
  • H - Toggle display of halfway per-vertex vectors
  • C - Toggle display of tangent space per-vertex coordinate systems
  • W - Toggle display of wireframe
  • [UP] - Move light further from object center
  • [DOWN] - Move light closer to object center
  • [LEFT MOUSE] + Mouse - Rotate Object
  • [RIGHT MOUSE] + Mouse - Rotate Light
  • [SPACE] - Stop light motion
  • [ESC] - Quit
 
Downloads
 
Note: The source code and media should be unzipped into the following recommended directory structure to ensure you can easily compile and run the executable.

Radeonxxxxxx.zip -> x:\atiddk\OpenGL

RadeonCombine3SpecMap.zip


Back to Samples Page

 
 
 


 



©2009 Advanced Micro Devices, Inc.  |  Contact AMD  |  Careers  |  RSS Feeds  |  Terms and Conditions  |  Privacy  |  Trademark information  |  Site Map