Blender  V2.93
svm_convert.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 /* Conversion Nodes */
20 
22  KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint from, uint to)
23 {
24  switch (type) {
25  case NODE_CONVERT_FI: {
26  float f = stack_load_float(stack, from);
27  stack_store_int(stack, to, float_to_int(f));
28  break;
29  }
30  case NODE_CONVERT_FV: {
31  float f = stack_load_float(stack, from);
32  stack_store_float3(stack, to, make_float3(f, f, f));
33  break;
34  }
35  case NODE_CONVERT_CF: {
36  float3 f = stack_load_float3(stack, from);
37  float g = linear_rgb_to_gray(kg, f);
38  stack_store_float(stack, to, g);
39  break;
40  }
41  case NODE_CONVERT_CI: {
42  float3 f = stack_load_float3(stack, from);
43  int i = (int)linear_rgb_to_gray(kg, f);
44  stack_store_int(stack, to, i);
45  break;
46  }
47  case NODE_CONVERT_VF: {
48  float3 f = stack_load_float3(stack, from);
49  float g = average(f);
50  stack_store_float(stack, to, g);
51  break;
52  }
53  case NODE_CONVERT_VI: {
54  float3 f = stack_load_float3(stack, from);
55  int i = (int)average(f);
56  stack_store_int(stack, to, i);
57  break;
58  }
59  case NODE_CONVERT_IF: {
60  float f = (float)stack_load_int(stack, from);
61  stack_store_float(stack, to, f);
62  break;
63  }
64  case NODE_CONVERT_IV: {
65  float f = (float)stack_load_int(stack, from);
66  stack_store_float3(stack, to, make_float3(f, f, f));
67  break;
68  }
69  }
70 }
71 
typedef float(TangentPoint)[2]
unsigned int uint
Definition: BLI_sys_types.h:83
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
StackEntry * from
ccl_device_inline void stack_store_int(float *stack, uint a, int i)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(float *stack, uint a)
ccl_device_inline float stack_load_float(float *stack, uint a)
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 int stack_load_int(float *stack, uint a)
ccl_device float linear_rgb_to_gray(KernelGlobals *kg, float3 c)
Definition: kernel_color.h:31
#define ccl_device
#define CCL_NAMESPACE_END
#define make_float3(x, y, z)
ShaderData
CCL_NAMESPACE_BEGIN ccl_device void svm_node_convert(KernelGlobals *kg, ShaderData *sd, float *stack, uint type, uint from, uint to)
Definition: svm_convert.h:21
@ NODE_CONVERT_IF
Definition: svm_types.h:392
@ NODE_CONVERT_CI
Definition: svm_types.h:389
@ NODE_CONVERT_CF
Definition: svm_types.h:388
@ NODE_CONVERT_VF
Definition: svm_types.h:390
@ NODE_CONVERT_VI
Definition: svm_types.h:391
@ NODE_CONVERT_FI
Definition: svm_types.h:387
@ NODE_CONVERT_IV
Definition: svm_types.h:393
@ NODE_CONVERT_FV
Definition: svm_types.h:386
ccl_device_inline int float_to_int(float f)
Definition: util_math.h:321
ccl_device_inline float average(const float2 &a)