AFAIK frustum culling on Unity happens on a per GameObject basis. If a GameObject mesh is subdivided in several submeshes, the bounding box used for the culling contains all the submesh, am I right?
Now I was wondering what happens, when I don’t have GameObject and manually draw Mesh using GraphicDraw.Mesh.
Consider the following snippet, where mesh contains several submeshes:
void Update()
{
for (int index = 0 ; index < packedMesh.subMeshCount; ++index)
{
Graphics.DrawMesh(packedMesh, Vector3.zero, Quaternion.identity, material, layer, null, index, property);
}
}
Does DrawMesh handle frustum culling?
If the submesh drawn is outside the view frustum, will it be culled off ?
“Note that DrawMesh does not draw the mesh immediately; it merely “submits” it for rendering. The mesh will be rendered as part of normal rendering process.” That suggests it’s subject to frustum culling.
Ok, I understood that. But since I’m not submitting a mesh, but a submesh, does the submesh will be considered individually during the culling, or it has to be considered still a part of the main Mesh?
I’ll illustrate a little bit more the context. I’m rendering hundreds of 3D building meshes.
Each mesh will share the same sharedMaterial, but I need to modify a few parameters before each draw call.
I initially was planning to use StaticBatchingUtility to pack all my building meshes, since they can use a single shared material. Unfortunately it seems that I can’t modify a parameter of a material just before a draw call of a mesh packed using StaticBatchingUtility (or at least I don’t know how).
So I moved to drawing each mesh individually, using MaterialPropertyBlock to hold the few modified parameters.
I’d like to achieve the same result as using StaticBatchUtility.Combine method:
]
to do that I’d like to use a single mesh for all my building. Each building assigned to a submesh. But if the engine won’t cull submeshes, that’s a serious problem.