Search Unity

Multiple camera rendering order control?

Discussion in 'General Graphics' started by Fragment1, Aug 27, 2019.

  1. Fragment1

    Fragment1

    Joined:
    Aug 30, 2013
    Posts:
    67
    I'm not really sure how to describe this in abstract terms. I have multiple cameras rendering on the same scene, but transparent objects are being drawn out of order. This means if there's overlap between what cameras are rendering to the screen, the transparent object's behind portion could be grey or white due to camera render order.

    I could use more cameras and layer culling, but that comes with significant overhead to my batch count along with using up precious limited layers.

    What currently happens:

    Code (CSharp):
    1. foreach (Camera cam in cameras)
    2. {
    3.      cam.RenderOpaque();
    4.      cam.RenderTransparent();
    5. }
    What I want to happen:


    Code (CSharp):
    1. foreach (Camera cam in cameras)
    2. {
    3.      cam.RenderOpaque();
    4. }
    5. foreach (Camera cam in cameras)
    6. {
    7.      cam.RenderTransparent();
    8. }
    9.  
    I tried looking into the scriptable render pipeline, but it seems like it would need a lot of error prone work as I can't just hook into the standard pipeline and change this in a trivial way.

    Or can I? Or, is there another way to do this?

    The only way I can see this happening is if I write my own entire rendering pipeline, which introduces potential incompatibility with third party shaders.

    And even then, I'm not entirely sure it would even be possible there as there isn't an obvious example or clue to it in the github assets.