Search Unity

Bind "Tangent", tangent - doesn't work.

Discussion in 'Shaders' started by Jessy, Oct 15, 2009.

  1. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
  2. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    I get a syntax error trying to use
    Code (csharp):
    1. Bind "Tangent", tangent
    Honestly, though, I don't know what you'd use it for. Tangents get used in the vertex shader in tangent-space normal mapping. Using BindChannels to pass them straight to the pixel shader wouldn't do you much good, because you'd get the raw tangents and have to do your normal transformation in the pixel shader, which is an expensive and redundant operation.
     
  3. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    I can't use pixel shaders because Unity iPhone doesn't support them yet. So I assume it's useless. Perhaps this binding works in Unity 2.5? (Can't test at the moment.)
     
  4. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    Nope, I tested it in 2.5.1. You didn't mention iPhone in your OP. I'm not familiar with the iPhone, but I believe it supports some sort of normal mapping in fixed function, so binding vertex tangents might make sense there.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Actually on the iphone tangents are without any use. I would expect Unity iPhone 1.5 to fully drop them for optimized transformation and batching.

    The Dot3 normal maps are not in tangent space but normal space as far as I'm aware

    As for using it in shaders: Ddoes unity generate tangets at all? As far as I see the tangent generation so far was always part of the shaders.
     
  6. Jessy

    Jessy

    Joined:
    Jun 7, 2007
    Posts:
    7,325
    I know, but I figured it was irrelevant. But then I thought maybe the error only happens because pixel shaders are not supported. It seems weird to include the binding in the documentation if it doesn't work at all.

    No, it only works based on textures, therefore, object space is the only practical application.

    http://forum.unity3d.com/viewtopic.php?t=15749

    You can do sort of do tangent space normal mapping, by programmatically creating a texture based on the world space normals of a mesh, but that will give you a slideshow, it's so slow. I even tried just adjusting vertex colors every frame, based on worldspace normals, and I got about 5 fps on my MacBook Pro, doing that. Totally impractical with today's technology, methinks.
     
  7. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    On the desktop there is actually an easy way to overcome the vertex color modification stuff: A 1x1 per side cubemap that encodes the color data and blend the normal map with that. Naturally you can use larger cubemap sides if you want more finegrained data.

    As this works even high performant on dX7 its granted that any current gen hardware takes that without any hit at all :) (learned about that trick through Blitz3D where you don't have access to the animated vertices on animated models at all to alter the vertex color)
     
  8. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    BindChannels is only used for fixed function vertex processing. Now, there's no concept of "tangent" in fixed function vertex processing, so what you're doing will not work.

    In fixed function T&L, all there is is positions, normals, texture coordinates and colors.