In this lesson, you will learn how to balance the high visual fidelity of volumetric fog and clouds with the performance demands of your target hardware.
Volumetric rendering is incredibly expensive because it involves "ray marching"—sampling 3D volumes step-by-step through the depth of your scene. If you sample too frequently, your GPU will hit a bottleneck. Optimization is a balancing act of three main levers: Sample Counts, Resolution Scaling, and Shadow Integration.
1. Controlling Sample Density
The r.VolumetricFog.GridPixelSize console command is your primary tool for resolution control. By default, volumetric fog is rendered at a lower resolution than your main scene. Increasing the GridPixelSize (e.g., from 8 to 16) significantly reduces the number of voxels the GPU needs to calculate, providing an immediate frame rate boost at the cost of some sharpness.
2. Managing Shadow Complexity
Volumetric shadows are often the most taxing part of the render. If your volumetric fog is casting shadows from a Directional Light, you can optimize this by adjusting the light's Volumetric Scattering Intensity. Additionally, ensure you are not using high-resolution shadow maps for lights that don't need them. In your light settings, you can toggle Cast Volumetric Shadow to disable this costly pass for secondary lights.
3. Jitter and Temporal Upsampling
Unreal Engine uses temporal super-resolution techniques to smooth out low-sample counts. If you notice "noise" or "banding" in your volumetrics, resist the urge to simply increase samples. Instead, check your r.VolumetricFog.TemporalReprojection. Keeping this enabled allows the engine to blend previous frames, effectively letting you run lower sample counts without the visual jitter that usually accompanies them.
Practical Application
To test your performance, open the console and type stat fogrendering. Watch the "Sample Count" and "Voxel Density" numbers. If your GPU time is high, start by increasing the GridPixelSize in your DefaultEngine.ini or via console command before touching your material-based cloud samples. Always favor lower resolution samples smoothed by temporal reprojection over high-resolution, aliased rendering.
Key Takeaway: Prioritize resolution scaling and temporal blending over raw sample counts to achieve high-performance, artifact-free volumetric rendering.