0
\$\begingroup\$

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.

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

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.

\$\endgroup\$
2
\$\begingroup\$

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.

\$\endgroup\$
  • \$\begingroup\$ Which leads to game never being finished due to all efforts on optimizing non-bottleneck places. "Premature optimization" that is called. \$\endgroup\$ – Kromster Mar 3 '16 at 17:11
  • \$\begingroup\$ @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"? \$\endgroup\$ – MAnd Mar 3 '16 at 21:04
  • \$\begingroup\$ @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. \$\endgroup\$ – Kromster Mar 4 '16 at 5:12
  • \$\begingroup\$ @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. \$\endgroup\$ – MAnd Mar 4 '16 at 5:28
  • \$\begingroup\$ @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. \$\endgroup\$ – Kromster Mar 4 '16 at 5:33
2
\$\begingroup\$

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...

\$\endgroup\$
2
\$\begingroup\$

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
  • Additional time to load and memory to use for 2 models instead of one

Answering your original question - best option is to test and measure performance differences. Likely they are minimal, compared to all the rest game does, a few hundred polygons is next to nothing.

\$\endgroup\$
  • \$\begingroup\$ Thanks a lot Krom. Yes triangles in question are not much. I was just wondering what good practices are while tackling such things, what widely used workflows are. You are right that it will really be a hassle in creating 2 models for each character. \$\endgroup\$ – Gaurav Rawat Mar 5 '16 at 6:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.