🏭

UE5 Material Batching Technical Investigation

Unique Dynamic material instance for each Mesh

First attempt :

2052 frames collected over 30.34 seconds, disregarding 0.00 seconds (0 frames) for a 67.64 FPS average
Average GPU frametime: 14.68 ms
Average RenderThread frametime: 17.51 ms
Average GameThread frametime: 1.33 ms

Second attempt :

2119 frames collected over 30.01 seconds, disregarding 0.00 seconds (0 frames) for a 70.61 FPS average
Average GPU frametime: 14.09 ms
Average RenderThread frametime: 16.89 ms
Average GameThread frametime: 0.88 ms


One Material instance for all Mesh

2432 frames collected over 30.00 seconds, disregarding 0.00 seconds (0 frames) for a 81.06 FPS average
Average GPU frametime: 12.25 ms
Average RenderThread frametime: 13.66 ms
Average GameThread frametime: 0.80 ms


Unique material instance for each Mesh with no changed variables

2431 frames collected over 30.01 seconds, disregarding 0.00 seconds (0 frames) for a 81.01 FPS average
Average GPU frametime: 12.31 ms
Average RenderThread frametime: 13.75 ms
Average GameThread frametime: 0.81 ms


Unique material instance for each Meshwith changed variables

(not showing as I didn’t crank up the screen emissivness)

2124 frames collected over 30.01 seconds, disregarding 0.00 seconds (0 frames) for a 70.77 FPS average
Average GPU frametime: 14.04 ms
Average RenderThread frametime: 17.74 ms
Average GameThread frametime: 0.86 ms


One Dynamic material instance for all Mesh

2431 frames collected over 30.01 seconds, disregarding 0.00 seconds (0 frames) for a 81.01 FPS average
Average GPU frametime: 12.27 ms
Average RenderThread frametime: 15.74 ms
Average GameThread frametime: 0.82 ms


Using CustomPrim data and a single material instance for all Mesh

2427 frames collected over 30.01 seconds, disregarding 0.00 seconds (0 frames) for a 80.88 FPS average
Average GPU frametime: 12.27 ms
Average RenderThread frametime: 13.57 ms
Average GameThread frametime: 0.81 ms


Synopsis :

A single dynamic material instance (DMI) costs the same as a single material instance (MI).

Unreal engine batches material instances with no change parameters.

For maximum customization CustomPrimitiveData is to be used. Each used custom primitive adds very little, extra time to render, however the more CustomPrimitiveData floats you use, the more expensive the instanced draw will become.