Blender  V2.93
svm_vertex_color.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_vertex_color(KernelGlobals *kg,
20  ShaderData *sd,
21  float *stack,
22  uint layer_id,
23  uint color_offset,
24  uint alpha_offset)
25 {
27  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
28  float4 vertex_color = primitive_surface_attribute_float4(kg, sd, descriptor, NULL, NULL);
29  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
30  stack_store_float(stack, alpha_offset, vertex_color.w);
31  }
32  else {
33  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
34  stack_store_float(stack, alpha_offset, 0.0f);
35  }
36 }
37 
38 #ifndef __KERNEL_CUDA__
40 #else
42 #endif
43  void
45  ShaderData *sd,
46  float *stack,
47  uint layer_id,
48  uint color_offset,
49  uint alpha_offset)
50 {
52  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
53  float4 dx;
54  float4 vertex_color = primitive_surface_attribute_float4(kg, sd, descriptor, &dx, NULL);
55  vertex_color += dx;
56  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
57  stack_store_float(stack, alpha_offset, vertex_color.w);
58  }
59  else {
60  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
61  stack_store_float(stack, alpha_offset, 0.0f);
62  }
63 }
64 
65 #ifndef __KERNEL_CUDA__
67 #else
69 #endif
70  void
72  ShaderData *sd,
73  float *stack,
74  uint layer_id,
75  uint color_offset,
76  uint alpha_offset)
77 {
79  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
80  float4 dy;
81  float4 vertex_color = primitive_surface_attribute_float4(kg, sd, descriptor, NULL, &dy);
82  vertex_color += dy;
83  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
84  stack_store_float(stack, alpha_offset, vertex_color.w);
85  }
86  else {
87  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
88  stack_store_float(stack, alpha_offset, 0.0f);
89  }
90 }
91 
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 float4 primitive_surface_attribute_float4(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float4 *dx, float4 *dy)
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)
#define ccl_device
#define ccl_device_noinline
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
@ ATTR_STD_NOT_FOUND
Definition: kernel_types.h:773
ShaderData
descriptor
Definition: logImageCore.h:153
CCL_NAMESPACE_BEGIN ccl_device void svm_node_vertex_color(KernelGlobals *kg, ShaderData *sd, float *stack, uint layer_id, uint color_offset, uint alpha_offset)
ccl_device void svm_node_vertex_color_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint layer_id, uint color_offset, uint alpha_offset)
ccl_device void svm_node_vertex_color_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint layer_id, uint color_offset, uint alpha_offset)
ccl_device_inline float3 float4_to_float3(const float4 a)
Definition: util_math.h:415