0
\$\begingroup\$

I'm trying to have a camera automatically disable if it's not rendering anything.

Is there a simple way to check if a camera is blank/empty?

Edit: Alternatively, is there a way to prevent a camera from rendering if there is nothing in it's view?

  • For example, I do not want MSAA applied to a blank camera. (I'd hope it would attempt AA, but effectively do zero work)
\$\endgroup\$
  • \$\begingroup\$ What's the structure of your scene, that results in cameras unpredictably having nothing to render? A render of nothing should be very cheap — just a frustum culling pass, the same work you'd need to do to determine it's empty anyway — so are you sure this is the bottleneck in your game? \$\endgroup\$ – DMGregory Dec 30 '18 at 3:20
  • \$\begingroup\$ I'm testing on a low-end android, and the blank cameras are taking 2ms or so each to render. The cameras are used for temporary UIs and overlays. In case it matters, the sometimes-blank cameras have their Clear Flags set to "Depth only" \$\endgroup\$ – Tread Dec 30 '18 at 3:35
  • 2
    \$\begingroup\$ Then it seems like your UI state management logic should be able to handle turning them on & off, no? \$\endgroup\$ – DMGregory Dec 30 '18 at 3:38
  • \$\begingroup\$ That was my initial thought, but it wasn't going to be super easy to track when the overlays were finished (since external conditions determine how long they're needed). So, I thought I could just have the cameras themselves poll for being blank and disable themselves. \$\endgroup\$ – Tread Dec 30 '18 at 3:43
  • 1
    \$\begingroup\$ I think if you're concerned about performance, fixing this problem at its source will be the most efficient option. Want to try reframing your question as "How can I eliminate unnecessary rendering when changing UI states"? That way options to automatically disable cameras are still a valid answer, but so are state management strategies that will let you choreograph when to turn them on/off. \$\endgroup\$ – DMGregory Dec 30 '18 at 4:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.