Search Unity

Question Edge shader

Discussion in 'Shaders' started by Ikaro88, Aug 18, 2022.

  1. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    300
    Hi exist a "edge" shader?
    I need an effect similar to this:


    With the difference that the objects must be transparent

    I have to use this on a VR project so I am not sure I can use a post process...

    Anyway on the web I found a LOT of outline solutions but not one "edge" solution...

    Can anyone help?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    Not possible. Not with the technique being used above.

    Post process based outlines like that only work with opaque objects, because it is using a screen space texture of the normals and depth of the closest visible surface. Because it's a texture, it can only hold one normal and one depth per pixel, which isn't a problem for opaque surfaces. For transparent surfaces there can be multiple normals and depths. There are some people who render all of the transparent objects into a separate set of screen space textures, treating them like opaque objects, and using that for an extra set of outlines and edges, but that only works for very specific visual styles, and again only the closest "transparent" surfaces will get the lines, and any overlapped transparent surfaces will not.

    The only way to achieve this in an efficient way is to do it with the content. Have your transparent objects have lines drawn on them, either with textures, or with additional geometry.