Search Unity

Semi-transparent objects in deferred rendering: Fall back to forward render or use a command buffer?

Discussion in 'General Graphics' started by ilusomu, Jun 7, 2016.

  1. ilusomu

    ilusomu

    Joined:
    May 28, 2015
    Posts:
    24
    I have a couple of vehicles in my scene with semi-transparent glass that the player ideally could look through and see pedestrians driving. Without using forward rendering for those glass objects, it seems like the best option would be to use a command buffer or grabpass.

    My question now is which is better for performance? When we're talking about potentially tens of vehicles on screen, is there a clear-cut winner?
     
  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    forward seems like the best bet, especially if those glass pieces are dynamically batched (low poly). I don't think instancing works well with forward yet.
     
  3. ilusomu

    ilusomu

    Joined:
    May 28, 2015
    Posts:
    24
    Good to know. If you don't mind me asking, you could give a basic rundown on why that would be the better option? I'm pretty new to a lot of this rendering tech and would love to learn more.
     
  4. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Well you don't actually need to do anything, transparency will just work. Unity will draw it in forward even if you're in deferred.
     
  5. ilusomu

    ilusomu

    Joined:
    May 28, 2015
    Posts:
    24
    Sorry, heh. I meant to ask this from a performance perspective in comparison to using a command buffer. It sounds like they might be comparable, making forward the better choice?
     
    Last edited: Jun 7, 2016
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Command buffers are for when you want to do something outside of what the default Unity pipeline does, or you want very explicit control.

    If you just want a bunch of transparent objects and you don't want to have to handle depth sorting, culling, or lighting on your own, just use transparent shaders.

    If you don't need or want to do all of the above using your own code and don't mind if they don't sort properly with other transparencies in the scene, use command buffers.

    Performance wise if you're just rendering a few of them command buffers are probably faster. If you're rending a lot of them the built in stuff will likely be faster unless you do a lot more work.


    The cost of rendering transparencies has more to do with how much of the screen they cover and how many of them are overlapping. Beyond that they have all of the same performance impacts as drawing opaque objects; vertex count, draw calls, etc. Unity has some built in stuff to try to make stuff draw as efficiently as possible, and command buffers don't necessarily.
     
  7. ilusomu

    ilusomu

    Joined:
    May 28, 2015
    Posts:
    24
    Thanks! The breakdown is much appreciated. Both you guys rock. : )