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

How to use one custom shader for both alpha and additive blending for reducing batches?

Discussion in 'General Graphics' started by Go3k, Dec 25, 2017.

  1. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    17
    I found a youtube video that shows a custom shader could support the two different blending effect with only 1 material. This is the exactly solution I want to reduce draw calls in my project, but I can't imagine how this implemented. Can anyone give me some suggestion?
     
  2. ifurkend

    ifurkend

    Joined:
    Sep 4, 2012
    Posts:
    350
    While I have no idea of and am interested in the author's method, one extra drawcall would hardly be a game changer in mobile performance. What you really need to watch out besides drawcall are overdraw and screen fillrate of your transparent objects. If my particle material can use opaque shader, I would rather sacrifice 1 drawcall batching with other transparent particles.
     
  3. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    17
    Thanks for your advice! The drawcall issue im working on is: I have a 100 v 100 unit battle, and each unit will create a particle effect when it attack, the particle effect contains 2 particle system objects with different material, there are hundreds particles at the same time. I found the dynamic batch don't working well, the batch count will increase 100+, I don't know the exact reason. But if I use a single one material in the particle, the batch works fine.
     
  4. ifurkend

    ifurkend

    Joined:
    Sep 4, 2012
    Posts:
    350
    Use "order in layer" in particle system renderer. You may set negative 1 for your alpha blended particles so they are always behind the additive particles (order zero). Sandwiching different materials or billboard/mesh mode prevent drawcall batching.
     
  5. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    17
    Thanks! It's really helpful for me. :)
     
  6. Torbach

    Torbach

    Joined:
    Jan 3, 2013
    Posts:
    10
    richardkettlewell likes this.
  7. Go3k

    Go3k

    Joined:
    Oct 21, 2015
    Posts:
    17