Search Unity

Compositing Multiple Cameras in LWRP...

Discussion in 'Editor & General Support' started by MONKAYMOO, Aug 6, 2019.

  1. MONKAYMOO

    MONKAYMOO

    Joined:
    Aug 23, 2013
    Posts:
    2
    I have a finished product that uses multiple cameras with "depth-only" buffer clearing in the Standard Render Pipeline. I have been asked to get my product running on a tablet, and I have opted for converting to the LWRP because it runs faster on the tablet. LWRP does not support multi-camera rendering to the main buffer. As an alternative, I have followed this tutorial (https://docs.unity3d.com/Packages/com.unity.postprocessing@2.0/manual/Writing-Custom-Effects.html) to create a custom effect that composites a texture with the main buffer. I set one of the secondary cameras to render to texture, and I use that texture in my custom effect. This works great. However, I need to do this with multiple secondary cameras (each one renders specific elements in the scene). The problem I am having is that the post process volume only allows each effect to be added to it ONCE. Thus, I cannot simply stack my effect on the post process volume and assign different render textures (one for each secondary camera's render target).

    I'm losing my mind trying to figure this out. I need some direction from a more experienced developer, someone who knows more about the scriptable render pipeline.

    Goal: given 1 main camera that renders to the main buffer, and N secondary cameras that each render to their own render texture, composite each of the N render textures into the main buffer.

    Current solutions (non-optimal):
    1) have a shader with N texture2d properties, set each one to a corresponding camera's render texture, composite all of them in that one shader.
    2) have N custom post process effects (compositeEffect1, compositeEffect2, ...), each of them is exactly the same code and reference the same shader, but when adding them to the post process volume, have their property set to a different camera's render texture.

    These two solutions are very bad for maintainability and are super hacky.

    Can someone please point me in the right direction?