Currently using function as outlined in http://www.terathon....de/tangent.html
This appears to match DA stock models which use regular armour shader, but results in noticeably different appearance for items like hair. For these, it seems swapping the equations for tangent and bitangent provides correct shading, except it can result in some nasty glitches in certain spots, plusit breaks the appearance for regular shader.
Just wondering if someone figured out a better/more universal way to calculate these.
Calculating mesh vertex tangents/bitangents?
Débuté par
tmp7704
, avril 04 2010 02:03
#1
Posté 04 avril 2010 - 02:03
#2
Posté 04 avril 2010 - 02:35
The way I calculated them is this if the normal is [x,y,z]:
Tangent: [-y,x,z] x [x,y,z] (thats cross product)
Bitangent: Tangent x Normal (again cross product)
I have no idea how it works for hair though.
Tangent: [-y,x,z] x [x,y,z] (thats cross product)
Bitangent: Tangent x Normal (again cross product)
I have no idea how it works for hair though.
#3
Posté 04 avril 2010 - 03:45
Yup, tried some of the simpler ways like that but that doesn't really work either -- with regular shader the misaligned vectors affect just the normal mapping so it's easier to overlook, but hair seems to do some specular/reflection tricks to simulate closer the real thing, which highlights the issue.
Would be much easier to get it all match if there was some kind of debug switch either in toolset or in game itself to render the tangent vectors, but i suppose if there's such thing it's not published anywhere.
Would be much easier to get it all match if there was some kind of debug switch either in toolset or in game itself to render the tangent vectors, but i suppose if there's such thing it's not published anywhere.
Modifié par tmp7704, 04 avril 2010 - 03:54 .
#4
Posté 04 avril 2010 - 04:26
Why dont you try to match results?
Halla model: (these are all added as vertex normals)
Normal Original

Normals as exported

Tangents Original

Tangents exported

Binormals Original

Binormals exported
Halla model: (these are all added as vertex normals)
Normal Original

Normals as exported

Tangents Original

Tangents exported

Binormals Original

Binormals exported
#5
Posté 04 avril 2010 - 05:00
That's a great idea. Unfortunately Lightwave support for showing vertex normals is pretty much non-existent so can't use it... i guess i could tweak the importer though, to generate extra geometry out of the tangent/bitangent data. That's something to look into, thanks.
#6
Posté 05 avril 2010 - 02:29
OK, some results of poking around:

on the left are DA meshes imported straight, on the right it's the same meshes after export and re-import. Top half has pictures of light armour model, bottom half is a strand of hair model. Red vector is tangent, green is bitangent, blue is normal.
As you can see, the normals for the light armour model match pretty close. For hair model however, DA apparently expects the tangent and bitangent to be swapped -- that is, while in normal shader the tangent is generally aligned with S-direction of the uv map, for hair it's aligned with T-direction instead. Rather bizzare, but i guess when in Rome etc.
Incidentally, turned out the glitches i mentioned in OP were result of some hideously sloppy uv-mapping of the base model i've used as source. Once these were straightened the errors disappeared... i guess BioWare's own tools work different and/or are more sophisticated, since they clearly managed to preduce mapping which avoided that issue.

on the left are DA meshes imported straight, on the right it's the same meshes after export and re-import. Top half has pictures of light armour model, bottom half is a strand of hair model. Red vector is tangent, green is bitangent, blue is normal.
As you can see, the normals for the light armour model match pretty close. For hair model however, DA apparently expects the tangent and bitangent to be swapped -- that is, while in normal shader the tangent is generally aligned with S-direction of the uv map, for hair it's aligned with T-direction instead. Rather bizzare, but i guess when in Rome etc.
Incidentally, turned out the glitches i mentioned in OP were result of some hideously sloppy uv-mapping of the base model i've used as source. Once these were straightened the errors disappeared... i guess BioWare's own tools work different and/or are more sophisticated, since they clearly managed to preduce mapping which avoided that issue.
#7
Posté 05 avril 2010 - 03:28
What kind of sloppy hair model was it can you tell?
At least your birnomaltangent stuff is abit right lol. I would leave the possibility that this is not the problem. But is strange i guess. What kind of problem do you have now that the glitch is gone?
At least your birnomaltangent stuff is abit right lol. I would leave the possibility that this is not the problem. But is strange i guess. What kind of problem do you have now that the glitch is gone?
#8
Posté 05 avril 2010 - 03:56
It was the *hb4 model for human females if i remember right, but i wouldn't be surprised if more meshes were affected by it, as the models shipped with game come with tangents/bitangents which make it seem fine.Eshme wrote...
What kind of sloppy hair model was it can you tell?
At least your birnomaltangent stuff is abit right lol. I would leave the possibility that this is not the problem. But is strange i guess. What kind of problem do you have now that the glitch is gone?
I guess it's just weird decision to have some shaders work with the vectors arranged in one way, but another requiring them to be arranged just the opposite -- short of adding explicit switch in exporter config or something and expecting the artist to actually know they have to flip it on export, that can't be really automated. In any case not having further problems with it (for now at least), i just posted that last pic/update in case one day someone else stumbled upon this too and also wondered what the heck





Retour en haut






