Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question intersecting 2 quads with transparent shader

Discussion in 'Shaders' started by pertholdth, May 24, 2024.

  1. pertholdth

    pertholdth

    Joined:
    Feb 28, 2024
    Posts:
    191
    when i intersect 2 quads with a transparent shader the sorting gets bugged

    i have found that if I instead leave the material as opaque and just tick "alpha clipping", it works

    is this supposed to be the fix or is there something more nefarious at play?
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,546
  3. pertholdth

    pertholdth

    Joined:
    Feb 28, 2024
    Posts:
    191
  4. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,546
    yes if it works for your case.

    additive blending was mentioned as one workaround also.
     
    DrDemencio and pertholdth like this.
  5. DrDemencio

    DrDemencio

    Joined:
    Sep 2, 2022
    Posts:
    78
    Yes, additive blending doesn't require sorting as you're just adding values (and addition is commutative). But you need to ensure opaque objects are rendered first and then draw transparent objects without modifying the z-buffer (not sure how to specify this stuff in Unity). Of course the result is completely different to alpha blending.

    For a 2D game, I think the best would be to force rendering objects from furthest to closest distance to the camera (again, not sure how to do such thing in Unity)