texture3D
Samples a data value (e.g., color, density) from a 3D texture volume at a specified 3D coordinate (XYZ), enabling the rendering of volumetric phenomena with internal structure.
Core Advantages
It enables true volumetric rendering (like clouds, smoke, fire) and solid procedural materials (like marble) by allowing shaders to query the internal properties of a space, not just a surface.
Common Uses
Volumetric cloud, smoke, or nebula rendering
Medical and scientific data visualization (MRI, CT)
Solid procedural materials with internal patterns (e.g., marble, wood)
How to adjust
By transforming the 3D sampling coordinate (`uvNode`). To change the scale of the volumetric features, multiply the coordinate input (e.g., `positionLocal.mul(0.5)`). To animate the volume, add a time-based vector to the coordinate (e.g., `positionLocal.add(vec3(0, timerLocal(), 0))`) to create flowing or evolving effects.
Code Examples
1
2// Sample a 3D texture using the object's local position.
3// This makes the material appear carved from the texture volume.
4const noise = texture3D( myVolumeTexture, positionLocal );
5
6// Animate the sampling coordinate to create a flowing fog effect.
7const animatedPos = positionLocal.add( vec3( 0, timerLocal( -0.1 ), 0 ) );
8const flowingFog = texture3D( myVolumeTexture, animatedPos );