Blender  V2.93
svm_white_noise.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 
20  ShaderData *sd,
21  float *stack,
22  uint dimensions,
23  uint inputs_stack_offsets,
24  uint ouptuts_stack_offsets,
25  int *offset)
26 {
27  uint vector_stack_offset, w_stack_offset, value_stack_offset, color_stack_offset;
28  svm_unpack_node_uchar2(inputs_stack_offsets, &vector_stack_offset, &w_stack_offset);
29  svm_unpack_node_uchar2(ouptuts_stack_offsets, &value_stack_offset, &color_stack_offset);
30 
31  float3 vector = stack_load_float3(stack, vector_stack_offset);
32  float w = stack_load_float(stack, w_stack_offset);
33 
34  if (stack_valid(color_stack_offset)) {
35  float3 color;
36  switch (dimensions) {
37  case 1:
38  color = hash_float_to_float3(w);
39  break;
40  case 2:
42  break;
43  case 3:
45  break;
46  case 4:
48  break;
49  default:
50  color = make_float3(1.0f, 0.0f, 1.0f);
51  kernel_assert(0);
52  break;
53  }
54  stack_store_float3(stack, color_stack_offset, color);
55  }
56 
57  if (stack_valid(value_stack_offset)) {
58  float value;
59  switch (dimensions) {
60  case 1:
61  value = hash_float_to_float(w);
62  break;
63  case 2:
65  break;
66  case 3:
68  break;
69  case 4:
71  break;
72  default:
73  value = 0.0f;
74  kernel_assert(0);
75  break;
76  }
77  stack_store_float(stack, value_stack_offset, value);
78  }
79 }
80 
unsigned int uint
Definition: BLI_sys_types.h:83
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition: btQuadWord.h:119
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_forceinline void svm_unpack_node_uchar2(uint i, uint *x, uint *y)
ccl_device_inline bool stack_valid(uint a)
#define kernel_assert(cond)
#define ccl_device
#define CCL_NAMESPACE_END
#define make_float2(x, y)
#define make_float4(x, y, z, w)
#define make_float3(x, y, z)
ShaderData
float hash_float_to_float(float k)
Definition: node_hash.h:9
CCL_NAMESPACE_BEGIN ccl_device void svm_node_tex_white_noise(KernelGlobals *kg, ShaderData *sd, float *stack, uint dimensions, uint inputs_stack_offsets, uint ouptuts_stack_offsets, int *offset)
ccl_device_inline float3 hash_float_to_float3(float k)
Definition: util_hash.h:197
ccl_device_inline float3 hash_float4_to_float3(float4 k)
Definition: util_hash.h:211
ccl_device_inline float3 hash_float2_to_float3(float2 k)
Definition: util_hash.h:204
ccl_device_inline float hash_float2_to_float(float2 k)
Definition: util_hash.h:157
ccl_device_inline float hash_float4_to_float(float4 k)
Definition: util_hash.h:167
ccl_device_inline float hash_float3_to_float(float3 k)
Definition: util_hash.h:162
ccl_device_inline float3 hash_float3_to_float3(float3 k)
Definition: util_hash.h:180