2

I have a pretty large and full scene and therefore gets a lot of draw calls.

Sometimes I display a video in the game, which covers the entire screen. When I tested my game with Unity's profiler tool I noticed that the camera still renders everything (although occlusion culling is enabled and calculated), and it causes the video to lag.

My question is how can I disable the camera?

When I disable the Camera component or the camera's GameObject I get a warning ⚠ in the game view that says No camera is rendering to this display. Which, I guess, is not good (correct me if I'm wrong).

So I was wondering if cancelling the culling mask on the camera (by setting it to Nothing) would force unity to stop render the scene. Or does it still do some work in the background? (Like with UI elements that still being rendered even though they are fully transparent).

Thanks in advance

BPDESILVA
  • 2,040
  • 5
  • 15
  • 35
SagiZiv
  • 932
  • 1
  • 16
  • 38

1 Answers1

3

I have a pretty large and full scene and therefore gets a lot of draw calls.

I recommend activating "Instancing" on your materials, it can greatly reduce draw calls.

When the UI Pops open, it can help removing the "Default" layer (or whatever layer the majority of your renderers are) from the active cameras. You can do this easily with layer masks. Or you can just set Camera.main.farClippingPlane to 1 or any low number.

Mika
  • 66
  • 5
  • Thank you, do you have a link that explains "Instancing", because I never used it. And I would definitely try to set the layer mask when I display the video. – SagiZiv Jun 28 '19 at 08:59
  • 1
    https://docs.unity3d.com/Manual/GPUInstancing.html It's a simple tap on the material you are using. You can define two LayerMask's in your class, like "public LayerMask UIOpen; public LayerMask UIClosed" and then swap between them. LayerMask is seen in the inspector so you can just tap the layers for each mask. – Mika Jun 28 '19 at 10:08
  • I haven't tested this, but setting Camera.main.clearFlags = CameraClearFlags.Nothing; should leave you with the last frame that you have rendered, In case you have UI Elements that are transparent, this could be a cool effect. I'm not sure if this works properly though. – Mika Jun 28 '19 at 10:14
  • Wow, thank you for the great response. This is exactly what I was looking for. Turning instancing on really reduced my draw calls quite a bit, and the LayerMask solution works great. Haven't tried the clear flags solution yet, but will as soon as I can – SagiZiv Jun 28 '19 at 10:32