Should I care about invisible meshs?

It is hypotethical question…

Supposing that I have eight cubes { 1f, 1f, 1f }, and it is forming a big “pseudo” cube { 2f, 2f, 2f }. These cubes have all six faces but, in general, it is not visible (the internal faces).

68401-cube.png

Illustration: keep in mind that the left cube is just to show how it is built. In general, it will be rendered like the right cube.

The question is: should I care about it? It can affect game performance/memory usage if, for instance, I have a lot of this big cubes (some thousands) vs. have only single big cubes?

My question is because I don’t know how graphic card (or some else) can optimize things like that.

well, without testing it: 1 big cube vs 27 small cubes (3x3):

  • memory usage:
    • mesh: the big cube has 8 vertices, aswell as each of the small cubes has, so your vertex buffer is 27 times larger.
    • components: in unity every object has a transform component, each of your cubes has a render component and each of them (could) have a collider, so this would also take 27 times more memory than a single cube

but i think you dont need to care much about memory usage if the factor is less then 1 big cube vs 100 mini-cubes

  • performance:
    • rendering: assuming all those cubes share the same material, there should not be much of a difference between 1 big cube and many mini cubes
    • collision: depends. if all those cubes should behave physical correct (are not static, are attracted by gravity and other forces, …) it will hit your performance hard.

you should make sure that the cubes dont collide with each other if they dont need to, and that as many static flags are set as possible

edit: to answer a bit more directly to your question about invisible faces: IIRC, stuff like backface-culling and occlusion-culling is done by the graphics card, so you’ll need the memory for all the vertices if they are visible or not. and even if most of your poligons dont need to be drawn (because they are invisible), you’ll atleast get a small performance hit because your front-face is also splittet.

it does not rly matter how large an object is. a 3meter x 3meter cube is rendered as fast as a 1 meter x 1 meter, and they use the same amount of memory.