x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Using Instanced Meshes doesn't reduce draw calls

Hi, there :

I had tried two methods to create instanced static meshes : First method, Create a Blueprint within only one component which is InstancedMeshComponent, and added an element in the property "Instances"; Second method, as first method which has only one InstancedMeshComponent, but write a construction script to Add Instance.

The result of two methods all shows that drawcalls are same as indivisual staticmeshes which are not instanced, which means that it didn't reduce drawcalls.

Did I do something wrong? or I missunderstand the meaning of InstancedStaticmeshComponent ?

Thanks.

Product Version: Not Selected
Tags:
method1.png (71.3 kB)
method2.png (69.6 kB)
more ▼

asked Nov 03 '14 at 09:14 AM in Rendering

avatar image

ZenTechEntertaiment
39 5 11 22

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

Hey ZenTechEntertinament -

Instanced meshes will reduce the draw call overhead on the CPU but will not reduce the GPU cost. In fact the GPU time can increase when using instancing. Allow me to get a little technical for a moment:

This process has to do with the limitations of the CPU vs. GPU and how the API (OpenGL or DirectX) tries to maximize this limitation through batching. Instancing being a special case of batching. With a scene rendered with many small or simple objects each with only a few triangles, the performance is entirely CPU-bound by the API; the GPU has no ability to increase it. More precisely, "the processing time on the CPU for the draw call is greater than the amount of time the GPU takes to actually draw the mesh, so the GPU is starved." [Moeller, Real Time Rendering, 708]. So Batching attempts to allow the CPU to combine a number of objects into a single API call. In the case of Instancing it is the one mesh and the number of times you are drawing with a separate data structure for holding information about each separate mesh.

From a Rendering Engineerer:

"On meshes and material IDs, let me present a hypothetical situation to try to explain the situation more clearly. Let's say you have a mesh that has three materials: wood, chrome, and leather. Now let's say you place 100 of these meshes in your level. Ignoring other passes (shadow, depth only), this will result in 300 draw calls: one per-ID, per-instance. You can see this by looking at the section counts in the primitive stats window.

First thing to keep in mind: some draw calls are more expensive than others. The renderer sorts by material. So in this hypothetical scene we will draw the 100 wood elements first, the 100 chrome elements next, and the 100 leather elements last. Once we draw a wood element, the cost of drawing another wood element is not so high because we are rendering using the same shader and with mostly the same textures. But once we switch materials to draw the chrome we incur a high cost. That's why the renderer sorts by material.

Compare that situation to another scene where you have the same mesh instanced 100 times but each mesh has its own unique material. The scene is still 300 draw calls but the renderer incurs the material switch cost for every draw call. Instancing a mesh provides performance benefits even if the total number of draw calls does not reflect that"

To really see the performance boost in using Instances bring up the Stat UNIT and watch the DRAW versus GPU (CPU vGPU) and notice when you instance a mesh the CPU time remains fairly consistent depending on the additional information you are wanting to pass to each instance, while the GPU will increase. All of these numbers are still dependent on the size of your mesh and the type of material setup and the ultimate limitations of your CPU and GPU.

Thank You

Eric Ketchum

more ▼

answered Nov 24 '14 at 03:50 PM

avatar image

Eric Ketchum ♦♦ STAFF
37.4k 700 234 721

avatar image ZenTechEntertaiment Nov 25 '14 at 03:09 AM

Very appreciate for your detailed explanation, I'll try it again.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Hey ZenTechEntertainment -

There actually is a draw call difference between a instanced static mesh and a normal static mesh setup. Here is some examples of what I mean. The Green Boxes are normal static meshes and the red boxes are all instances of the same mesh. The Material setup, which is also import to consider when dealing with draw calls, is a Master Material, green, and an Instance of that Material, red. The value you should be looking at specifically is the Static List Draw Calls.

Here you can see that it a value of 4 which is one material assigned to each mesh.

alt text

Here you can see that it has a value of 1 which is one material assigned to the master mesh and instanced out.

alt text

Here is the meshes all together and you can see it has a value of 5, the 4 individual meshes and the instanced set.

alt text

Hopefully that clarifies, but if not please feel free to ask -

Thank You

Eric Ketchum

meshdrawcall.jpg (148.0 kB)
totaldrawcall.jpg (163.1 kB)
more ▼

answered Nov 11 '14 at 03:56 PM

avatar image

Eric Ketchum ♦♦ STAFF
37.4k 700 234 721

avatar image ZenTechEntertaiment Nov 24 '14 at 10:15 AM

Hi, I have tested the instanced static mesh again. The Static list draw calls = 6 in an Empty Scene.( as shown in "emptyscene.png" ) The Static list draw calls = 7 when using Foliage System to place Staticmeshes.( as shown in "foliage.png" ) The Static list draw calls = 12 when using InstancedStaticMesh Component in Blueprint.( as shown in "InstancedStaticMeshComponent.png" )

Did I missunderstand any thing in InstancedStaticMesh Component?

Best regards.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question