- Home /
A theory / question about improving game performance
Hello friends,
It could probably be said that this might be better off in the forums, and I'm not opposed to that. Perusing them, however, I couldn't exactly figure out WHERE to put this topic, so I thought I'd post it in answers. Hope I'm not clogging up the place with it. So, this has to do with performance. I noticed after adding different models, textures, etc. that my framerate went way down, while my drawcalls and tris went skyrocketing. Ok, no problem. A little google search taught me about the "Combine Children" script. Always wondered what that was. Used it, and life seemed good.
For a moment.
Performance improved dramatically, but then I noticed that many of my combined meshes just plain weren't showing up anymore. I've read up on this, I see it's an issue that's been addressed, and while I haven't found a unified single answer, I know that the topic's been covered enough to not warrant one more noob asking about it.
So believe it or not, I'm not asking how to fix it. Not right now. Instead, I'm going to ask for opinions on a workaround that I've thought up. It's dawned on me that I might be drawing things unnecessarily in my game. For instance: let's say the town of bogville is 20 miles away from the spooky forest. Yet the spooky forest is still active on my map when I walk into the town of bogville. Would I save drawcalls, save on performance if I just put an invisible box collider nearer to the spooky forest which would activate / deactive it when the player is close? I suppose I could do this with any models that were collected in a gameobject throughout the game, my question is just would this be a way (good, bad, or ugly is irrelevant right now, I just am thinking proof of concept) of improving performance? Thanks, and God bless.
Answer by Statement · Dec 10, 2013 at 11:58 PM
For instance: let's say the town of bogville is 20 miles away from the spooky forest. Yet the spooky forest is still active on my map when I walk into the town of bogville. Would I save drawcalls, save on performance if I just put an invisible box collider nearer to the spooky forest which would activate / deactive it when the player is close?
You can toggle renderers on and off, yes. This should improve performance since Unity doesn't have to cull objects and since Unity doesn't have to render them (in case your frustum is super big, like the 1 KM frustum that is default with Unity).
I suppose I could do this with any models that were collected in a gameobject throughout the game, my question is just would this be a way (good, bad, or ugly is irrelevant right now, I just am thinking proof of concept) of improving performance? Thanks, and God bless.
It's a good thing to do. You can also use occlusion culling if you have Unity Pro.
Other things that may or may not be obvious is your render mode (try switching between deferred and forward) and try disabling lights (maybe you have too many dynamic lights). Use light mapping and light probes. Also check the number of materials you use, and make sure you actually use the same materials and don't do things like setting the color individually per item. For dynamic batching, you should not [non-uniformly] scale your objects. Everything that is staticly batched must not change.
$$anonymous$$ake changes, observe draw calls. See what gives the most bang for the buck. Try disabling all scripts in one copy of the level and see if that improves drawcalls (you may be messing with materials or changing transforms)
I appreciate that Statement, thanks. Am playing around with enabling / disabling gameobjects automatically now, and it seems to be giving me several fps performance boost.
EDIT - Additionally, I owe you one. I had no idea about what the rendering path was on my camera. Changing to forward gave me a three fold increase in rendering performance with a very acceptable downgrade in visual performance. Thanks!
There's a lot of options in quality settings too. Like you may be able to reduce shadow distance if you use shadows or lightmaps (dual lightmaps use the shadow distance to blend between realtime lighting and baked lighting for instance)
Statement, your advice has been incredibly valuable in increasing the performance output of my game :)
Great! (Graphics) Optimization is such a broad topic so it's hard to tell where to start in many cases. I'm glad you see a great increase in your app, but I'll throw in some more info in case someone else is stuck too and the limited info in the answer was poor help.
Using the statistics window and especially the profiler is a good step if you suddenly find yourself running short of juice. Even if you feel lost at using these tools, you could see what happens if you try to:
Turn off all real time shadows. $$anonymous$$aybe you've got too many lights that cast shadows, too many shadow casters or too many shadow collectors, or too far shadow distance?
Turn off all real time lights. $$anonymous$$aybe you have too many lights and should use lightmapping and/or light probes?
Swap out all materials to use a single material. Problems are likely inability to use batching or having multiple materials (will increase draw calls and possibly overdraw).
Swap out all shaders to use a $$anonymous$$imal shader. Problems are likely too complex shaders, too many passes in shaders, use of expensive operations etc. Other problems may be that you are rendering too many triangles with these shaders, or too big area of the screen with these shaders, or too much overdraw with these shaders.
Turn off cameras (if you have multiple) one by one. $$anonymous$$aybe you have items in a special layer that somehow causes a lot of issues? $$anonymous$$aybe you have too many active cameras that need to do frustum/occlusion culling (once per cam)?
Turn off all cameras. Still running slow? It's probably not graphics but your scripts or something else like physics or animation (if set to animate off screen) that is bottlenecking - check the profiler!