From 1d1f6cf94644d064417adf7a12557abcaaee1ed1 Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Sun, 10 Nov 2024 17:12:56 -0500 Subject: [PATCH] PostProcessingUtils: Add method for normal reconstruction. (#1348) --- .../src/nodes/utils/PostProcessingUtils.d.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/types/three/src/nodes/utils/PostProcessingUtils.d.ts b/types/three/src/nodes/utils/PostProcessingUtils.d.ts index f1d5d5012..0406e4d77 100644 --- a/types/three/src/nodes/utils/PostProcessingUtils.d.ts +++ b/types/three/src/nodes/utils/PostProcessingUtils.d.ts @@ -28,3 +28,18 @@ export const getScreenPosition: ( viewPosition: NodeRepresentation, projectionMatrix: NodeRepresentation, ) => ShaderNodeObject; + +/** + * Computes a normal vector based on depth data. Can be used as a fallback when no normal render target is available or + * if flat surface normals are required. + * + * @param {vec2} uv - The texture coordinate. + * @param {DepthTexture} depthTexture - The depth texture. + * @param {mat4} projectionMatrixInverse - The camera's inverse projection matrix. + * @return {vec3} The computed normal vector. + */ +export const getNormalFromDepth: ( + uv: NodeRepresentation, + depthTexture: NodeRepresentation, + projectionMatrixInverse: NodeRepresentation, +) => ShaderNodeObject;