Blender V4.5
voxel.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
8#include "kernel/svm/util.h"
9
11
12/* TODO(sergey): Think of making it more generic volume-type attribute
13 * sampler.
14 */
15template<uint node_feature_mask>
17 ccl_private ShaderData *sd,
18 ccl_private float *stack,
19 const uint4 node,
20 int offset)
21{
22 uint co_offset;
23 uint density_out_offset;
24 uint color_out_offset;
25 uint space;
26 svm_unpack_node_uchar4(node.z, &co_offset, &density_out_offset, &color_out_offset, &space);
27
28 float4 r = zero_float4();
29
30#ifdef __VOLUME__
32 {
33 const int id = node.y;
34 float3 co = stack_load_float3(stack, co_offset);
35 if (space == NODE_TEX_VOXEL_SPACE_OBJECT) {
36 co = volume_normalized_position(kg, sd, co);
37 }
38 else {
40 Transform tfm;
41 tfm.x = read_node_float(kg, &offset);
42 tfm.y = read_node_float(kg, &offset);
43 tfm.z = read_node_float(kg, &offset);
44 co = transform_point(&tfm, co);
45 }
46
48 }
49 else
50#endif /* __VOLUME__ */
51 if (space != NODE_TEX_VOXEL_SPACE_OBJECT)
52 {
53 read_node_float(kg, &offset);
54 read_node_float(kg, &offset);
55 read_node_float(kg, &offset);
56 }
57
58 if (stack_valid(density_out_offset)) {
59 stack_store_float(stack, density_out_offset, r.w);
60 }
61 if (stack_valid(color_out_offset)) {
62 stack_store_float3(stack, color_out_offset, make_float3(r.x, r.y, r.z));
63 }
64 return offset;
65}
66
unsigned int uint
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, const int id, float3 P, InterpolationType interp)
ccl_device_inline float4 read_node_float(KernelGlobals kg, ccl_private int *const offset)
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_uchar4(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z, ccl_private uint *w)
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 IF_KERNEL_NODES_FEATURE(feature)
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
VecBase< float, 4 > float4
@ NODE_TEX_VOXEL_SPACE_WORLD
@ NODE_TEX_VOXEL_SPACE_OBJECT
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
Definition math_float4.h:13
float4 y
Definition transform.h:23
float4 x
Definition transform.h:23
float4 z
Definition transform.h:23
uint y
Definition types_uint4.h:13
uint z
Definition types_uint4.h:13
ccl_device_inline float3 transform_point(const ccl_private Transform *t, const float3 a)
Definition transform.h:56
@ INTERPOLATION_NONE
CCL_NAMESPACE_BEGIN ccl_device_noinline int svm_node_tex_voxel(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, const uint4 node, int offset)
Definition voxel.h:16