Radeon ProRender

Instance Creation

Instances are memory saving mesh shapes.

Imagine rendering a forest of identical trees. Instances can be used to create one tree with N copies instead of creating N tree meshes. This saves time and memory.

rprContextCreateInstance() simply takes a reference to the ‘parent’ object and returns an rpr_shape. This shape can then have its own transform or shader, or settings applied to it just like a normal mesh rpr_shape.

rpr_shape instance = nullptr;

// Create an 'instance' from the 'cube' parent
rprContextCreateInstance(context, cube, &instance);

// At this point, the 'instance' can be managed like any classic rpr_shape

	 // Create a translation transform: -2 unit along X axis and 1 unit up Y axis
	 RadeonProRender::matrix m = RadeonProRender::translation(RadeonProRender::float3(2, 1, 0));

	 // Set the transform
	 CHECK(rprShapeSetTransform(instance, RPR_TRUE, &m.m00));

// Attach the instance to the scene
CHECK(rprSceneAttachShape(scene, instance));


Example of creating an instance can be found in the Basic Scene demo.