getParallaxCorrectNormal
Corrects parallax errors for local environment reflections, making them appear spatially accurate and three-dimensional within a finite space (e.g., a room) instead of looking like a 'sticker'.
Core Advantages
Achieves highly realistic local reflection parallax correction at a very low performance cost. It encapsulates a complex Ray-AABB intersection algorithm, significantly enhancing scene realism and immersion.
Common Uses
Indoor architectural visualization
Automotive or product showcases
In-game mirrors or puddles
Museum glass display cases
How to adjust
Adjust `cubeSize` and `cubePos`, which define the environment's bounding box. A smaller `cubeSize` results in more pronounced parallax effects; a larger size approaches the effect of a standard, non-parallax environment map. `cubePos` must precisely match the center position of the CubeCamera used to generate the environment map, otherwise, the reflections will be misplaced. This node assumes the environment map was 'shot' from the six faces of this bounding box.
Code Examples
1// Calculate the initial reflection vector
2const reflectVec = reflect( viewDirection, worldNormal );
3
4// Correct the reflection vector for parallax based on the environment's bounding box
5const parallaxCorrectedNormal = getParallaxCorrectNormal( reflectVec, envMapPosition, envMapSize );