Culling

Overview


By using the culling system, it is possible to stop the simulation if the character is not drawn to the camera or is too far away from the camera.
This can greatly improve performance, especially in first-person FPS and VR.

The following video is an example of how camera culling works.
Notice the performance improvement by enabling the culling system.

Camera Culling


Camera culling is a function that stops cloth simulations that are not drawn on the camera.
This is determined from inside and outside the camera’s viewing frustum.

Camera culling mode

“Camera Culling Mode” sets the behavior when hidden from the camera.

Off Disable camera culling.
Reset Reset the simulation.
Keep Pause the simulation.
Animator Linkage

Automatically linked with the character’s Animator’s “CullingMode”.
Always Animate => [Off]
Cull Update Transforms => [Reset]
Cull Completely => [Keep]

Camera culling judgment method

Basically, culling is determined from the display state of the character’s Renderer component.
Therefore, in order to perform culling, it is necessary to register one or more renderers.
“Camera Culling Method” specifies how this renderer is registered.

Automatic Renderer Automatically set from the character’s Animator.
This is typically all Renderer components under Animator.
Manual Renderer Configure Renderer manually.

Distance Culling


Distance culling stops the simulation when a character is too far away from the camera.
Stopping the simulation can improve performance.

The following video visualizes distance culling in relation to camera position.
Notice how the simulation stops as the camera moves away.

Distance Culling Length Specifies the enabled state of distance culling and the judgment distance.
Distance Culling Fade Ratio Distance culling fade setting.
The simulation state and disabled state are blended to make the transition look smoother.
This is a ratio to the judgment distance.
Distance Culling Reference Object Specifies the object to measure the distance to.
If (None) is set, the main camera will be referenced.
The distance is calculated from the target set here and the coordinates of the MagicaCloth component.

Checking the culling status


You can check whether the cross component is currently displayed or hidden from the information in the inspector.
If it is excluded from the simulation, the Visible flag will be False.

Things to keep in mind


Notes when running the editor

Note that when running in the Unity editor, the editor’s Scene view is also subject to camera culling.
For example, even if a character is not shown in the Game view, if it is shown in the Scene view, it will be drawn and camera culling will not be performed.

Shadow effect

The character’s shadow is also subject to drawing judgment.
Please note that even if the character itself is not visible, if its shadow is visible on the screen, it will not be culled.

Not all functions will stop

Even if the simulation is stopped due to culling, the minimum necessary processing is still being executed.
Please note that this does not mean that the load will be 0.

Animator culling issue

When Animator’s culling mode is “Cull Update Transforms”, when the character appears on screen again, a pose with simulation disabled may be displayed momentarily.
This is because the Animator’s culling is determined during the rendering process, and the pose is written to the transform on the fly, overwriting the simulation results.
This is a Unity specification and unfortunately cannot be avoided.

Combining camera culling and distance culling

If you use camera culling and distance culling together, the simulation will only run if both are visible.