Q. I created a big explosion and lightning effect using VFX Graph. It looks fine while playing in the center of the screen, but if you move the camera slightly to the left or right and the source moves to the edge of the screen, the effect suddenly disappears even though the effect is still there. What is the cause?
A. This is a bug in the camera Frustum Culling (Frustum Culling), which occurs because the size of the "bounding box" (Bounds), which determines the drawing of VFX, is too small for the range in which particles spread.
Failure symptoms and culling phenomenon that suddenly disappears
When creating dynamic effects that use a large amount of space in Unity's Visual Effect Graph (VFX Graph), you may encounter unnatural bugs. This is a phenomenon that appears when the source of the effect is captured in the center of the screen, but the moment you change the direction of the camera and move the source off the screen, a large amount of particles that should still be floating around in the screen disappear in an instant. If you put the camera back, it will reappear. This situation is caused by a misconfiguration of Unity's culling function to reduce the drawing load.
An analogy for beginners: The invisible stage of the theater and the actor's big jump
To help visualize this phenomenon, let's compare effects to "actors performing on a theater stage" and the VFX object Bounds to "the stage itself surrounded by an invisible wooden frame."
The theater cameraman (camera viewing frustum) is shooting a movie. The cameraman is very rational, checking every frame to see if the stage (Bounds' wooden frame) is even slightly within the camera's angle of view. If the wooden frame moves completely outside the field of view, the cameraman will decide that there is no one else on stage and should take a break and switch off the camera (this is called culling).
The problem is that even though the wooden frame of the stage is narrow (1 meter square), the actors ride the wind or make big jumps and perform by jumping 10 meters outside the wooden frame. No matter how much the actors were running around on screen, the cameraman would turn off the camera just because the wooden frame was not in the camera's field of view. As a result, the actors on the screen disappear in an instant. The solution is simple. The goal is to make the invisible stage (Bounds frame) large enough to encompass the entire area where the actors will be running around.
Assumed main causes
The main causes of the bug where effects are suddenly deleted are as follows.
- The initial value of Bounds is extremely small by default: When creating a new VFX Graph, the bounding box size is usually set to a very narrow cube such as "1m x 1m x 1m". If particles are scattered beyond this range, a culling error will occur.
- Large movement due to physical parameters or external factors: This is because the particles are moving a longer distance than expected after being emitted due to `Gravity`, `Turbulence`, or adding speed by script, but Bounds are not following it.
- Disabling Dynamic Bounds Calculation: Since GPU particles are processed at extremely high speeds, it would be very expensive to use the CPU to track the particles at the current edge every frame. Therefore, VFX Graph basically fixes the size in advance (static Bounds), and this problem will occur if manual adjustment is neglected.
Specific solutions and procedures
This is a setting procedure to prevent the effect from disappearing due to camera movement.
Step 1: Visualize the bounding box (Bounds)
First, check the current size. Enable Bounds display from the Visual Effect Helper menu in the top toolbar of the scene view, or select the desired VFX object. A cube (Bounds) is displayed in green wireframe on the scene view. Make sure the particles are flying out of this green box.
Step 2: Manually adjust Bounds size and position in VFX Graph
- Open the VFX Graph editor and view the **`VFX Property Sheet`** in the top left of the editor window.
- Look for **`Bounds`** in the settings.
- Change the value of **`Size`** to a value that fully covers the maximum spread of the effect (for example, `10, 10, 10`).
- If the particles move in a particular direction, slide the **`Center`** value to shift the center of gravity of the green box in that direction.
Step 3: Utilize automatic calculation function (Record Bounds)
If manual sizing is difficult, use the VFX Graph feature **`Record Bounds`**. When you press this button while the game is running or playing in the editor, it will automatically measure the maximum range from the movement history of the emitted particles and automatically apply the optimal bounds size and center point.
Bounds recommended settings table by effect type
| Effect type | Recommended Bounds size | Setting points |
|---|---|---|
| Dust smoke and small sparks at your feet | About 3m × 3m × 3m | Sizes close to the default are also supported. Center is placed at the feet. |
| Big explosions and huge magic circles | About 15m × 15m × 15m | Considering the distance that shock waves and debris fly, set it widely in all directions. |
The following is debugging code for dynamically changing and checking the state of the VFX bounding box from a C# script.
using UnityEngine;
using UnityEngine.VFX;
[RequireComponent(typeof(VisualEffect))]
public class VFXBoundsOptimizer : MonoBehaviour
{
private VisualEffect vfx;
[SerializeField] private Vector3 customSize = new Vector3(20f, 20f, 20f);
[SerializeField] private Vector3 customCenter = Vector3.zero;
void Start()
{
vfx = GetComponent<VisualEffect>();
if (vfx != null)
{
vfx.localBounds = new Bounds(customCenter, customSize);
}
}
}
Adjusting the bounding box size appropriately is an essential task to maintain the visual quality of the game. If it is too wide, the culling effect will be weakened and many things will not be drawn, and if it is too narrow, it will directly lead to display bugs, so use the steps above and the Gizmo display to find the perfect size for each effect.