Blender  V3.3
vertex_color.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: Apache-2.0
2  * Copyright 2011-2022 Blender Foundation */
3 
4 #pragma once
5 
7 
10  ccl_private float *stack,
11  uint layer_id,
12  uint color_offset,
13  uint alpha_offset)
14 {
15  AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id);
16  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
17  if (descriptor.type == NODE_ATTR_FLOAT4 || descriptor.type == NODE_ATTR_RGBA) {
19  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
20  stack_store_float(stack, alpha_offset, vertex_color.w);
21  }
22  else {
24  stack_store_float3(stack, color_offset, vertex_color);
25  stack_store_float(stack, alpha_offset, 1.0f);
26  }
27  }
28  else {
29  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
30  stack_store_float(stack, alpha_offset, 0.0f);
31  }
32 }
33 
36  ccl_private float *stack,
37  uint layer_id,
38  uint color_offset,
39  uint alpha_offset)
40 {
41  AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id);
42  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
43  if (descriptor.type == NODE_ATTR_FLOAT4 || descriptor.type == NODE_ATTR_RGBA) {
44  float4 dx;
45  float4 vertex_color = primitive_surface_attribute_float4(kg, sd, descriptor, &dx, NULL);
46  vertex_color += dx;
47  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
48  stack_store_float(stack, alpha_offset, vertex_color.w);
49  }
50  else {
51  float3 dx;
52  float3 vertex_color = primitive_surface_attribute_float3(kg, sd, descriptor, &dx, NULL);
53  vertex_color += dx;
54  stack_store_float3(stack, color_offset, vertex_color);
55  stack_store_float(stack, alpha_offset, 1.0f);
56  }
57  }
58  else {
59  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
60  stack_store_float(stack, alpha_offset, 0.0f);
61  }
62 }
63 
66  ccl_private float *stack,
67  uint layer_id,
68  uint color_offset,
69  uint alpha_offset)
70 {
71  AttributeDescriptor descriptor = find_attribute(kg, sd, layer_id);
72  if (descriptor.offset != ATTR_STD_NOT_FOUND) {
73  if (descriptor.type == NODE_ATTR_FLOAT4 || descriptor.type == NODE_ATTR_RGBA) {
74  float4 dy;
75  float4 vertex_color = primitive_surface_attribute_float4(kg, sd, descriptor, NULL, &dy);
76  vertex_color += dy;
77  stack_store_float3(stack, color_offset, float4_to_float3(vertex_color));
78  stack_store_float(stack, alpha_offset, vertex_color.w);
79  }
80  else {
81  float3 dy;
82  float3 vertex_color = primitive_surface_attribute_float3(kg, sd, descriptor, NULL, &dy);
83  vertex_color += dy;
84  stack_store_float3(stack, color_offset, vertex_color);
85  stack_store_float(stack, alpha_offset, 1.0f);
86  }
87  }
88  else {
89  stack_store_float3(stack, color_offset, make_float3(0.0f, 0.0f, 0.0f));
90  stack_store_float(stack, alpha_offset, 0.0f);
91  }
92 }
93 
unsigned int uint
Definition: BLI_sys_types.h:67
float float4[4]
#define ccl_private
Definition: cuda/compat.h:48
#define ccl_device_noinline
Definition: cuda/compat.h:40
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
const KernelGlobalsCPU *ccl_restrict KernelGlobals
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals kg, ccl_private const ShaderData *sd, uint id)
ccl_device_inline void stack_store_float3(ccl_private float *stack, uint a, float3 f)
ccl_device_inline void stack_store_float(ccl_private float *stack, uint a, float f)
@ NODE_ATTR_RGBA
@ NODE_ATTR_FLOAT4
@ ATTR_STD_NOT_FOUND
Definition: kernel/types.h:647
ShaderData
Definition: kernel/types.h:925
descriptor
Definition: logImageCore.h:144
#define make_float3(x, y, z)
Definition: metal/compat.h:204
ccl_device_forceinline float3 primitive_surface_attribute_float3(KernelGlobals kg, ccl_private const ShaderData *sd, const AttributeDescriptor desc, ccl_private float3 *dx, ccl_private float3 *dy)
Definition: primitive.h:83
ccl_device_forceinline float4 primitive_surface_attribute_float4(KernelGlobals kg, ccl_private const ShaderData *sd, const AttributeDescriptor desc, ccl_private float4 *dx, ccl_private float4 *dy)
Definition: primitive.h:114
ccl_device_inline float3 float4_to_float3(const float4 a)
Definition: util/math.h:500
ccl_device_noinline void svm_node_vertex_color_bump_dy(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint layer_id, uint color_offset, uint alpha_offset)
Definition: vertex_color.h:64
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_vertex_color(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint layer_id, uint color_offset, uint alpha_offset)
Definition: vertex_color.h:8
ccl_device_noinline void svm_node_vertex_color_bump_dx(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint layer_id, uint color_offset, uint alpha_offset)
Definition: vertex_color.h:34