Say I’m building a level, and I decide to repeatedly copy/paste a particular piece of level geometry over and over again to make it easier on myself. Would this have a negative effect on the computer’s performance? The reason I ask is because TheNewBoston, a popular programming tutorial maker, claims that these things called “Static Meshes” can be re-used again and again and again without too much extra work for the graphics card. The specific video that he says this in is: Unreal Development Kit UDK Tutorial - 29 - Introduction to Static Meshes - YouTube (skip to about 5:35)
What I want to know is: does Unity have something that is equivalent to UDK’s “Static Meshes”? Or are Unity’s meshes already technically “static” by default? If such a thing does not exist in Unity, then is there some kind of add-on for Unity that adds it? Thanks in advance!
You are probably referring to the concept of batching draw calls. Unity can do this in a couple ways:
See: Unity - Manual: Draw call batching
In the case of static objects, this would be Static Batching. It is not on by default, but you just need to click the Static checkbox in the inspector.
For the simple case: Does copying a mesh incur significant memory overhead?
No. Go ahead and make copies of your mesh. It will most likely reuse your mesh. But keep reading for the exceptions:
However, if you have static batching enabled and if your meshes are static, then it means that the vertex data will be baked together to a single mesh. This means that it will use more memory, but it does this to render faster. It is not a good idea to make everything staticly batched since this could completely blow away your free RAM.
Another however; if you make copies of your mesh and they are not static, everything is nice and fine until you set a non-uniform scale on some of the objects. That is, if you have a tree model and make a forest of trees, you might want to make them look a little bit different so you rotate them a little and scale them a little and that’s fine, but if you scale them non-uniformly for example to (2, 2, 2.4), then Unity will generate a new mesh for performance reasons. This has to do with normals on the models, where non uniform scales mess with normals. It would be possible to handle this in a shader but that shader would become complex and slow and instead another Mesh is used, trading memory for runtime performance. Uniformly scaled meshes are no problem since we can just update a shader property with the uniform scale.
To put it simple: Scale 1, 1, 1 is fine. 2, 2, 2 is fine. 3.57, 3.57, 3.57 is fine. 1, 2, 3 is not (well it’s fine, but you should keep in mind that the mesh will be duplicated in memory).