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?
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.
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.
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?
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.