How to handle RenderTexture for offscreen drawing

Updated: 10/14/2025

This page contains statements regarding the beta version.

Cubism 5 SDK for Unity R5 beta2 and Cubism 5 SDK for Web R5 beta2 and later adopt a structure that reduces memory loads by using available offscreen drawing RenderTextures (RenderTargets).

Offscreen drawing flow

Offscreen drawing in Cubism SDK for Unity and Cubism SDK for Web follows this flow.

Structure of using available RenderTextures

Model structure patterns that can use available RenderTextures

Model structures that can and cannot use available RenderTextures

The RenderTexture of the parent offscreen drawing will continue to hold the RenderTextures of all drawable objects (Drawable and offscreen drawing) in the child hierarchy until they have finished being drawn.
Therefore, if offscreen drawing is used in a parent-child hierarchy, RenderTexture can be held for each offscreen drawing in the parent-child hierarchy.

For example, a model with the following structure will hold a maximum of three RenderTextures.

If offscreen drawing exists in parallel in the same hierarchy, there is only one RenderTexture used in that hierarchy.
For example, a model with the following structure has four offscreen drawings, but there is no parent-child hierarchy of offscreen drawings, so there is only one RenderTexture to be generated and used.

In the case of a model with the following structure in which these offscreen drawings are combined, the number of offscreen drawings in the parent-child hierarchy is three (at PartA through PartD), so the maximum number of RenderTextures that are generated and that can be used is three.

Release the number of RenderTextures that were not used in the previous frame

In Unity, if you want to release only those RenderTextures that were created but are no longer needed, call the function CubismOffscreenRenderTextureManager.ReleaseStaleRenderTextures(), which releases the number of RenderTextures that were not used in the previous frame.

CubismOffscreenRenderTextureManager.GetInstance().ReleaseStaleRenderTextures();

To release RenderTextures when switching scenes (Unity)

SceneManager.sceneLoaded += OnSceneLoaded();

~~~
private void OnSceneLoaded()
{
    CubismOffscreenRenderTextureManager.GetInstance().ReleaseStaleRenderTextures();
}

Was this article helpful?
YesNo
Please let us know what you think about this article.