Blender V5.0
white_noise.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/svm/util.h"
8#include "util/hash.h"
9
11
13 const uint dimensions,
14 const uint inputs_stack_offsets,
15 const uint outputs_stack_offsets)
16{
17 uint vector_stack_offset;
18 uint w_stack_offset;
19 uint value_stack_offset;
20 uint color_stack_offset;
21 svm_unpack_node_uchar2(inputs_stack_offsets, &vector_stack_offset, &w_stack_offset);
22 svm_unpack_node_uchar2(outputs_stack_offsets, &value_stack_offset, &color_stack_offset);
23
24 const float3 vector = stack_load_float3(stack, vector_stack_offset);
25 const float w = stack_load_float(stack, w_stack_offset);
26
27 if (stack_valid(color_stack_offset)) {
28 float3 color;
29 switch (dimensions) {
30 case 1:
31 color = hash_float_to_float3(w);
32 break;
33 case 2:
35 break;
36 case 3:
38 break;
39 case 4:
41 break;
42 default:
43 color = make_float3(1.0f, 0.0f, 1.0f);
45 break;
46 }
47 stack_store_float3(stack, color_stack_offset, color);
48 }
49
50 if (stack_valid(value_stack_offset)) {
51 float value;
52 switch (dimensions) {
53 case 1:
54 value = hash_float_to_float(w);
55 break;
56 case 2:
58 break;
59 case 3:
61 break;
62 case 4:
64 break;
65 default:
66 value = 0.0f;
68 break;
69 }
70 stack_store_float(stack, value_stack_offset, value);
71 }
72}
73
unsigned int uint
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_forceinline void svm_unpack_node_uchar2(const uint i, ccl_private uint *x, ccl_private uint *y)
ccl_device_inline bool stack_valid(const uint a)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
#define kernel_assert(cond)
#define ccl_private
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_inline float3 hash_float_to_float3(const float k)
Definition hash.h:300
ccl_device_inline float hash_float3_to_float(const float3 k)
Definition hash.h:227
ccl_device_inline float3 hash_float2_to_float3(const float2 k)
Definition hash.h:307
ccl_device_inline float hash_float2_to_float(const float2 k)
Definition hash.h:222
ccl_device_inline float hash_float4_to_float(const float4 k)
Definition hash.h:232
ccl_device_inline float3 hash_float4_to_float3(const float4 k)
Definition hash.h:314
ccl_device_inline float3 hash_float3_to_float3(const float3 k)
Definition hash.h:283
float hash_float_to_float(float k)
Definition node_hash.h:70
#define make_float2
#define make_float4
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_tex_white_noise(ccl_private float *stack, const uint dimensions, const uint inputs_stack_offsets, const uint outputs_stack_offsets)
Definition white_noise.h:12