I’m working on a building project and I plan to make it a game model. I’ve been doing viz projects so far and making things efficient for game-engines has not been important, so I’m a bit lost here.
I read from the docs that “The best way to improve rendering performance is to combine objects together so each mesh has around 1500 or more triangles and uses only one Material for the entire mesh.”
Ok, but what exactly is a combined mesh in this document? Does it have to be connected, solid piece or just anything that’s connected into a single mesh?
In this particular project I have a big building with irregular walls and dozens of arched windows. In addition the windows have a sort of “lip” to keep the rain off them. Normally, in a viz project I would just add the edge loops necessary and extrude them right of the wall, but that would increase the polycount - inefficient, perhaps?
When doing this for Unity should I rather model those lips separately and combine them, thus saving 80 - 100 polygons?
What about the window panes? Another combined mesh containing all the panes (that would of course share material)
As the docs say, unless it’s being run on an intel graphics, or iphone. Polycount isn’t such a big deal (though obviously keeping it small as possible is still important) it’s the draw calls that are the big problem. As far as I understand it, a new draw call is made everytime an individual object is displayed. eg: a forest of tree’s would be a lot of draw calls, one for each tree. But if all those trees were combined, it would cut down the number of calls. I’m not sure how it works or why, just that less draw calls = better.
In your case, making all those windows part of the same object, combined in some way would work better than individual ones.
Also each material creates a new draw call too. So if each window had a different material, it wouldn’t help much to combine them.
Hopefully someone else can answer this much better than me.
I’m going to try to stick with those guides. I’m probably going to model those window lips separately anyway, because I realized they don’t really share the same texture as the walls anyway.
Well what you could do with regards those lips. I take it their texture isn’t that big or needs to be that detailed?
When you’re making your UV for the building, leave a space for a single lip’s UV, and have all those lips use the same UV space in the same UV1 shared with the walls. Which cuts it down to one material and texture for the walls and lips. You’ll probably be doing the same thing with the walls actually too.
When you come to do your lightmapping, that’ll hide the fact it’s all duplicated textures, and you’ve knocked off a few extra draw calls.
If you’ve got some space left in your texture, you might even be able to use it for a faint dirt/surface texture for your windows. You’ll still need a second material to handle your windows. But you’ll be using one less texture and I’m sure that’ll help in some way. Heck you could even reserve a space in that texture for a small blurry normal map (we’re talking real small at this point, not much space left lol), and depending on the shader you use, you could use that blurry normal map segment on an otherwise regular texture, to give some slight distortion to your glass surface. Which wouldn’t be a sharp edged detailed distortion anyway, more a kind of faint wavy warp look to it, which the small blurred mini normal map would provide.
I didn’t get the light mapping part, though. I though you should never share UV space when using light maps?
I’m not sure what the proper name for those “lips” is (English is not my first language), but here’s a shot of one window in the actual real-world building.
It’s not the best photo either, but it shows the brick pattern - so it’s pretty unforgiving in terms of detail. Of course, I’m not making a replica here, so I might cut myself some slack and simplify it a little.
Awesome idea that bump map for the glass, I sometimes go that far with my still images, but I can’t wait to try it in Unity.
That’s very true. But you use UV1 for your actual textures, and UV2 made up of polygons across the whole or large groups of models (depending on situation) and the lightmap goes in there and works as a single texture across a whole bunch of models, as you can allow for lower resolution per area than you’d want to for your actual textures. And of course, lightmaps > realtime lighting/shadows when it comes to optimization, quality, speed. And with careful use of color, avoiding baking obvious directional shadows they work just fine even in a day/night environment as well. Throw in some realtime lighting of course, and shadows being cast by the characters and such, and you can eventually get a nice mix of the two, which Unity does really nicely and Unity 3 will be even better at.
I reckon with careful UV mapping (a lot of your walls will be able to share the same texture, saving more space) you’ll have enough room left for texturing those parts of the window.
To break things up even more, and help hide obvious repeating effects, you can always make use of decal objects sitting close to the surface to add random details. Those will increase your draw calls of course, but with the other optimizations you’ll have freed up plenty to use for things like that.
BTW This draw call thing, too many is bad, but really it’s not as strict as I’m making it sound. Unless you’re developing for the iPhone or something, then I think it is really really REALLY low. If you make use of good occlusion culling and other tricks to hide what you don’t need until you need it. You’ll not have to worry too much.
Hehe yeah, I never even thought of that myself until I was playing Doom 3 the other night for the first time in years (and shocked at how good it still looks… now I got a PC that can play it properly, haha) and noticed little things like that, and the slight distortion the glass would often have. I was surprised, looking through the D3 assets, just how very simple and basic a lot of it is. But still looks great.
I forgot all about the second UV set! Must get some sleep before I continue
Fortunately, once I get around the windows, there isn’t much more to it. It’s a big building, but mainly it’s just repeating those same windows all over the walls, plus some simple square ones at its top floor. Even the doorways have that same arch-thingy.
Right you are, I checked out some screenshots from Doom 3, doesn’t look bad at all, especially when you take into account, that it’s from 2004! To be honest I don’t play enough games these days (almost none at all) - I should try some, at least in an educational sense
Hmm, I should take back some of what I suggested earlier. I had a quick glance through the forum and draw calls are based on materials rather than individual objects, or something, eh, confusing!
No, draw calls are based on individual objects. Unity 3 and Unity iPhone have dynamic batching in some cases (which is based on materials), but it’s not free, so often it’s better to statically combine objects.