Blender  V2.93
svm_normal.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_normal(KernelGlobals *kg,
20  ShaderData *sd,
21  float *stack,
22  uint in_normal_offset,
23  uint out_normal_offset,
24  uint out_dot_offset,
25  int *offset)
26 {
27  /* read extra data */
28  uint4 node1 = read_node(kg, offset);
29  float3 normal = stack_load_float3(stack, in_normal_offset);
30 
31  float3 direction;
32  direction.x = __int_as_float(node1.x);
33  direction.y = __int_as_float(node1.y);
34  direction.z = __int_as_float(node1.z);
35  direction = normalize(direction);
36 
37  if (stack_valid(out_normal_offset))
38  stack_store_float3(stack, out_normal_offset, direction);
39 
40  if (stack_valid(out_dot_offset))
41  stack_store_float(stack, out_dot_offset, dot(direction, normalize(normal)));
42 }
43 
unsigned int uint
Definition: BLI_sys_types.h:83
IconTextureDrawCall normal
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline uint4 read_node(KernelGlobals *kg, int *offset)
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 ccl_device
#define CCL_NAMESPACE_END
ShaderData
float z
Definition: sky_float3.h:35
float y
Definition: sky_float3.h:35
float x
Definition: sky_float3.h:35
CCL_NAMESPACE_BEGIN ccl_device void svm_node_normal(KernelGlobals *kg, ShaderData *sd, float *stack, uint in_normal_offset, uint out_normal_offset, uint out_dot_offset, int *offset)
Definition: svm_normal.h:19
ccl_device_inline float __int_as_float(int i)
Definition: util_math.h:212
ccl_device_inline float2 normalize(const float2 &a)
ccl_device_inline float dot(const float2 &a, const float2 &b)