Search Unity

Alpha Vertex Lit Z

Discussion in 'Shaders' started by jujunosuke, Feb 18, 2015.

  1. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    Hi Everyone!
    I am using Alpha Vertex Lit Z shader that do exactly what i need.
    http://wiki.unity3d.com/index.php?title=AlphaVertexLitZ

    However, is it possible to have the same effect in a fragment shader ?
    Or is there a way to control vertex position in ShaderLab ?

    Any feedback on this would be great.
    Best regards.
     
  2. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    Yes, that's possible. The same strategy of first filling the depth buffer can be applied.
    Yes, you can modify the vertex positions in the vextex shader.
     
  3. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    Thanks mate i found how to do it.
    I just added ColorMask 0 to the fragmentation pass and then another pass with ColorMask RGB and that did the trick.
    Basically the content of The 2 passes i very identical except the Color Mask value and the Zwrite value.
    I am sure there is a smarter way of doing this but anyway it worked.
     
  4. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,520
    True, that pretty much is it. Technically you would also want to make your fragment shader very simple in the first pass, because the color is thrown away anyway. But, realistically, the GPU driver already does this for you.
     
  5. jujunosuke

    jujunosuke

    Joined:
    Apr 30, 2011
    Posts:
    190
    Thank you for taking the time to answer mate.
    I appreciate very much!
    Best regards.