Are there ways to controll/optimize the draw order of objects?

I did a renderdoc capture of my game, and noticed objects are drawn in a very unoptimal order.

I expect unreal uses object bounds and transforms to deduce the best draw order. However my game is made of large/merged static meshes, which cover the whole screen. This makes bounds and transforms somewhat useless as a predictor of what object is infront of another, i think this is why unreal has a poor draw order for me.

Regarding culling, you will need to be conservative with your mesh merging or else you will face this. There is such a thing as merging too much. You cannot control the draw order of opaque objects, so objects in bounds will be depth tested regardless.

I’d only merge meshes that are likely to be in screen space together anyway, so that they have opportunities to be culled.

1 Like

In general, modern graphics APIs are very good at drawing many instances of objects, and even pretty good at switching textures for different instances when the base (Master) material is the same.

Thus, the old advice of “you must batch all objects and pay super close attention to number of draw calls” isn’t as important on modern systems (Metal, DX12, Vulkan.)

It’s still useful to bake an object 10 different sub-materials into a single material. It’s also still useful to use a single master material (“uber shader”) that you create all your material instances from. (Or, if you can’t do that, use only a few different non-instance base materials.)

So, this means that you don’t have to bake all your meshes together for performance. If your DCC tool can let you export them as smaller pieces, you’ll probably do fine doing that.

Sounds like I may be out of luck, thankyou for your awnswers guys.

Slight correction, I am infact using ISM components, not merging meshes (though either method would result in an unoptimal draw-order).

I am porting an old game to unreal’s renderer. It’s graphics engine is not alike to modern engines. With object instancing, I am using up to 3000 drawcalls. Without it I would be using something to the tune of 20000. So its not really an option to render all the objects individually.

I have done mock tests with dx12, and also with unreals auto instancing, where i render 30000 cubes. Manual instancing and mesh-merging is still very much superior to these in terms of rendering many objects.

I suppose HISM components would have a better draw order, I have yet to test whether these are feasible for my situation.