Runtime batching – ShiVa Engine

Runtime batching

In ShiVa, you can optimize your performance by batching small and simple objects into one to reduce draw calls. The engine auto-batches for you if your models have less than 33 vertices. If you cannot meet this requirement, you could manually batch objects once upon scene init.

Auto Batcher Restrictions:
– Vertex count must be lower than 33
– You cannot use lightmaps nor dynamic lighting
– Skinned mesh is not allowed (no bones)
– The material must be the original (no script override, starting with 1.9.2, you can use UVOffset and UVScale)
– batch materials should each use another material priority (different from the default 127, and also different from one another)

The most restrictive limitation is the vertex count; also you might have seen that 32 vertices in 3DS Max are not 32 vertices in ShiVa.

Manual Batching:
This method is very effective but has limitations: The merge objects have to be a simple objects (no children, not a group of groups),
and objects must not have controllers (no AI, etc). Code:

--create empty batch group
hGroup = scene.createRuntimeObject ( hScene, "" )
-- then, for each object you want to combine, parent it to the group:
object.setParent ( hObject, hGroup, true )
-- the group is ready, it’s merge time:
hCombined = scene.combineRuntimeObjectsGroup ( hScene, hGroup )
-- remove the group of models and set the batchgroup visible:
scene.destroyRuntimeObject ( hScene, hGroup )
object.setVisible (hCombined, true )



Need more answers?

  • slackBanner