textureCubeUV
The textureCubeUV node provides a high-quality method to sample environment maps stored in a special 'Cube UV' format (a 2D texture unwrap of a cube's six faces) directly within the shader. It includes built-in logic for Mipmap level selection based on roughness, making it a core tool for PBR environment reflections, especially in scenarios requiring cross-platform compatibility.
Core Advantages
By simulating cube map sampling in shader code, it enables high-quality, seamless PBR environment reflections that can run on platforms without hardware support for cube map LOD. The node automatically handles complex Mipmap selection and trilinear filtering based on roughness, greatly simplifying development.
Common Uses
Implementing specular reflections for PBR materials (Specular IBL)
Simulating diffuse ambient light by setting roughness to its maximum (Diffuse IBL)
Serving as a low-level sampling tool to build custom advanced shading effects (e.g., distorted reflections)
How to adjust
Effects are controlled primarily by adjusting the `roughness` and `sampleDir` inputs. Changing `roughness` (from 0.0 to 1.0) smoothly transitions the surface reflection from a clear, mirror-like image to a completely diffuse one. Changing `sampleDir` (e.g., from a reflection vector to a normal vector) alters the sampling direction, enabling different effects from specular reflection to ambient lighting.
Code Examples
1const reflectVec = reflect( positionViewDirection.negate(), normalWorld );
2
3// Sample the CubeUV environment map using the reflection vector and surface roughness
4const envColor = textureCubeUV(
5 pmremTexture,
6 reflectVec,
7 surfaceRoughness,
8 CUBEUV_TEXEL_WIDTH,
9 CUBEUV_TEXEL_HEIGHT,
10 CUBEUV_MAX_MIP
11);