Home Unreal Engine

What are the drawbacks of grouped draw calls?

Zablorg
polycounter lvl 6
Offline / Send Message
Zablorg polycounter lvl 6
I'm not really at a point where I can experiment with this myself, but something I hear consistently is that you can yield optimization benefits in the engine by grouping objects together into a single draw call.

To me this raises the question of: taking this to the limit, if you grouped absolutely everything you've got into a singular draw call, what would the consequences be?

I'm not fully across the ins and outs of draw calls in the first place, but I'm guessing it would mean that absolutely everything would be forced to be drawn behind the scenes whether you're looking at it or not, which sounds bad. Is the optimal approach for to make draw call groups out of objects a player is likely to be simultaneously looking at, i.e. the objects in a particular room?

Replies

  • poopipe
    Offline / Send Message
    poopipe grand marshal polycounter
    I'm no expert but... 

    The main drawback I think would be that everything had to use one base level material so if you wanted things like alpha sorting or skinning it'd have to be done to everything (whether it was actually used or not) 

    You can still cull objects prior to them being rendered and you can use different textures on objects (with texture arrays)

    Theres plenty of  lower level stuff to do with how data is organised and passed around  that I don't understand - some of it may mean it's impossible to do everything in one hit. 
  • PatrickSF
    Offline / Send Message
    PatrickSF triangle
    One good example for merging objects is a segmented wall in a modular environment. When separate, the swarm agent building the lighting will light them as if they are separate, unrelated objects. This can create seams in the finished bake. Merging them will allow the lightmass to treat it like one object. But this will force it to use one light map for the entire set of walls so you'd then have to up the light map resolution for that new merged object in some cases.

    It really depends on a situation by situation basis.
  • rymbrant
    Offline / Send Message
    rymbrant polycounter lvl 4
    Some bad parts of combining assets:

    1. Less freedom of reuse.  It makes the asset more specific and less re-usable.
    2. Usually takes more time to make, requires rebaking from source assets each time it needs to change.  Imagine you baked an entire house into a single giant draw call and saw a problem with a trash can.  You make your 5 minute trash can fix then have to rebake the entire asset as well as all other pre-combined assets that have that trash can (hope you remember them all).
    3. Even though you reduced CPU time making less draw calls you have now created a lot more GPU work in the vertex shader.  Any objects not on screen are typically ignored and not rendered for efficiency.  While there are a number of caveats, this mostly means if it is behind your camera the game doesn't have to bother with it BUT the ENTIRE object must be out of the camera's view, not just the center.   So if even one vertex of your object is in view the GPU has to iterate through every one of your verts.  This leads combining to being limited to smaller groups of things that will disappear off screen together easily (like you mentioned).  

    Most engines, including UE4, have some help for this.  They have systems for have individual assets all placed around willy nilly but when the user is far enough away they combine into a pre-baked version that has been reduced in complexity and draw calls.  In Unreal this is called the Hierarchical Level of Detail (HLOD) and is saved per map, not as assets.

    https://docs.unrealengine.com/en-us/Engine/HLOD

    Unreal also has an actor merging function that can created a combined, cleaned up version of your meshes.  I've used this to build a blueprint full of meshes then combined them into one.  At long distances i hide the multiple mesh components and show the combined one.

    https://docs.unrealengine.com/en-us/Engine/Actors/Merging

Sign In or Register to comment.