Home Technical Talk

normal, tangent, binormals - how they works

PetSto
polycounter lvl 4
Offline / Send Message
PetSto polycounter lvl 4
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

  • Farfarer
    Offline / Send Message
    Farfarer polycounter lvl 17
    So, generally for normal mapping, you want the normal, the tangent and the binormal to all point at right angles to each other (it wants to be orthogonal... they should form something that looks similar to the little red, green and blue axis in your 3D program; three directions each with 90 degrees between it and the other two).

    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.
  • ceebee
    Offline / Send Message
    ceebee polycounter lvl 14
    I typically will only export my LP from Maya with only "Smoothing Groups" and "Triangulation" checked (unless I'm triangulating manually or by hand). Now that Mikk Tangent Space is becoming more commonplace (Substance, UE4, Unity..i think, xNormal, Knald, Handplane) I'd rather the baker and engine do the tangent work for me. It makes things much more simple, and honestly easier.
Sign In or Register to comment.