Where does Nanite decide it needs to batch draw calls?

When using Nanite where does the rendering pipeline decide a draw call is using the same Materials/Resources and should just use a cached draw call or create a new draw call?
From what I can tell if the material instance and used resources are the same it will batch the draw calls together.

Any help is appreciated.

I’d track down the original nanite presentations and information about the new programmable raster system, Nanite rendering is a hugely complicated system and I would advise you to look into the articles written by the devs.

Found what I was looking for in NaniteShading.cpp

ShadingPipeline.ShaderBindings = MakePimpl<FMeshDrawShaderBindings, EPimplPtrMode::DeepCopy>();

UE::MeshPassUtils::SetupComputeBindings(BasePassShader, &Scene, FeatureLevel, SceneProxy, *MaterialProxy, *ShadingPipeline.Material, ShaderElementData, *ShadingPipeline.ShaderBindings);

ShadingPipeline.ShaderBindingsHash = ShadingPipeline.ShaderBindings->GetDynamicInstancingHash();

As long as the ShaderBindingsHash is different the draw calls will be separate.

1 Like