- Home /
Low framerate with culling mask set to nothing?
So at the moment all my game does is generate a world of tiles and objects, all in 2D (everything being quads with no colliders placed beside or on top of each other). I set the culling mask on the camera to nothing so that nothing is rendered and I got these stats in two separate cases.
10x10x9 world (~950 GameObjects)
200x200x9 world (~380,000 GameObjects)
I guess I'm not really sure why the framerate is dropping so low when nothing is being rendered on the screen. These stats are after the entire world has been generated and the only script utilizing update() is simply checking for basic keyboard input and nothing else. Is the amount of GameObjects slowing it down this much? If so that won't be welcome news considering there's no way I can think of minimizing the GameObject count, and I was hoping to increase it.
Card name: NVIDIA GeForce GTX 560
Memory: 8192MB RAM
Processor: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz (4 CPUs), ~3.8GHz
Operating System: Windows 7 Home Premium 64-bit
are you sure you aren't rendering the objects?
afaik if you can see them in editor you are rendering them in play mode if you see them or not.
only if the rendering mesh is disabled than you aren't rendering the objects
that feature comes with the Unity pro that you aren't rendering anything else than only stuff that can be seen with camera and AFAI$$anonymous$$ you need to add some behaviour script, ... but I'm not very knowledgable as I'm on Unity free my self
I'm fairly certain using the camera's culling mask to only render certain things is available on Unity Free. As you can see on the statistics the Draw Calls are down to 1, but if I set the culling mask back to everything it shoots up as it is now rendering the objects.
I can't actually see the objects in the editor since the world is generated by script at the start of the scene, but from the draw calls I'm fairly sure the objects are not being rendered. I could be wrong though as I just started using culling masks and layers.
did you try by only deactivating all prefabs mesh renderer?
and all those objects are kinematic right?
I kinda remember having my infinity game where I first had everything rendered and more I opened about 200k objects more it slowed down and when I started deactivating rendering it speed up
I disabled the renderer on all GameObjects on start() and even then the FPS is still around 10. None of these GameObjects have any physics components.
So they're definitely not rendering, so the only thing I can think of to explain the low FPS is the large amount of GameObjects but it doesn't really make sense how that would lower my FPS so much. Large amounts of GameObjects is vital for my game so I hope this isn't the case.
http://answers.unity3d.com/questions/408298/max-number-of-gameobjects-5000-1.html
Framerate is not decided entirely by the graphical components. Having 380k Update functions to process will be demanding even if there is nothing in them. Even without scripts, trying to keep a handle on that many objects will take some time.
If each of those objects has a collider, that's 380k objects entered into a physics routine, which is far more demanding. This will of course, cause a hang.
Go through the camera culling one by one and see if any individual entry improves the situation, if you think that is what the problem is.
hmmm, ... what @Eric5h5 said is you should parent some of the objects
like making 20 general parents and in their parents 10 children and after that all other game objects, ...
sounds reasonable, ...
in my labyrinth I had 1 parent having around 20 - 40 children
and all that parents were grouped in 1 parent
well it was easyer for me to manipulate all the game objects, ...
I've just been reading just out of curiosity and found a strange thing I've never saw before ScriptableObject says with it it's possible to create about 2.5$$anonymous$$ objects before unity crashes, ...
going to make a Q about that
my curiosity made me make a Q
Sounds ideal :D
However if it said 2.5$$anonymous$$ objects before FPS drops < 30, it would be workable :D
Don't forget there are many many many other factors/game elements that also require a chunk of the ~0.0333 frametime.
If a 'game' is dragging on FPS only considering gameobject count there is no hope for an optimised Complete game.
That said, it would be very interesting to learn more of what Eric says on the matter :)
Answer by Cains · Oct 28, 2013 at 09:29 PM
The amount of GameObjects (380,000) was indeed slowing the FPS to a crawl, even though the GameObjects had empty update() scripts running between frames.
By making only a couple hundred GameObjects with custom meshes that hold thousands of tiles the FPS is significantly increased, well into thousands of frames per seconds compared to around ten. Creating custom meshes that hold many objects is definitely the way to go for procedural generation, at least in my case.
Unity's tutorial here got me going pretty quickly.
Your answer
Follow this Question
Related Questions
Android lag 1 Answer
How to render severals cameras at differents Frame Rate ? 2 Answers
Fast line rendering in 2D/3D 0 Answers