- Home /
Performance impact of camera that has 'nothing' culling mask and doesn't clear anything?
I need to create a gameobject with a camera attached to it, the camera has to be enabled and have its depth set to '100' but besides those two things it doesn't need to do anything at all.
If I set the clear flags to 'don't clear' and the culling mask to 'nothing' will this mean it has no performance impact asf ar as rendering goes?
That would very much depend on how Unity implemented it, and I'd imagine that's not a use case they had in $$anonymous$$d, so if it is very efficient as you hope, then it's probably by luck.
But the best way to get an answer would be to do some testing. Create a prefab of such a camera, and instantiate a few hundred of those in a script, and see how it affects the framerate.
You may want to compare it to creating the same amount of empty gameobjects (without a camera) to see the specific performance impact of the camera itself.
BTW, I'm assu$$anonymous$$g you'd need to use the camera once in a while for ScreenToWorldPoint, or something like that (otherwise you wouldn't put it there at all...) so consider disabling the camera component, and only enabling it when you need to, ins$$anonymous$$d of playing with the culling and clear flags. Disabling a component is something that is designed to improve performance among other things.
Answer by Bunny83 · Nov 24, 2013 at 03:03 PM
Well, the performance impact of the "concept" of a camera is relatively low. A camera is literally just a transformation matrix (the Transform component) and a projection matrix (in the camera component itself). If you don't clear and don't draw any geometry with it, it literally does nothing beside some setup overhead. It might go through all renderers to check the layermask, but if nothing is used it's probably skipping this. Even if not that's nothing to worry about. In comparison to your actual camera it's workload is probably way below 1%
May i ask why the camera has to be active? Even disabled cameras can be used for rendering by calling the Render function manually. Since your camera does nothing i don't see the reason why it should be enabled? Some insight on the purpose?
edit
If you might just want an OnRender callback or something like that, just use OnGUI!
The repaint event is always invoked after all cameras have finished rendering. So it'S the perfect place to do some post rendering stuff. You can even render (disabled) cameras there manually which i did quite often ;)
I am seeing a large performance issue caused by camera culling for a second camera that only renders one object. The second camera is used for a special effect and has only one object in an "effect" layer.
Performance tests indicate that Unity is doing an expensive camera culling operation behind the scenes BEFORE checking the layer culling mask of the second camera for the "effect" layer. That is, it appears to be perfor$$anonymous$$g frustum culling or other expensive filtering on objects that are not even in the layer the second camera is rendering!
Behind the scenes I'd like the camera to simply hold a list of the objects in it's layer and only perform frustum culling on those objects. In my case it would be even higher performance if the camera did no frustum culling at all and simply rendered the objects in it's layer (I already know they all need to be rendered).
Does anyone know a way to set up a camera to avoid frustum culling checks for objects that are not in the camera's layer(s)?
Your answer
Follow this Question
Related Questions
camera.layerCullDistances not working on gameobject with combinechildren 1 Answer
What are the performance issue of using multiple camera in layers (Mobile) 0 Answers
Camera Follow Code Causes Jerky Movements 2 Answers
When do shaders compute? 1 Answer
Second camera in editor causes flicker/judder/lag in VR image. 0 Answers