From 4ca207a145d514bb000c91caadeeea44f01732d3 Mon Sep 17 00:00:00 2001 From: Alaska Date: Thu, 9 Jan 2025 12:44:52 +0100 Subject: [PATCH] Cycles: Align Camera data output between SVM and OSL The `ZDepth` output of the camera data node was different between SVM and OSL. SVM would output the `ZDepth`, with negative distances for points behind the camera. While OSL would output the absolute of the distance, which resulted in points behind the camera becoming positive. Align OSL to SVM and allow outputting the negative distance as it allows users to differentiate between what's in front or behind the camera. Pull Request: https://projects.blender.org/blender/blender/pulls/132837 --- intern/cycles/kernel/osl/shaders/node_camera.osl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/intern/cycles/kernel/osl/shaders/node_camera.osl b/intern/cycles/kernel/osl/shaders/node_camera.osl index 4051dd8b273..68791b95cfa 100644 --- a/intern/cycles/kernel/osl/shaders/node_camera.osl +++ b/intern/cycles/kernel/osl/shaders/node_camera.osl @@ -10,7 +10,7 @@ shader node_camera(output vector ViewVector = vector(0.0, 0.0, 0.0), { ViewVector = (vector)transform("world", "camera", P); - ViewZDepth = fabs(ViewVector[2]); + ViewZDepth = ViewVector[2]; ViewDistance = length(ViewVector); ViewVector = normalize(ViewVector);