parallaxUV
parallaxUV
Calculates UV coordinates with a depth illusion based on the viewing direction and a height map, used to simulate parallax effects on flat surfaces.
Core Advantages
Common Uses
Basic Parallax Mapping (e.g., brick walls, cobblestone)
Refraction distortion for water or glass
Heat haze or mirage effects
How to adjust
Mainly controlled by adjusting the `scale` input. Increasing the `scale` value enhances the sense of depth but can cause artifacts; using a negative value inverts the effect (e.g., bump to dent). Applying math functions (like `pow`) to the value sampled from the height map can alter the depth response curve for a sharper effect.
Code Examples
1// Get depth from a height map and multiply by a scale
2const scale = texture( heightMap ).r.mul( parallaxScale );
3
4// Calculate the new UVs with the parallax effect
5const parallaxedUV = parallaxUV( uv(), scale );