2
\$\begingroup\$

In teh tangent space vertex attributes why is the bitangent (aka binormal) provided as an attribute instead of calculated?

If the three vectors of the tangent space must be perpendicular then the bitangent can be calculated as the cross-product of the other two vectors. There are technically two perpendiculars here, but surely we could consistently calculate the one we want, even if it requires a boolean marker to negate it.

Similarly the bitangent itself doesn't need a full vector to be represented. From the normal alone we know the plane on which the tangent must reside. In theory a simple angle would be enough to calculate the tangent vector.

Given that GPU memory is at a premium why do we provide the full vectors for these values rather than calculating them (with reduced data input)? Or am I wrong in assuming the tangent space must be a cartesian system?

\$\endgroup\$
4
  • \$\begingroup\$ Actually I have seen both implementations, calculated and passed as attribute. Why did you assume that it is not calculated ? \$\endgroup\$
    – concept3d
    Apr 16, 2014 at 8:14
  • \$\begingroup\$ All the references I've looked at show it's calculated as part of the mesh. The libraries I've used (only a few) also expect it as a precalculated vertex attribute. Additionally it is exported by modelling programs. \$\endgroup\$ Apr 16, 2014 at 8:39
  • \$\begingroup\$ well, it depends on the implementation, this one doesn't pass it as attribute terathon.com/code/tangent.html \$\endgroup\$
    – concept3d
    Apr 16, 2014 at 8:42
  • 1
    \$\begingroup\$ That article does state that it isn't necessarily true that all vectors are orthogonal. \$\endgroup\$ Apr 16, 2014 at 9:02

1 Answer 1

1
\$\begingroup\$

I'm pretty sure many games do calculate the bitangent by crossing the normal and tangent. In the games I've worked on, that's what we did. We also stored a 1-bit "flip" value to indicate whether the tangent basis should be right-handed or left-handed. As you say, this saves memory, plus the bandwidth used to fetch the memory; and if you reconstruct the bitangent in the pixel shader it also saves an interpolator (which can be a nontrivial cost).

However, it's not always correct to do this. The tangent and bitangent vectors are derived from the UV mapping, so if the UV mapping is distorted then these vectors need not be orthogonal. Therefore the bitangent can't be correctly reconstructed from just the normal and tangent.

On the other hand, in practice, people tend to model things in such a way that the mapping is close to orthogonal most of the time, and it's difficult to notice lighting errors due to slightly wrong bitangents.

\$\endgroup\$
2
  • \$\begingroup\$ Do you know of a reference that would indicate why the UV mapping would not be orthogonal? That is, what effect it can achieve? \$\endgroup\$ Apr 17, 2014 at 6:36
  • \$\begingroup\$ @edA-qamort-ora-y The UV mapping is whatever the artist creates. If the artist makes it non-orthogonal, that's what it is. UVs for curved surfaces, such as characters, are always at least a little bit non-orthogonal. \$\endgroup\$ Apr 17, 2014 at 20:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .