Search Unity

DepthOffset

Discussion in 'Shaders' started by NCarter, Mar 5, 2006.

  1. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    I'm trying to write a shader which uses something like glPolygonOffset() to artificially place an applied object in front of the surface it's lying on to reduce Z-fighting. Specifically, I'm using a TextMesh to put a blended code number on the side of a spaceship.

    Looking at the OTEE wiki page for SL-Pass, I notice that there's a DepthOffset feature which sounds like it might be the same thing. However, it isn't documented and it doesn't seem to work (it gives a syntax error). Is it supposed to work, and if so, how would I use it?
     
  2. NicholasFrancis

    NicholasFrancis

    Joined:
    Apr 8, 2005
    Posts:
    1,587
    The syntax is 'offset'


    Try:
    Code (csharp):
    1.  
    2.  
    3. ...blah...
    4.    Pass {
    5.       Offset -1, -1   // Pulls the objects a bit closer
    6.       ...blah...
    7.    }
    8.  
    You can insert pretty much any value there.
     
  3. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    Thanks, that works perfectly. :)
     
  4. NCarter

    NCarter

    Joined:
    Sep 3, 2005
    Posts:
    686
    In anyone's interested, this is the resulting shader.