Optimization questions

The project I’m currently on suffers from there only being one of me to keep an eye on artists. Since I got here, I’ve been nose to the grindstone trying to get the character pipeline solid. Lots of other things have come up, issues with co-workers got in the way, the usual, right? Now I’m finally getting around to trying to fix and clean up our environment art and I’m, well… terrified.

What I’ve come across so far is multiple copies of materials with no actual difference, multiple exports containing the same geometry and no way to verify that every reference is pointing to one instance of that geometry, insane numbers of multi-/sub-objects in a single export, etc… I have questions.

I have a pretty good grasp on how real-time rendering works, and specifically how it works within the version of Unity that we’re working with. What I lack is heavy experience in optimizing what other people have made. My inclination is to split out all the duplicated geometry and export a single copy of each, then export out whatever small differences exist as individual objects that can be combined at run-time to make variations on a theme. For example:

My environmental artist made two tents. The tent geometry and texture set are about 90% identical between the two. One tent has a banner on it, as well as a squared roof decoration. The other has no banner and pointed roof decorations. The 10% difference in the texture is just the roof decoration.

I want to tear the tents into bits; the main tent becomes its own object, the decorations each become an object, and the banner becomes an object. This also means I need to redo the textures so that the decorations can be pulled out into a separate - though much smaller - texture set.

This is what makes sense to me, but I’m struggling with is that I’ll be essentially making more objects, more materials, more textures, and more draw calls out of this process. There’s never more than a handful of tents in a given space, so I fear my savings will be fairly small even once batching gets involved. However, it gives me more options down the road for re-use now that the tent is in smaller, more logical components. Also worrying is that this is a pair of tents giving me pause, and the rest of the environment assets look much the same with duplicated geometry baked in instead of heavily instanced. I’m feeling pretty swamped with the sheer enormity of what it looks to me like extremely necessary busy work and I’m coming to you guys for some kind of sanity check.

Am I insane to be considering this?

We have performance issues in our game already with thousands of draw calls happening in cities and settlements and we’re bumping up against 4GB of RAM used at run-time. Batching in Unity usually involves increased RAM usage, but my assumption is that I’ll see savings after reducing the number of copied-not-instanced objects in the scene. I should also see a dramatic decrease in draw calls once I have fewer copies of materials and turn static batching back on… but I won’t be able to see any of that until I’ve already done weeks of clean-up work. What if I’m just wrong and none of the work I’m laying out in front of me gets the performance boosts I’m expecting? Turning on static batching in the past actually killed our frame rates, but that’s because there was almost nothing to batch; there was not enough savings for the amount of overhead involved in testing the scene for batching, I guess.

Help?

the crappy answer is, it really depends on the game/level you are making.

the last game I shipped was a side-scroller, so we didn’t really care that much about instancing… we exported the entire level as one big piece of content that was segmented post-export into sections that could be rendered efficiently. now we are making a different type of game, so we are relying more on instancing and kits.

our engine has multiple graphs so we can measure the CPU/GPU balance. often we make decisions per-level to shift the load.

Yeah, the only true answer is ‘it depends’. A long talk with your engineers beats a lot of theorizing; testing beats a guessing. It’s too bad that the project is far along without good content guidelines but figuring out what the guidelines ought to be is job #1 – if nobody knows how to make good content it’s a certainty you’ll have problems. The Unity Profiler can be a big help, so can logging tools.

Only after you’ve gotten a good, evidence-based idea of where your bottlenecks are then you should start trolling the content to look for possible optimzations and upgrades. If the situation is really dire you should make sure that somebody with the political clout to get the whole team in on the fix is aware of the issues and willing to make everybody pitch in. As a TA you can do a lot of behind the scenes magic to make things better but many optimizations will demand a human being in the drivers seat. Pulling the whole team off of making new content and getting them to help fix the old content is a good way to really teach everybody what the good stuff looks like. In an ideal wold you’ll know enough by the time this happens that you can be useful to your teammates with advice, training and tools.

Automate what you can and get the production artists in on what you can’t.