Blender V4.5
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 ccl_private ShaderData *sd,
14 ccl_private float *stack,
15 const uint dimensions,
16 const uint inputs_stack_offsets,
17 const uint outputs_stack_offsets)
18{
19 uint vector_stack_offset;
20 uint w_stack_offset;
21 uint value_stack_offset;
22 uint color_stack_offset;
23 svm_unpack_node_uchar2(inputs_stack_offsets, &vector_stack_offset, &w_stack_offset);
24 svm_unpack_node_uchar2(outputs_stack_offsets, &value_stack_offset, &color_stack_offset);
25
26 const float3 vector = stack_load_float3(stack, vector_stack_offset);
27 const float w = stack_load_float(stack, w_stack_offset);
28
29 if (stack_valid(color_stack_offset)) {
30 float3 color;
31 switch (dimensions) {
32 case 1:
33 color = hash_float_to_float3(w);
34 break;
35 case 2:
37 break;
38 case 3:
40 break;
41 case 4:
43 break;
44 default:
45 color = make_float3(1.0f, 0.0f, 1.0f);
47 break;
48 }
49 stack_store_float3(stack, color_stack_offset, color);
50 }
51
52 if (stack_valid(value_stack_offset)) {
53 float value;
54 switch (dimensions) {
55 case 1:
56 value = hash_float_to_float(w);
57 break;
58 case 2:
60 break;
61 case 3:
63 break;
64 case 4:
66 break;
67 default:
68 value = 0.0f;
70 break;
71 }
72 stack_store_float(stack, value_stack_offset, value);
73 }
74}
75
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
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float4 make_float4(const float x, const float y, const float z, const float w)
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline float2 make_float2(const float x, const float y)
ccl_device_inline float3 hash_float_to_float3(const float k)
Definition hash.h:213
ccl_device_inline float hash_float3_to_float(const float3 k)
Definition hash.h:178
ccl_device_inline float3 hash_float2_to_float3(const float2 k)
Definition hash.h:220
ccl_device_inline float hash_float2_to_float(const float2 k)
Definition hash.h:173
ccl_device_inline float hash_float4_to_float(const float4 k)
Definition hash.h:183
ccl_device_inline float3 hash_float4_to_float3(const float4 k)
Definition hash.h:227
ccl_device_inline float3 hash_float3_to_float3(const float3 k)
Definition hash.h:196
float hash_float_to_float(float k)
Definition node_hash.h:13
CCL_NAMESPACE_BEGIN ccl_device_noinline void svm_node_tex_white_noise(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, const uint dimensions, const uint inputs_stack_offsets, const uint outputs_stack_offsets)
Definition white_noise.h:12