- Home /
On combining two objects to reduce draw calls ...
Imagine you have two objects. Say, two different green sheds.
1 2 3 - They already use the same, identical, material. They are physically near each other. They never move or twist in relation to each other.
You think to yourself, "I'll go combine the meshes for optimisation."
In these circumstances, IS IT ALWAYS a good idea to manually remake it as one mesh? ie, to combine the meshes?
I guess I've always assumed the answer is yes. But ..? Any downsides to manually combining meshes in the example?
Note -- assume target is mobile, so probably just plain old Vertex Lit. If you are using fancy lighting, there is a gotchya described here ... RenderTech-ForwardRendering.html ... where it can be better to use mesh of smaller physical extent. Ignore that issue. In this question I mean only in ordinary, single-light situations.
Note 2 -- in the art of culling (whether camera, or occlusion) the shapes of your objects can be critical. I'm not referring to that issue here.
So in a sentence ...........
Is there ANY REASON AT ALL to not combine mesh (manually I mean), where you can?
So for example .....for all I know, the renderer prefers mesh of a certain size (just a wild example...) or maybe there is a difference on mobile, something relating to a shader or fog .. some aspect of rendering .. who knows?
Cheers!
The only things I would imagine would be a problem are:
the creation of an atlas that was wasteful - but I guess you say they are using the same material so that won't be a problem...
The inability to cull one or more of the objects because they would normally be occluded
Awesome -- thanks. It would appear that 4 out of 4 thinkers agree on this issue.
That has to be good enough for software engineering. Time for beer and $$anonymous$$iPads! :) Cheers!
Answer by liszto · Oct 31, 2012 at 11:00 PM
Yes I think you could do it. I do this by script in one of my project on an entire land cause this slice the draw call drastically if lot of separate static mesh use the same material/texture. The only way you mustn't is if your meshes are really large or if they are push them apart. In this second case, the engine gonna compute triangles which are not in the screen because for him it's the same mesh.
O$$anonymous$$ .. so you agree it's best and there's no real reason not to do it. So so far nobody has a reason not to do it ! :)
Just TBC ... in your example ... you say you do it on an entire "land"
Did you mean the "ground", "surface" ... in fact, just as you say, you probably would not have one mesh for a very large object If you mean the "ground" you probably would not do that right?
Indeed: say a racing game or similar. If you have a very large ground, say 10 hectares. Indeed, you would CUT IT UP, you generally cut up large terrains in to smaller pieces. You might have say 20 or 30 pieces, not one huge champs of 10 ha.
But i guess you just meant in your "whole project" right? (The whole imaginary world.) So for example what sort of things did you combine?
So, you combined two small buildings and so on ... right?
Again ... I don't think there's any reason NOT to do this.
(Other than one's occlusion strategy - I set aside that issue here.)
Answer by TurboHermit · Oct 31, 2012 at 12:42 PM
If you never use them separately... Ever, then I don't see a reason why you shouldn't. The only downside I can think of is that your texture will expand in dimensions, but if you use the same material with different uv, that is not a problem at all.
I know ^^ I just promote them or post them in answer state when I'm sure it's a good answer ^^
Answer by flaviusxvii · Nov 01, 2012 at 03:37 PM
You could contrive a scenario where the camera will frequently only see one of them at a time. In that case it makes sense to keep them separate, because the engine would be able to cull the shed that isn't in view.
Other wise it would end up processing the geometry for the hidden shed no matter what, until it knew it could discard the fragments.
But like I said, that's a contrived case.
Right -- exactly a good example. As I mention in the question, regarding CULLING you may sometimes want things to be separate, for specific culling reasons ... whether frustrum culling or occlusion culling.
But setting aside that issue ... is there some other gotchya? Example .....For all I know, the renderer prefers mesh of a certain size (who knows, just a wild example...) $$anonymous$$aybe there is a difference on mobile, something depending on shader .. who knows?
So far, 3 of 3 say it's never an issue :)