Search Unity

Resolved Mesh Transparency Artefacts

Discussion in 'Shader Graph' started by romanpapush, Jun 25, 2019.

  1. romanpapush

    romanpapush

    Joined:
    Sep 20, 2012
    Posts:
    40
    Hello,

    On the image below is a heavily subdivided mesh with vertex offset and transparency (to get depth fade effect as seen on the boxes). The problem is that with transparency enabled some polygons are getting randomly "clipped".

    As I understand it is caused by the order in which the polygons are drawn... But can't seem to find if there is a solution to this right now.



    It is running on the latest stable Unity and everything (Shader Graph / HDRP). I'm on Mac, so this is using Metal.
    I'm mentioning this because I had no problem when I was making similar shader on Built-in Renderer with the help of Amplify Shader Graph, where I was using OpenGL and had these settings for transparency:

    upload_2019-6-25_18-40-53.png

    Is there any solution for Shader Graph I'm missing?
    Much appreciated for any help or direction.
     
    Last edited: Jun 25, 2019
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,348
    I'm actually guessing your ASE version of the shader had one other thing enabled:
    upload_2019-6-26_9-22-41.png

    That renders the object once only to the depth buffer so that for the "real" pass only the closest surfaces are seen. That solves the sorting issue, though also removes visible overlaps. See this from the documentation:
    https://docs.unity3d.com/Manual/SL-CullAndDepth.html
    Unfortunately I don't believe there is any option to do this with Shader Graph at this time. The option to enable this does exist on some of the built in HDRP shaders, but that's not terribly helpful.

    Right now the solution would be either to hand modify the generated shader code to add the extra pass, or to pre sort the triangles of your mesh in c# or with a compute shader, potentially every frame.
     
    hippocoder likes this.
  3. romanpapush

    romanpapush

    Joined:
    Sep 20, 2012
    Posts:
    40
    @bgolus Thank you, once again, for responding so thoroughly.

    With your direction and Unity docs you've linked, I've managed to get the desired result by changing ZWrite parameter from "Off" to "On" under "ForwardOnly" Pass in generated Shader code.

    Just this one small change, and so far smooth sailing, no unwanted side effects.

    For discussion sake, these were the settings for the material that works in ASE:
    I don't know if that helps, but "Extra Depth Pass" was disabled.

    Thank you, once again. Now we'll just have to wait for Unity to implement this feature in Shader Graph.

    Cheers!