Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can a TransparentCutout shader be as efficient as Opaque?

Discussion in 'Shaders' started by JoeStrout, May 16, 2020.

  1. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I understand that transparent shaders are generally very costly, because they don't write to the depth buffer, but instead have to be sorted and drawn in back-to-front order — whereas opaque shaders are ideally drawn front-to-back, and use the depth buffer to avoid drawing further away pixels at all.

    But I don't understand how TransparentCutout shaders fit into this. Many of the fragments are clipped, and do nothing; and most of the others are solidly opaque, so I would hope that they write to the depth buffer. But do they? And do they still need to be rendered after all opaque geometry and drawn back-to-front, just for those edge pixels that may have partial alpha?

    If so, it sounds like these may be substantially less efficient (thinking particularly about mobile hardware like Quest) than an opaque cutout shader. Is that true?

    If so, is there any solution that lets me get some smoothing on the edges (ideally using the MSAA alpha-to-coverage technique) without sacrificing performance? Maybe (grasping at things I don't really understand yet) something like using additive alpha instead of alpha blending?
     
    april_4_short likes this.