Performance Question

Hey guys,

So if I have a long corridor with several lights on it, like such:

In a prior engine I was using, it was better for performance to break up long walls like this into a series of smaller objects (because each light that hits the wall causes it to be redrawn a couple of times). So that is what I’ve been doing. But is that better in Unity? Or should I just keep the long walls/floors/ceilings as one object (keeping in mind I will eventually be baking lightmaps once I complete the texturing)?

Lights will still redraw every object that has a normal map or requirement for pixel lights and you’re not using vertex lights. So basically to avoid the problem without using chunks means you need new shaders and vertex lights only or even better look into using unity’s light probes.

I’ve found Unity likes larger grouped meshes as opposed to lots of little meshes but that is very contrary to having dynamic lights as they do redraw or at least recalculate lighting based on mesh vertexes. So there will be a larger performance hit on larger meshes during lighting calculations. From one of the Unity presentation videos (I forget the specific one) it was recommended to keep your combined meshes within the size of the light area. So if you’ve got a few little meshes that would fall inside the lit area you’re likely better off combining those into a single mesh. It was also stated that if you went too far with combining you’d run into the performance issue of running the calc on areas that wouldn’t be lit anyways.

It really comes down to your specific scene layout. If you’ve not got dynamic lights and will be using a baked light map then combine if possible. Thankfully unity provides the CombineMesh script so you can test the performance either way without having to redo individual meshes. Setup your scene with the collection of wall bits parented by an object with the CombineMesh script and you can test both with the click of a button.

“The above is my own personal (layman) opinion and not necessarily bases on any specific testing or best practices. Your mileage may vary.”

Edit : The Unity video that I referred to was from the 2007 Unite Performance Optimization video at http://unity3d.com/unite/archive/2007 some of the information from that video is a bit out of date in terms of some specifics (generating light maps : video says not available but now it is) but might help shed some light (pun intended) on the issue.

Thanks guys,

Thanks especially BPP for the link to the video. I watched the first 5 minutes, and just from that I can tell I will learn a lot from it. I’m about to sit down and watch over the entire thing. Actually, I probably ought to go over all of the archived videos and watch over any I think might be useful. Thanks for the resource!

I did try and check the performance of one mesh verses several, but it’s difficult to tell a real difference with just one wall (or even one corridor). I’d probably have to do a large chunk of the level both ways to see a real difference and figure out which is better.

Hippo: I don’t think I want to use vertex lighting. Mine is a desktop game and I don’t think that flies these days :slight_smile: (except on mobile platforms, of course). I guess I could set up a low quality setting that uses vertex lighting (I think, is that an option, to change the rendering path? I don’t remember seeing that, I’ll check into it). Also, I’ll take another look at light probes, thanks for the suggestion.