# If a 3d surface is occluded by another 3d surface, does this have any effect on the performance and rendering speed?

We have a 3D character who is wearing a gauntlet on his forearm and visibility of which can be turned on and off. Would it be better to create two versions of arm, one without extra triangles that are hidden beneath the gauntlet? Or we can just one model with gauntlet as separate object which can be turned on and off ?

Does the hidden triangles have any effect on rendering or are they completely ignored by engine?

We are using Unity 3D.

• What engine are you talking about? You need to be bit more specific in order to get good answer.
– Katu
Mar 3 '16 at 13:48
• Are you only concerned about this 3D character wearing a Gauntlet or are you going to cull the triangles for every model ? Mar 3 '16 at 14:24
• We are using Unity 3d for this. We have multiple such 3d characters on which this will be applied. Mar 5 '16 at 5:22

My answer, much like Krom's, is that it depends.

In cases where you have large swaths of polygons being obstructed by another object, it's likely going to be a good idea to cull objects that are completely obscured. Suppose you are looking at a wall made of two triangles, and behind it are several objects composed of several thousand polygons. If you draw everything, you waste valuable GPU time. But by culling the objects behind the wall you can turn a draw call of thousands of polygons into a draw call of only two polygons. In this theoretical scenario, you likely would not see a massive difference in performance as a few thousand polygons is nothing to a GPU. However, when applied to larger scenes the performance gains can be quite significant.

On the inverse, and as is probably closer to your scenario, when dealing with a minute amount of polygons being obscured, while it may technically be slightly faster to draw a different model that has the obscured polygons removed, the gains will be minute, and almost definitely invisible. In addition, you will have to factor in the memory increase by loading in the alternate model. (Or models, assuming you have a different one for each area that can be obscured on your character)

Specifically, in your case, it's unlikely that culling the few polygons will do much for you, but it's always wise to do an A-B test to determine if that's true.

Generally, if you know your object will not be displayed, you should not send it to the graphics card.

Culling on the CPU removes some work to be done by the GPU.

For a few polygons, it's ok to send them (as Krom Stern suggests), but in my experience, if you start to do some few polygons here, and few polygons there, you can end up sending uselessly many polygons to the GPU, which will have to take the time to realize it does not need to work on it.

A good habit is thus to not send them.

• Which leads to game never being finished due to all efforts on optimizing non-bottleneck places. "Premature optimization" that is called. Mar 3 '16 at 17:11
• @KromStern I totally agree that the OP question smells like premature optimization. I very much doubt that the triangles below a character's gauntlet will make that much of a difference. Now, how on Earth can a basic good practice of avoiding to send unnecessary triangles to the GPU (in case it's easy to avoid) be seen as something even close to "premature optimization"?
– MAnd
Mar 3 '16 at 21:04
• @MAnd I assume OP is spending his (and ours) time on something very minor compared to the rest of the finished product that he needs. If performance ever becomes an issue, then profiling and optimizations are needed, in this order. Mar 4 '16 at 5:12
• @KromStern Yes, sure thing. But if you noticed, with that I agreed in the first sentence of my comment. My point was merely that some good practices are not per se optimization, much less premature. They are just good practices one would be better served if thinking of from the beginning. Designing code with having in mind the paradigm of avoiding unnecessary CPU or GPU burden is an example of such.
– MAnd
Mar 4 '16 at 5:28
• @MAnd There are much too many good practices, that following all of them at once will bring a novice to a halt. Case for a YAGNI in my humble opinion. Mar 4 '16 at 5:33

For a low-polygon textured model, generally speaking, having a few more triangles around its hand should not be an issue (performance wise). Of course it all depends of the sizes of your models but I'm guessing we are talking about sensible volumes here. If you have permanently attached the gauntlet to the hand and you switch its visibility on/off, then, when invisible, every engine that respects itself should NOT send its triangles to the GPU (or do anything with it anyway). If visible, then BOTH hand and gauntlet will be sent to the GPU (unless the gauntlet is big enough to cover the entire hand AND the hand mesh is a separate mesh from the rest of the model AND the engine supports such kind of culling).

So, yes, it depends of the situation, but for most scenarios I can thing of, performance should not be an issue.

That said, you should consider some other things apart the performance. Those are simplicity of implementation and expandability of the solution.

For example, if you are going to have just one character with just one gauntlet, it should be fairly easy for your modeler to create 2 versions of the hand. The benefit here is that you will avoid potential visual artifacts (they can happen) and it MAY be a simpler solution (especially in FPS situations where you only see the hands) If your case is that you may have many different characters that may wear many different types of gauntlet, you may need to attach the thing on the hand (to avoid creating endless combinations). If you already have a way to attach things to the character's hands (weapons, potions), it may be simpler to simply attach the gauntlet the same way.

Just saying...

It depends.

There is performance difference depending on fill-rate limitations, order in which polygons are drawn and early Z-test. If, for example, your engine renderer is fill-rate limited and you draw from far to near several times, accumulating layers, then each pass eats from you budget. This is why it is beneficial to draw opaque geometry from near to far, so that early Z-test can happen and skip the "expensive" repeating part. How it is happening in your exact engine, it's hard to tell, they are all quite different in such details.

Now there are some other more real problems that can be mitigated by keeping the model "clean":

• Z-fighting if those layers are very close to each other
• Polygon collisions/penetrations if those are skeletally animated with skinning
• Consistent AO, if you plan to have different AOs baked into the arm models

And drawbacks:

• Additional work to make and maintain now 2 models instead of one
• Additional code paths to support the switching of them