Files
test2/intern/cycles/kernel/osl/shaders/node_camera.osl
Alaska 4ca207a145 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
2025-01-09 12:44:52 +01:00

18 lines
464 B
Plaintext

/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
*
* SPDX-License-Identifier: Apache-2.0 */
#include "stdcycles.h"
shader node_camera(output vector ViewVector = vector(0.0, 0.0, 0.0),
output float ViewZDepth = 0.0,
output float ViewDistance = 0.0)
{
ViewVector = (vector)transform("world", "camera", P);
ViewZDepth = ViewVector[2];
ViewDistance = length(ViewVector);
ViewVector = normalize(ViewVector);
}