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

Question ScriptableCullingParameters and multiple cameras.

Discussion in 'SRP Dev Blitz Day 2022 - Q&A' started by sabojako, Sep 29, 2022.

  1. sabojako

    sabojako

    Joined:
    Jul 7, 2017
    Posts:
    48
    This touches on the idea of a global ShadowManager that handles multiple cameras, in this post: https://forum.unity.com/threads/urp-cached-shadows.1342265/#post-8475938

    In SRP, it would be cool if we could input more params to ScriptableCullingParameters for the creation of the main CullingResults, so that we could combine multiple culling inputs together, say 2 cameras.

    It would be even cooler if DrawRenderers() would allow drawing renderers with a custom culling matrix/planes (not strictly the camera's ScriptableCullingParameters it was created from). It kinda would function like what DrawShadows() seems to do with ShadowDrawingSettings, but with "CustomDrawingSettings(CullingResults cullingResults, int cameraIndex or cameraCullingMatrix)".

    A perfect use case : a Planar Reflection ScriptableRenderPass where we could pass the reflection's culling params as extra for the main CullingResults. Run the Cull(). Then we could just call DrawRenderers() with a CustomDrawingSettings. This way we can avoid running an extra context.Cull() which is insanely costly. We actually have a Planar Reflection ScriptableRenderPass ourselves but we need a new CullingResults for each reflection plane.

    In the end, we actually do something different. We take the camera's culling matrix and we expand it a bit towards the direction of the reflection plane's normal. We can only do this because of camera constraints allow this (fixed rotation). This effectively results in more objects to draw during the main camera rendering, but is much faster on CPU for our platform. We then proceed to render our planar reflection using the same cullingResults, but with different view/proj matrices. That also allows use to render multiple reflection planes without much CPU cost.

    I could see this idea propagate to splitscreen multiplayer rendering.

    Thoughts?
     
    ontrigger likes this.