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

Bug (Case 1323760) Alpha clip threshold not working properly

Discussion in 'Shader Graph' started by FOXAcemond, Mar 23, 2021.

  1. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    I have a weird bug since 2021.1 in my shader graph.
    I'm using alpha and alpha clip threshold to mask a mesh but it glitches out:
    alpha.png
    Two meshes are at the same location but one is masked with alpha clip threshold and should not be visible.
    If I disable the one that is visible (the dark one), the other (the light one that glitches out) disappears as well!
     
  2. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    This bug is major for me and kills my game completely. I'm creating a small reproductible to submit a proper bug report.
     
  3. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
  4. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    932
  5. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    Hey @SebLagarde,

    I suspected this commit to be the "issue" for me indeed since it corresponds to the 10.4.0 update of HDRP.

    The idea of having small offsets everywhere as a workaround bugs me though somehow. Even if it means implementing an automatic process for shifting said surfaces. It just feels like it calls for additional problems down the line.

    From what I understand from the commit, that means that depth prepass was performed for surfaces that were opaque + alpha clipping. And now it is completely skipped if the surface is opaque regardless of the state of alpha clipping, right?

    That doesn't sound to me as a big deal on performances in my case and I'm totally okay to check depth for all that have alpha clipping on since that's precisely what I need. I'll stick with the old check then, maybe I can even upgrade HDRP and manually override this line of code? (I don't like to stay behind in terms of versions.)

    I'm sincerely grateful for all the effort that was spent on dealing with this! Thank you.
     
  6. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    Yes, that's it. I modified the template in the Library's PackageCache and there is no glitch any more.

    Now I need a way to make it "permanent" for me and compatible with pulling next versions of HDRP... Any idea on how I could do that properly?

    Fow now I just copy over the package from cache, change the template and add the package as a local package. I guess I'm going to need to do that for every update now, right?
     
    Last edited: Apr 28, 2021
  7. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    932
    Hi,

    >From what I understand from the commit, that means that depth prepass was performed for surfaces that were opaque >+ alpha clipping. And now it is completely skipped if the surface is opaque regardless of the state of alpha clipping, right?

    No it is the opposite.

    Before this fix, the alpha clipping test was perform for both depth prepass and for gbuffer pass. After this fix, it is apply only to depth prepass. This is required to get the performance boost. We want to avoid to have to redo the alpha clipping test in gbuffer pass.

    And this explain why you get the behavior you are looking for, as the alpha clipping is perform in gbuffer pass you don't have the Z-fighting issue you observe with the fix.

    >Now I need a way to make it "permanent" for me and compatible with pulling next versions of HDRP... Any idea on how I could do that properly?
    >I guess I'm going to need to do that for every update now, right?

    You case is very specific and defeat our architecture design to optimize alpha clipping, so you will need to maintain it. The proper way is still our first advice: To have a slight offset between your geometry to avoid z-fighting.

    Cheers
     
  8. FOXAcemond

    FOXAcemond

    Joined:
    Jan 23, 2015
    Posts:
    99
    Ok I need to take a little bit of time to understand all this. In the meantime, I'll stick with my manual override and if things get out of control, I'll consider the surface offset.

    This is a last resort for me since we're talking about all the meshes in my game here. All the objects in the game are using this test in order to know if they should appear or not.