My Account


RSS
oZone3D.Net RSS Feeds»RSS 2.0 Feeds

Blogs
»Demoniak3D Blog
»JeGX's Infamous Lab

Sponsors

Modul8: real time video mixing and compositing


Link to Us

oZone3D.Net 100% Realtime 3D

»All Links

Web Partners

www.geeks3d.com
www.benchmarkhq.ru
www.tdt3d.com
www.steph3d.net
www.g-truc.net
www.worldpcspecs.com


Banners Exchange

www.jmax-hardware.com
cgindia.blogspot.com
grapejuice.c.la
www.game-lab.com


Links Exchange

»CYGAD's 3DXtra

Search
Google
Web
oZone3D.Net
 
Normal Map Compression
Renormalization
Swizzled DXT5 - ATI 3Dc

By Jerome Guinot aka 'JeGX' - jegx [at] ozone3d (dot) net

Initial draft: March 11, 2006
Update: March 16, 2006


[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Conclusion

»Next Page



3 - Generation of the Z component or Swizzled DXT5

We will now use another technique, based on the one used in the game Doom 3. This technique uses two particularities of the DXT5 compression format.

The first particularity is that the alpha canal is compressed except for the three others red, green and bleu. This means that the value contained in the alpha canal is not changed too much during the compression.

The second particularity is that the 3 canals RGB (Red Green Blue) are stocked on 16 bits in the following format: 5_6_5, that is to say 5 bits for the red canal, 6 bits for the green one and finally 5 bits for the blue one. The result is that the green canal is more precise than the other two.

But how will we exploit these 2 particularities? By simply using the base relation of a normal vector:

z = sqrt( 1 - x*x + y*y );

This very simple mathematical relation simply shows us that the knowledge of the X and Y coordinates of the normal vector permits us to calculate the third coordinate Z. More simply, the normal-map only needs the X and Y coordinates. Each texel of our normal-map contains the RGB triplet. The red canal represents the X coordinate, the green canal the Y coordinate and the blue canal the Z coordinate. The first particularity will be exploited and the red canal will be stocked in the fourth canal, the alpha canal. The second particularity will be exploited in the calculation of Z by using the value contained in the green canal (Y) in the relation seen just before. The calculation of the normal vector is given in the following piece of code:

vec3 bump;
bump.xy	= (texture2D(normalMap, uv).ag * 2.0) - 1.0;
bump.z = sqrt(1.0 - dot(bump.xy, bump.xy));

This small piece of code shows a quite practical functionality of the GLSL (and available in the other languages like Cg or the HLSL of Direct3D): the swizzling. The swizzle operator allows us to rearrange the components of a vector as we wish. In our case, we transfer the component a in x while the component g remains in y...

The DXTViewer tool will reveal itself as being essential here as it will permit us to create a DXT5 type compressed normal-map with the red canal injected into the alpha canal. To do so, it is simply necessary to load an uncompressed normal-map with 'RGBA Byte Texel' and 'Inject Red Channel into Alpha Channel' selected:


Fig. 7 - DXTViewer: Swizzled DXT5 normal map creation

The only thing we have to do after is to save the normal map in O3TC (or DDS, as you want!) format specifying DXT5 compression:


Fig. 8 - DXTViewer: DXT5 saving

This technique is somewhat similar to the one used with the ATI 3Dc format, technique that we will show after.

The result of this modification (available in the bump_map_compressed_swizzled_dxt5.xml file) is visible in picture 9:


Fig. 9 - Compressed bump map (DXT5) with the generation of the Z coordinate

The specular reflections are now correct and the result is globally satisfactory. But we can do better as we are going to see!







[ Index ]

Introduction | Page 2 | Page 3 | Page 4 | Conclusion

»Next Page







Language:


Demoniak3D
Current Version: 1.23.0
»Demoniak3D
»Download
»Libraries and Plugins
»Demos
»Online Help - Reference Guide
»Codes Samples


GPU Caps Viewer
Current Version: 1.4.2
»GPU Caps Viewer
»GPU DB Submissions


FurMark
Current Version: 1.4.0
»FurMark
»Benchmark Submissions


Geeks3D News
Page generated in 0.082690000534058 seconds.