new BBMOD_DynamicBatch(_model, _size)


A dynamic batch is a structure that allows you to render multiple instances of a single model at once, each with its own position, scale and rotation. Compared to BBMOD_Model.render, this drastically reduces draw calls and increases performance, but requires more memory. Current limitations are that the model must not have bones (it cannot be animated) and it can use only a single material. Number of model instances per batch is also affected by maximum number of uniforms that a vertex shader can accept.


Name Type Description
_model BBMOD_Model The model to create a dynamic batch of. Must use a single material and must not have bones.
_size real Number of model instances in the batch.


Name Description
Model A model that is being batched.
Size Number of model instances in the batch.


Name Description
default_fn The default function used in BBMOD_DynamicBatch.render_object. Uses instance's variables x, y, z for position, image_xscale for uniform scale and image_angle for rotation around the z axis.
destroy Frees memory used by the dynamic batch. Use this in combination with delete to destroy a dynamic batch struct.
freeze Freezes the dynamic batch. This makes it render faster.
render Submits the dynamic batch for rendering.
render_object Renders all instances of an object in batches of BBMOD_DynamicBatch.size.


Following code renders all instances of a car object in batches of 64.

/// @desc Create event
mod_car = new BBMOD_Model("Car.bbmod");
mat_car = new BBMOD_Material(BBMOD_ShDefaultBatched, sprite_get_texture(SprCar, 0));
car_batch = new BBMOD_DynamicBatch(mod_car, 64);

/// @desc Draw event
car_batch.render_object(OCar, mat_car);

See also


Copyright © 2020, BlueBurn. Built on November 30, 2020 using GMDoc.