Game Development Community

BUG: Normal Map DDS not supported in 1.8.1

by Steve Acaster · in Torque Game Engine Advanced · 04/29/2009 (8:12 am) · 5 replies

After a fair bit of porting/testing/code patching, it appears that TGEA 1.8.1 does not support Normal Map DDS files on DTS models. It all goes horribly wrong with inverted lighting - shadowed areas are fully lit, lit areas are in shadow.

And I did patch all the reported errors in the engine from the sticky. Reverting to non-DDS formats for normal mapping cures said problem. This wasn't an issue in 1.7.1.

#1
04/29/2009 (10:06 am)
You've stumbled across an "improvement". TGEA 1.8.x expects DXT5 normalmaps to be set up a bit differently, specifically with 'x' in the alpha channel and 'y' in the green channel. The shader will recalculate z on its own. This is done because, generally speaking, DXT compression produces horrible results on normal maps, but rearranging the channels like that produces significantly better results. There's more detail in this paper.

Too bad this isn't documented though. It should probably be a separate flag on the material instead of "Oh hey, DXT5 bumpmap, it must be swizzled!"

Edit: Bah, I missed a chance to use "It's not a bug, it's a feature!" in an accurate and non-ironic context.
#2
04/29/2009 (10:17 am)
Ah, I'll have a read of that and see about "swizzling".

generally speaking, DXT compression produces horrible results on normal maps
Yeah, I noticed and have come up with a whole host of tests to get better results.

edit: Lol! Swizzling actually is a technical description!
#3
04/29/2009 (9:05 pm)
ya, swizzle.
...swizzle that shizzle my mizzle.
(swizzle that sh&* my man)

not that you need mroe than that PDF AlexS posted but have ti anyways...more info on this shiznit here yo: go to section "3.3 Tangent-Space 3Dc"

Liking those test results Steve! nice to see another analytical mind roaming about the realm of normal maps!



#4
04/29/2009 (9:18 pm)
We had experimented with DDS Normal maps prior to 1.7.1 with some decent results (had modified the shader ourselves to swizzle the channels, but lighting was still a mess).

If it is working as it should in 1.8.x, then maybe will have to give it a shot, since it'll save alot of space and alot of the artifacts from DXT compression in normal maps are somewhat balanced out with Z being calculated in the shader (thus everything is normalized or should be)
#5
05/04/2009 (11:15 pm)
As a general update, in TGEA 1.8.x trunk, there is now a swizzledNormalMap parameter for each stage of a material which indicates if the normal map has been swizzled as described in that paper. The material system no longer assumes that a DXT5 normal map has been swizzled.

Also, when I say "TGEA 1.8.x trunk" I probably also mean "Torque 3D trunk", just so you guys know.