I have few questions about normal, tangent, binormals and how they works (with baker, engine, ..) Correct me if I'm wrong.
I begin very simply, I create LP and HP, create Smoothing groups (hard/soft edges) as I need on my LP. My vertex normals (split, average) are computed from these smoothing groups.
Then I export my LP and HP as FBX file, of course I clone and triangulate my LP before exporting to avoid getting shading problems if each programs (baker, engine)
can triangulate differently.
I check option from FBX export menu Smoothing Groups. This option save information to FBX file about my vertex normals as are set, that are computed from smoothing groups (hard/soft edges) or can be vertex normals that are manualy tweaked by hand too.
First option, check export with tangent a binormals, that means my modeling program (Maya) compute tangent and binormals by his own tangent calculator and storing information about tangent and binormals to FBX file.
Secound option, uncheck export with tangent a binormals, that means my modeling program (Maya) do not compute tangent and binormals by his own tangent calculator and no information about tangent and binormals are stored in to FBX.
I import my LP to xNormal and now may become this.
If my LP contains data about tangent and binormals, xNormal use this information to bake.
If my LP doesn't contains data tangent and binormals, xNormal compute tangent and binormals by his own tangent calculator , in this case Mikk Tspace.
And now what I don't understand exactly, in xNormal plugin menu for tangent calculator I can choose Compute binormals in the pixel shader.
What exactly this option do when:
- my LP contains tangent and binormals data
- my LP doesn't contains tangent and binormals data
Replies
That means that, if you know two of them (the normal and the tangent, usually) you can easily work out which direction the third (the binormal) should point in; it's whatever direction is at right angles to the other two (we can use what's called a cross product in vector maths terms). This is good for games because that means you only need to store 2 values per vertex, rather than 3 (it makes it cheaper to store and to send the mesh data to the graphics card because there's less information it needs to know).
Generally this is done for each vertex (in the vertex shader) and the calculated binormal at each vertex is blended across each triangle in the pixel shader.
However, it's possible to do this same calculation for each [i]pixel[/i] rather than vertex. The results are slightly different because it uses the blended values for that point on the triangle.
It is slightly more expensive to do that calculation for each pixel rather than each vertex. However, by not sending the binormal through from the vertex shader, you free up some space to send extra data through (or you're just sending less data, which makes it faster). So the trade-off can often be worth it.
Unreal Engine 4 does the per-pixel thing.
Note: I've simplified this a little bit, but that's the general idea.
When you're sending FBX through from Maya with Tangent and Binormal exported, I believe xNormal will still do the per-pixel cross product thing if you tick the box.
That said, Maya's tangent basis is pretty complicated (it needs quite a few more extra and expensive per-pixel steps in order to look correct). So you're probably best not exporting Tangent and Binormal to FBX.