12#if !defined(__KERNEL_METAL__) && !defined(__KERNEL_ONEAPI__)
31 w[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f);
32 w[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f);
33 w[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f);
34 w[3] = (1.0f / 6.0f) * t * t * t;
47 fill_cubic_weights(
w, t);
53 for (
int j = 1; j < 4; j++) {
55 const float3 thresh =
w[j] / total_weight;
56 const auto mask = rand < thresh;
68 return select(rand < t, p + 1.0f, p);
77 P_new = interp_tricubic_stochastic(
P, rand);
80 P_new = interp_trilinear_stochastic(
P, rand);
90template<
typename OutT,
typename Acc>
97 const int ix =
index.x;
98 const int iy =
index.y;
99 const int iz =
index.z;
102 OutT(acc.getValue(
make_int3(ix, iy, iz + 1))),
105 OutT(acc.getValue(
make_int3(ix, iy + 1, iz))),
109 OutT(acc.getValue(
make_int3(ix + 1, iy + 1, iz + 1))),
112 OutT(acc.getValue(
make_int3(ix + 1, iy, iz))),
118template<
typename OutT,
typename Acc>
121# if defined(__KERNEL_HIP__)
135 fill_cubic_weights(weight, t);
137# define DATA(x, y, z) (OutT(acc.getValue(make_int3(xc[x], yc[y], zc[z]))))
138# define COL_TERM(col, row) \
139 (weight[col].y * (weight[0].x * DATA(0, col, row) + weight[1].x * DATA(1, col, row) + \
140 weight[2].x * DATA(2, col, row) + weight[3].x * DATA(3, col, row)))
141# define ROW_TERM(row) \
142 (weight[row].z * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
145 return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3);
158 fill_cubic_weights(
w, t);
162 for (
int k = 0; k < 4; k++) {
164 for (
int j = 0; j < 4; j++) {
165 col_term_acc +=
w[j].y * (
w[0].x * (OutT(acc.getValue(
index +
make_int3(0, j, k)))) +
170 result +=
w[k].z * col_term_acc;
177template<
typename OutT,
typename T>
178# if defined(__KERNEL_METAL__)
196 return kernel_image_interp_trilinear_nanovdb<OutT>(acc,
P);
199 return kernel_image_interp_tricubic_nanovdb<OutT>(acc,
P);
205 const int image_texture_id,
208 const bool stochastic)
214 if (tex.use_transform_3d) {
224 P = interp_stochastic(
P, interpolation, rand);
229 const float f = kernel_image_interp_nanovdb<float, float>(info,
P, interpolation);
233 const float3 f = kernel_image_interp_nanovdb<float3, packed_float3>(info,
P, interpolation);
237 return kernel_image_interp_nanovdb<float4, float4>(info,
P, interpolation);
240 const float f = kernel_image_interp_nanovdb<float, nanovdb::FpN>(info,
P, interpolation);
244 const float f = kernel_image_interp_nanovdb<float, nanovdb::Fp16>(info,
P, interpolation);
253 (void)image_texture_id;
262#ifndef __KERNEL_GPU__
struct AtomicSpinLock __attribute__((aligned(32))) AtomicSpinLock
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
#define kernel_assert(cond)
#define ccl_device_forceinline
#define kernel_data_fetch(name, index)
#define ccl_device_inline
#define ccl_device_noinline
#define CCL_NAMESPACE_END
float safe_divide(float a, float b)
ccl_device float3 lcg_step_float3(T rng)
ccl_device_inline float interp(const float a, const float b, const float t)
ccl_device_inline T make_zero()
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
#define IMAGE_MISSING_RGBA
ccl_device float4 kernel_image_interp_3d(KernelGlobals kg, ccl_private ShaderData *sd, const int image_texture_id, float3 P, InterpolationType interp, const bool stochastic)
Grid< NanoTree< BuildT > > NanoGrid
@ IMAGE_DATA_TYPE_NANOVDB_FP16
@ IMAGE_DATA_TYPE_NANOVDB_EMPTY
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT4
@ IMAGE_DATA_TYPE_NANOVDB_FPN