[Developer question/Engine] Unity + Instanced Rendering (Gfx optimization)?

Hey guys, I’ve looked around, but couldn’t find a clear answer to this:

-Is Unity sending 3D objects into the GPU optimized for instanced rendering?

Let me elaborate a bit:

-Suppose I have a 3D model “Car”, which has Texture, Mesh, Scale, Position and Rotation. That model is a prefab.

-Now, on my scene I have Car1, Car2, Car3 … Car30, which are editor instances of that prefab.

My question is:

When Unity sends these objects to the GPU, does he tell the GPU:

A) Get the Car object (Mesh + Texture) and render it on the position + rotation of Car1, Car2, Car3…Car30 instances?

OR

B) render Car1 (Mesh+Texture+Position, etc.), then Car2, then Car3, etc.?

I’m asking because I have some GFX optimizations that need to be done and I’m under the impression that the situation on case A, would actually allow me to render a whole bunch of identical objects in 1 draw call, while B would take 30 draw calls (one per object), since each one would be treated like a different entity.

I’m asking this, because while it seems that Unity does apply some layer of optimization on it’s primitives, I get the impression that when it comes to imported models, he treats each prefab instance as “complete” object and not like a repositioning of a existing one.

Is this assumption correct, or does Unity optimizes everything pre-render? I’m asking this to avoid doing redundant work e.g re-inventing the wheel :slight_smile:

Thanks in advance for the time and for the help!

No Unity devs out there that can help out? Or am I missing something really basic that makes my question irrelevant?

What you’re describing is batching. Unity has implementations of Static and Dynamic batching, each with their own caveats. You can find a more in depth article about batching in Unity here.

check this talk also (about instancing at 33min)

1 Like

Thanks for the help guys! I’ll take a look at the video and to the article :wink:

Unity is going instanced over time. First signs will be with speedtree etc, then it’ll roll out to other areas. I guess.