A RenderGroup is a Container that PixiJS treats as a self-contained rendering unit. Moving, rotating, scaling, or fading a RenderGroup happens on the GPU, so the CPU cost is near zero. This makes them the primary tool for optimizing scenes with large stable sub-trees or distinct visual layers like a game world and a HUD.
When you mark a Container as a RenderGroup, PixiJS builds a separate set of render instructions for everything inside it. The group's own transform (position, scale, rotation) and visual properties (alpha, tint) are applied as a single GPU operation rather than being recalculated per-child on the CPU. If nothing inside the group changes, PixiJS can skip rebuilding its instructions entirely.
The main advantage of using Render Groups lies in their optimization capabilities. They allow for certain calculations, like transformations (position, scale, rotation), tint, and alpha adjustments, to be offloaded to the GPU. This means that operations like moving or adjusting the Render Group can be done with minimal CPU impact, making your application more performance-efficient.
In practice, you're utilizing Render Groups even without explicit awareness. The root element you pass to the render function in PixiJS is automatically converted into a RenderGroup as this is where its render instructions will be stored. Though you also have the option to explicitly create additional RenderGroups as needed to further optimize your project.
This feature is particularly beneficial for:
const myGameWorld = new Container({
isRenderGroup: true,
});
const myHud = new Container({
isRenderGroup: true,
});
scene.addChild(myGameWorld, myHud);
renderer.render(scene); // this action will actually convert the scene to a render group under the hood
Check out the render group example.
For related optimization strategies, see Performance Tips and Garbage Collection.