12#if !defined(__KERNEL_METAL__) && !defined(__KERNEL_ONEAPI__)
37 const float3 w[4] = {(((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f),
38 ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f),
39 ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f),
40 (1.0f / 6.0f) * t * t * t};
46 for (
int j = 1; j < 4; j++) {
48 const float3 thresh =
w[j] / total_weight;
49 const auto mask = rand < thresh;
61 return select(rand < t, p + 1.0f, p);
70 P_new = interp_tricubic_stochastic(
P, rand);
73 P_new = interp_trilinear_stochastic(
P, rand);
83template<
typename OutT,
typename Acc>
90 const int ix = index.
x;
91 const int iy = index.
y;
92 const int iz = index.
z;
95 OutT(acc.getValue(
make_int3(ix, iy, iz + 1))),
98 OutT(acc.getValue(
make_int3(ix, iy + 1, iz))),
102 OutT(acc.getValue(
make_int3(ix + 1, iy + 1, iz + 1))),
105 OutT(acc.getValue(
make_int3(ix + 1, iy, iz))),
111template<
typename OutT,
typename Acc>
118 const int xc[4] = {index.
x - 1, index.
x, index.
x + 1, index.
x + 2};
119 const int yc[4] = {index.
y - 1, index.
y, index.
y + 1, index.
y + 2};
120 const int zc[4] = {index.
z - 1, index.
z, index.
z + 1, index.
z + 2};
121 float u[4],
v[4],
w[4];
126# define SET_CUBIC_SPLINE_WEIGHTS(u, t) \
128 u[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f); \
129 u[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f); \
130 u[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f); \
131 u[3] = (1.0f / 6.0f) * t * t * t; \
135# define DATA(x, y, z) (OutT(acc.getValue(make_int3(xc[x], yc[y], zc[z]))))
136# define COL_TERM(col, row) \
137 (v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
138 u[3] * DATA(3, col, row)))
139# define ROW_TERM(row) \
140 (w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
147 return ROW_TERM(0) + ROW_TERM(1) + ROW_TERM(2) + ROW_TERM(3);
152# undef SET_CUBIC_SPLINE_WEIGHTS
155template<
typename OutT,
typename T>
156# if defined(__KERNEL_METAL__)
174 return kernel_tex_image_interp_trilinear_nanovdb<OutT>(acc,
P);
177 return kernel_tex_image_interp_tricubic_nanovdb<OutT>(acc,
P);
186 const bool stochastic)
191 if (info.use_transform_3d) {
201 P = interp_stochastic(
P, interpolation, rand);
206 const float f = kernel_tex_image_interp_nanovdb<float, float>(info,
P, interpolation);
210 const float3 f = kernel_tex_image_interp_nanovdb<float3, packed_float3>(
211 info,
P, interpolation);
215 return kernel_tex_image_interp_nanovdb<float4, float4>(info,
P, interpolation);
218 const float f = kernel_tex_image_interp_nanovdb<float, nanovdb::FpN>(info,
P, interpolation);
222 const float f = kernel_tex_image_interp_nanovdb<float, nanovdb::Fp16>(info,
P, interpolation);
241#ifndef __KERNEL_GPU__
MINLINE float safe_divide(float a, float b)
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static __attribute__((constructor)) void cpu_check()
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
#define kernel_assert(cond)
#define kernel_data_fetch(name, index)
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define ccl_device_noinline
#define CCL_NAMESPACE_END
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 float2 mask(const MaskType mask, const float2 a)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, ccl_private ShaderData *sd, const int 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