Blender V5.3
kernel/svm/camera.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/globals.h"
8
10#include "kernel/svm/util.h"
11
13
15 ccl_private ShaderData *sd,
16 ccl_private float *ccl_restrict stack,
18{
19 const Transform tfm = kernel_data.cam.worldtocamera;
20 const float3 vector = transform_point(&tfm, sd->P);
21 const float zdepth = vector.z;
22 const float distance = len(vector);
23
24 if (stack_valid(node.vector_offset)) {
25 stack_store_float3(stack, node.vector_offset, normalize(vector));
26 }
27
28 if (stack_valid(node.zdepth_offset)) {
29 stack_store_float(stack, node.zdepth_offset, zdepth);
30 }
31
32 if (stack_valid(node.distance_offset)) {
33 stack_store_float(stack, node.distance_offset, distance);
34 }
35}
36
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline bool stack_valid(const uint a)
#define kernel_data
#define ccl_restrict
#define ccl_private
#define ccl_global
#define ccl_device_noinline
#define CCL_NAMESPACE_END
VecBase< float, D > normalize(VecOp< float, D >) RET
float distance(float, float) RET
float3 transform_point(float3x3 mat, float3 point)
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_camera(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *ccl_restrict stack, const ccl_global SVMNodeCamera &ccl_restrict node)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263