Blender  V2.93
svm_bump.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2016 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 /* Bump Eval Nodes */
20 
22  ShaderData *sd,
23  float *stack,
24  uint offset)
25 {
26  /* save state */
27  stack_store_float3(stack, offset + 0, sd->P);
28  stack_store_float3(stack, offset + 3, sd->dP.dx);
29  stack_store_float3(stack, offset + 6, sd->dP.dy);
30 
31  /* set state as if undisplaced */
33 
34  if (desc.offset != ATTR_STD_NOT_FOUND) {
35  float3 P, dPdx, dPdy;
36  P = primitive_surface_attribute_float3(kg, sd, desc, &dPdx, &dPdy);
37 
39  object_dir_transform(kg, sd, &dPdx);
40  object_dir_transform(kg, sd, &dPdy);
41 
42  sd->P = P;
43  sd->dP.dx = dPdx;
44  sd->dP.dy = dPdy;
45  }
46 }
47 
49  ShaderData *sd,
50  float *stack,
51  uint offset)
52 {
53  /* restore state */
54  sd->P = stack_load_float3(stack, offset + 0);
55  sd->dP.dx = stack_load_float3(stack, offset + 3);
56  sd->dP.dy = stack_load_float3(stack, offset + 6);
57 }
58 
unsigned int uint
Definition: BLI_sys_types.h:83
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id)
ccl_device_inline void object_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
Definition: geom_object.h:116
ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
Definition: geom_object.h:178
ccl_device_inline float3 primitive_surface_attribute_float3(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float3 *dx, float3 *dy)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline void stack_store_float3(float *stack, uint a, float3 f)
#define ccl_device
#define CCL_NAMESPACE_END
@ ATTR_STD_NOT_FOUND
Definition: kernel_types.h:773
@ ATTR_STD_POSITION_UNDISPLACED
Definition: kernel_types.h:755
ShaderData
static float P(float k)
Definition: math_interp.c:41
ccl_device void svm_node_leave_bump_eval(KernelGlobals *kg, ShaderData *sd, float *stack, uint offset)
Definition: svm_bump.h:48
CCL_NAMESPACE_BEGIN ccl_device void svm_node_enter_bump_eval(KernelGlobals *kg, ShaderData *sd, float *stack, uint offset)
Definition: svm_bump.h:21