Home Technical Talk

Per-pixel Anisotropic Highlights from normal map?

Well I'm working on my nVidia shader contest entry (thanks for the ideas btw guys, will show something tonight hopefully), I've a question.

I'm using anisotropic specular highlights, using the tangent. However, I have a normal map, I'd like to use the per-pixel tangent instead of the tangent passed from the geometry. Is this possible to do (to get a per-pixel tangent based on a tangent/object space normal map?)

What I assume I need to do, is take the normal map, and multiply it by the world T, B, and N somehow in order to generate a tangent instead of a normal?

Any suggestions or ideas you guys can give?

Replies

  • Ryan Clark
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Here's my suggestion. (I haven't tried this, but it oughtta work...)


    1. Transform PerPixelNormal into the same space as your tangent vectors. (if they aren't in the same space already)

    2. Define PerPixelTangent as the cross product of Bitangent and PerPixelNormal.

    3. Normalize PerPixelTangent.

    4. If the dot product of Tangent and PerPixelTangent is less than zero, multiply PerPixelTangent by -1 to invert it.
  • Rob Galanakis
    Thanks for the suggestion, it seems to be working some (not perfectly but close enough), I'll have a definite answer tonight.
  • Ryan Clark
    Offline / Send Message
    Ryan Clark polycounter lvl 18
    Here's another possibility. Slightly more expensive, but might be better looking. You may want to try both and see which works best.

    1. Transform PerPixelNormal into the same space as your tangent vectors. (if it's not in the same space already)

    2. Define PerPixelBitangent as the cross product of Tangent and PerPixelNormal.

    3. Define PerPixelTangent as the cross product of PerPixelBitangent and PerPixelNormal.

    4. Normalize PerPixelTangent.

    5. If the dot product of Tangent and PerPixelTangent is less than zero, multiply PerPixelTangent by -1 to invert it.
Sign In or Register to comment.