Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Vertex Position causes low points to render over high points?

Discussion in 'Shader Graph' started by Heroshrine, Jul 19, 2023.

  1. Heroshrine

    Heroshrine

    Joined:
    Feb 11, 2018
    Posts:
    13
    I'm not sure what to do, or what graph settings i need to put to fix this. Basically, I have a very basic wave shader graph and the low points of it are rendering over the high points of it. In the picture, the dark spots are lower on the Y axis.
    upload_2023-7-19_14-24-16.png upload_2023-7-19_14-24-31.png
    Here is the vertex offset:
    upload_2023-7-19_14-21-3.png
    and here is the graph settings:
    upload_2023-7-19_14-21-32.png upload_2023-7-19_14-21-41.png
    I've tried pretty much every value for Depth Test & alpha clip threshold, but nothing seems to fix it, or even effect the problem at all. For the color I'm lerping based on the height. I do have a scene depth node for a foam effect around objects in the water, but I deleted all of that and it didnt fix it so I couldn't imagine that's causing this. Any help is appreciated!
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Google "transparency sorting", long story short the material is transparent and engine does not know if triangle should be rendered before or after - it's not directly caused by the fact you offset them, but nature of transparent materials.
     
  3. Heroshrine

    Heroshrine

    Joined:
    Feb 11, 2018
    Posts:
    13
    What about when it happens while the material is set to opaque?
     
  4. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    Assuming you didn't disable "writes to depth" and "z-test" then it should not happen, unless we are talking about something else - to be honest it's not very clear what actually happens in your pictures.
    I tried to reproduce your graph and I can't see any strange behaviour.

    GIF 27.07.2023 02-46-44.gif
     
  5. Heroshrine

    Heroshrine

    Joined:
    Feb 11, 2018
    Posts:
    13
    Mine looks like this, except the black parts are rendering over the white parts, even when the shader is set to opaque. What settings should I check? You said I need to disable writes to depth and z-test while it's opaque and it shouldn't happen?
     
  6. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,108
    No, it must check depth and write to depth, that is the tool that makes opaque materials render correctly - it checks if current depth is closer to camera to determine if the pixel should be set. This way it can discard pixels when they are behind something.
    Create new opaque shader and you will see default options for depth.
     
  7. Heroshrine

    Heroshrine

    Joined:
    Feb 11, 2018
    Posts:
    13
    Yes, I've read on the depth options from https://docs.unity3d.com/Manual/SL-ZTest.html and I have it set to LEqual, but the behavior still exists. Is there anything else that could possibly be causing it? Since I had tested it and deleted parts of the graph, I don't think it was the scene depth node or the color part. I can provide the full graph if you'd like, but I'm not sure what the best way to do that would be.
     
    Last edited: Jul 27, 2023