Jump to content
  • Advertisement
Sign in to follow this  
Fromfame

Unity Tips for keeping a graphics heavy game in 60fps?

This topic is 934 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys,

 

What tips do you have for maintaining 60fps for developing games that are graphically really heavy?

 

Here are the things i've tweaked:

- Lighting.

- Shadows.

- Camera Draw Distance.

- LOD.

 

There are 4 image effects which shape the look of the game that can't be sacrificed - but kept to a minimum:

  • SSAO x2
  • Color correction
  • Contrast Enhance

The game i'm developing holds in at 20 frames per second when exported to laptops with these specs:

 

  • OS: Windows 7 or 8 
  • Processor: Dual Core CPU @ 2.4 GHz 
  • Memory: 3 GB RAM 
  • Graphics: Nvidia GeForce GTX 280 / ATI Radeon HD 5830 
  • Storage: 2 GB available space 
  • Sound Card: DirectX 9.0c compatible

 

Here's a quick look at the graphics:

https://goo.gl/HGNi4f

https://goo.gl/8bKxaD

https://goo.gl/E72BWE

 

Unity based answers are preferred - however, i'm certain this is general knowledge that applies to any engine.

Edited by Fromfame

Share this post


Link to post
Share on other sites
Advertisement

This is a profiling question, so step 1 is always: take measurements.

+1


most people start with random tweaks when they want to improve performance. some "stupid" ideas turn out good, while others don't, but because there was never a profiling, you don't know why and neither if there was a simpler/smarter way.

profile profile profile.
once you see what is going on, it starts to become approachable.

Share this post


Link to post
Share on other sites

As other have said, for emphasis:

 

Step 1: Find your bottleneck... is it really the GPU? Unity is extremly Drawcall intensive (many objects get rendered in multiple draw calls even if a simple shader is used) -> this creates CPU bottlenecks, as the render thread is stuck on a single core.

 

Step 2: reduce the amount of draw calls if they are the problem (easy to find with the Unity profiler. If the CPU takes most time, most of the CPU cost is graphics, and you see like 4000 draw calls in the stats, that is your problem #1).

Combine meshes as much as you can. You can do it offline in a 3D Tool like Blender, you can write your own Unity tool to do it, or there are third party assets in the store if you can spend something to do it. Reduce the amount of non-batchable objects (moving objects for example).

Check your lights. If you are using multiple lights with shadows, they will contribute quite a lot to your draw calls.

 

Step 3: If the problem is on the GPU side, see if you are using multiple lights. If you are using a forward rendering path, you should use only a single main light, and go easy on additional lights as the forward path is really not made to handle multiple light sources.

Check your shadow settings. Realtime shadows are EXTREMLY expensive, especially if cast from multiple light sources. Disable shadows for objects that do not need them (too small, like grass or small rubble). Bake shadow maps and only activate realtime shadows for lights that do need them (the ones where it would look off if moving objects wouldn't cast a shadow)...

There are options to "fake" shadows for moving objects. If shadows play a big part in your game, you have a lot of moving objects, and you want to keep using Unity and its default renderer (other renderers available in the asset store CLAIM to use a different method to draw shadows that MIGHT be performing better), consider "cheating" and only using shadow maps and fake shadows (for example blob shadows, or decals) to give moving objects some shadows.

 

Step 4: aside from the graphics, consider other bottlenecks. Are you Instanciating stuff? DON'T! EVER! Write object pools, instantiate at startup, and the recycle everything. Never, ever instanciate stuff during a running game. I have found that among rendering a massive amount of instanciated meshes with physics rigidbodys causing FPS dips, the instanciating was the big problem... not the meshes or drawcalls (seems the 100 or so objects didn't make too much of a difference as soon as I made sure they do not cast shadows), not the physics (seems PhysX can handle 100 rigidbodys just well on the single thread it was running on). Instanciating and destroying was the culprit. Once I started using an object pool and only deactivated and moved objects before reactiving them again, instead of FPS going down to 20-ish from the normal 35 FPS (yes, the game was not well optimized at the time), it just dipped 1-2 FPS for all the objects flying around (I did additional steps to limit the amount of rigidbodys at any time, but this is besides the topic).

 

I repeat: Never, ever instanciate or destroy anything during game runtime.

 

Step 5: Really think about if the weedy laptop you are using there should be minimum or recommended hardware. If it is minimum, maybe lower graphics settings.

 

Step 6: Just to reiterate Tangetails point: make sure there is culling going on. Without using Umbrella Occlusion Culling, Unity will always render everything. If you are using a large level, you might be rendering like 100's of rooms hidden by the wall in front of you. Worst case you built the level from components (with every wall being its own object), and didn't batch them. That might be 1000's of drawcalls just for looking at a wall! Not to mention all the lights and shadows not being culled.

 

Easiest way to spot such issues is to turn around in a fairly empty room. If the FPS/Drawcall/other stats vary wildly depending which direction you turn too, while the visible geometry stays more or less the same in complexity, you are not properly culling.

Edited by Gian-Reto

Share this post


Link to post
Share on other sites
My few cents:
- profiling, as mentioned
- don't draw what you don't see
- don't try to develop specific components which others can do better
- reuse data where possible
- use the right components for the right tasks (CPU, GPU, types of memory etc)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!