Blender  V2.93
svm_camera.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 ccl_device void svm_node_camera(KernelGlobals *kg,
20  ShaderData *sd,
21  float *stack,
22  uint out_vector,
23  uint out_zdepth,
24  uint out_distance)
25 {
26  float distance;
27  float zdepth;
28  float3 vector;
29 
30  Transform tfm = kernel_data.cam.worldtocamera;
31  vector = transform_point(&tfm, sd->P);
32  zdepth = vector.z;
33  distance = len(vector);
34 
35  if (stack_valid(out_vector))
36  stack_store_float3(stack, out_vector, normalize(vector));
37 
38  if (stack_valid(out_zdepth))
39  stack_store_float(stack, out_zdepth, zdepth);
40 
41  if (stack_valid(out_distance))
42  stack_store_float(stack, out_distance, distance);
43 }
44 
unsigned int uint
Definition: BLI_sys_types.h:83
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
ccl_device_inline void stack_store_float(float *stack, uint a, float f)
ccl_device_inline bool stack_valid(uint a)
#define kernel_data
#define ccl_device
#define CCL_NAMESPACE_END
ShaderData
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
Definition: vector.h:39
CCL_NAMESPACE_BEGIN ccl_device void svm_node_camera(KernelGlobals *kg, ShaderData *sd, float *stack, uint out_vector, uint out_zdepth, uint out_distance)
Definition: svm_camera.h:19
ccl_device_inline float distance(const float2 &a, const float2 &b)
ccl_device_inline float2 normalize(const float2 &a)
ccl_device_inline float3 transform_point(const Transform *t, const float3 a)
uint len