I desperately need some help. My levels are usually built with all vertices welded so that all transitions between the different features in the level are clean and there are no open edges. But I was told that everything that requires a special effect(such as reflection, mirror etc…) has to be a separate object. So that a window cannot be built integrated into the wall?! And the ceilings, floors and walls have to be separate objects?! In the past, I have worked with engines which use different smoothing group assignments to recognise which effect to use which i find very sensible. Another question is if there are open edges in the level, won’t that create cracks which show up in the game?
If everything has to be separated, it could be very messy. I’m also told that it is not possible to use multi/sub-object textures because then it’s not possible to apply the different effects. Before I start building my level, I would really appreciate any tips or tricks I also admit that I’m a bit puzzled about all this. Surely it should be more straight forward?
You can use multiple materials on a single object without problems. You can use different shaders in those different materials and so on.
However, some special effects in Unity (water and mirror reflections come to mind… and probably nothing else) are written to operate on a whole object. It’s possible to adapt them to operate on a specific sub-material of some object, just that does not come out of the box. So splitting whatever is needed into a separate object would be easier.
If you have an existing object and detach some parts of it into separate one (while keeping pivot point and object position/rotation/scale the same), then rendering will be exactly the same as rendering one object with multiple materials. That means no “cracks” will be visible.
Just to make sure, what “effects” you’re talking about in particular? Only planar reflections (water/mirror) come to my mind, anything else can be in the same object if you really want to.
…of course, putting the whole level into a single object can be not very good for performance if you’re using small pixel lights. The rule of thumb with pixel lights is that your objects should be roughly the size of the lights. Just so you know.
Well, I’m still trying to come to grip with Unity. And I’m not sure what you mean by my “objects should be roughly about the size of my lights”.
And what about having a lightmap for the level(a topic which I also have to read about!:()? Would that affect the performance if several rooms were joined together? Or do the rooms need to be separated by corridors to increase the performance?
Do you know if there’s a document anywhere explaining how to model a level suitable for Unity? What to avoid etc…?
Of course, lightmap everything you can. Lightmapping is always faster than using real dynamic lights.
Separating objects at least into room-sized ones will generally be faster - because if your whole level is a single object, then it has to be drawn in whole all the time. If you split it into some smaller ones, then the ones that are outside of the view don’t need to be drawn.
We have some documentation on graphics performance. Additionally, in a week or so presentations from Unite conference will be posted, Joachim did an extensive talk about performance and lightmapping there.
If you’re using dynamic (in-Unity) lights, and non-vertex-lit shaders, then several brightest lights on each object are drawn with per-pixel lighting. This allows using bumpmapping, light cookies, realtime shadows and whatnot, however it is quite expensive. Basically, each object is drawn once for each pixel light that shines on it.
So if you’ve got a small point light and a huge level object, this whole level object has to be drawn, even if point light is very small. Making objects the size of the room for example is a good idea (whereas making the whole dungeon a single object is not a good idea).
To answer your biiig question with a releative small answer…
A Unity Game Object Mesh renders best at 1.5k Polys+. Anything below that, will render at the same speed, so it is a waste of resources.
The less Game Objects the better.
Pixel lights are expensive, multiple materials as well. For each material and light an object has to be processed once. So use as less materials on a single object as possible. Use as less pixel lights as possible.
Combine lots of small textures to a large single one…
Combine Objects hit by the same light to a single one…
Use Mesh-Combine Scripts on movable but “sleeping” objects… just part them on wake, move them… when all gets quiet combine them again.
How you part your rooms and corridors and stuff is simply a design- and gameplay-question as well as an performance evaluation wich only you can do (with the above points). Thats up to you.
One thing i found very usefull is to build interior and exterior parts as different meshes and then place them on different layers in Unity. By doing so you can have different lighting inside and outside buildings for example.
That tip for interior and exterior areas is definitely going to come in handy!
I think I now get the idea of how I should build/split my level.
Would anyone know a good site for learning about lightmapping and texture baking in 3ds Max? I have found a couple of sites on this but I’m still confused about the process. So ideally something idiotproof would be great!
Sorry, I just looked at the docs posted on their site and it looks like they’ve done a revision and removed the tutorial I was thinking of. You may want to try downloading their demo and see if the tutorial is included with those files.