Horde3D
http://www.horde3d.org/forums/

UV rotation and normal maps
http://www.horde3d.org/forums/viewtopic.php?f=2&t=1179
Page 1 of 1

Author:  worstplayer [ 15.06.2010, 11:11 ]
Post subject:  UV rotation and normal maps

If mesh has any rotated UVs, normal maps display incorrectly, as if they were lit from wrong direction. This causes normal maps to looks "shattered" on models with complex UV.

Image
(straight, rotated, randomly rotated UV clusters, all 3 faces look identical in xNormal)

I'm using SVN 245 and colladaConv, diffuse maps look OK.
Any way around this?

EDIT: example file

Attachments:
head.zip [197.87 KiB]
Downloaded 608 times

Author:  marciano [ 15.06.2010, 22:20 ]
Post subject:  Re: UV rotation and normal maps

This is certainly a problem with the tangent space basis. Do you use the same tangent space normal map on all three meshes that have different UVs? That will not work as the normal map does no longer match the tangent space basis for which it was generated.

From your notes I see that you use xNormal to generate the normal maps. To get perfect results, the tangent space algorithm used for creating the normal maps must be exactly the same as the one that is used for rendering the model. However, xNormal will certainly have a different tangent space generation algorithm than ColladaConv. So the normals encoded by xNormals may not be decoded correctly in Horde. Depending on how different the algorithms are, the error may not always be noticeable but there can definitely be problems. AFAIK, xNormal has a plugin interface with which you can specify your own tangent space generator. For perfect results, someone would have to write a horde plugin which uses the tangent space generation code from ColladaConv.

Author:  worstplayer [ 16.06.2010, 12:25 ]
Post subject:  Re: UV rotation and normal maps

Wow, didn't expect it to be this complicated.
No problem, object space normal maps solve this quite efficiently. They have their own limitations (software skinning and morphs don't affect lighting (that would probably require changes in the engine)), but no more seams.

Image
And bumpmaps that look like this can't be all bad :D

Author:  swiftcoder [ 16.06.2010, 13:20 ]
Post subject:  Re: UV rotation and normal maps

worstplayer wrote:
If mesh has any rotated UVs, normal maps display incorrectly, as if they were lit from wrong direction.
I am still a little confused by what exactly a 'rotated UV' is - can you explain what exactly is rotated, and with respect to what?

I would assume that you have applied some portion of the UV mapping to the surface, and then decide to rotate the resulting triangle-to-texture mapping to rotate the location of that triangle in texture space.

If that is the case, then as long as you re-generate the tangent-space basis afterwards (taking into account the changed UV coordinates), everything should be fine.

Author:  marciano [ 16.06.2010, 23:56 ]
Post subject:  Re: UV rotation and normal maps

worstplayer wrote:
Wow, didn't expect it to be this complicated.
No problem, object space normal maps solve this quite efficiently. They have their own limitations (software skinning and morphs don't affect lighting (that would probably require changes in the engine)), but no more seams.

It is also good to keep in mind that they require considerably more memory, as you can't compress them with a two-component format like 3Dc and as it is not easily possible to mirror UVs when using object space normal maps.

BTW, I happened to see some of your videos on youtube. Really cool stuff you are doing there :)

Author:  worstplayer [ 18.06.2010, 09:49 ]
Post subject:  Re: UV rotation and normal maps

marciano wrote:
It is also good to keep in mind that they require considerably more memory, as you can't compress them with a two-component format like 3Dc and as it is not easily possible to mirror UVs when using object space normal maps.
Yeah, there also can't be any tiling or overlapping (except on completely flat surfaces). On the other hand, they work perfectly across different LOD levels (I tried decimating 200kpoly model to 5000 and there was still practically no distortion) . All in all, using object space for characters and tangent space for levels sounds like a good setup.

marciano wrote:
BTW, I happened to see some of your videos on youtube. Really cool stuff you are doing there :)
Thanks, none of it would be possible without this excellent engine :)

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/