VolumeNodeMaterial
A node material specialized for volumetric effects such as smoke, clouds, and fog. It uses ray marching inside a bounding geometry (e.g., a box), taking multiple samples to simulate light transport and scattering within a participating medium to achieve true volume appearance.
Core Advantages
It provides true volumetric rendering rather than surface transparency tricks. A custom scatteringNode function lets you control density, color, and lighting response at any point inside the volume, enabling complex, dynamic, and physically plausible effects with strong performance.
Common Uses
Animating smoke, fire, and explosions
Realistic atmospheric effects like clouds and fog
Rendering nebulae in space scenes
Scientific and medical visualization, e.g., CT/MRI volume data
How to adjust
scatteringNode is the core. Provide an Fn function node that returns a vec4, where rgb is color and a is density at each sampled point. steps is the key quality/performance trade‑off: higher values produce smoother, more accurate volumes at higher cost. Use offsetNode to add jitter or noise and reduce banding. With lights set to true, the material interacts with scene lights.
Code Examples
1<mesh>
2 <boxGeometry args={[1, 1, 1]} />
3 <volumeNodeMaterial
4 steps={64} // number of ray-marching steps; quality vs performance
5 scatteringNode={Fn(
6 // localPos is the local position inside the volume
7 float density = 1.0 - length(localPos) * 2.0;
8 density = saturate(density); // clamp density to [0,1]
9
10 // return scattering color (rgb) and density (a)
11 return vec4(1.0, 0.8, 0.6, density);
12 )}
13 />
14</mesh>