9#if !defined __KERNEL_METAL__
25 return (1.0f / 6.0f) * (a * (a * (-a + 3.0f) - 3.0f) + 1.0f);
29 return (1.0f / 6.0f) * (a * a * (3.0f * a - 6.0f) + 4.0f);
33 return (1.0f / 6.0f) * (a * (a * (-3.0f * a + 3.0f) + 3.0f) + 1.0f);
37 return (1.0f / 6.0f) * (a * a * a);
68 x = (
x * info.width) - 0.5f;
69 y = (
y * info.height) - 0.5f;
79 float x0 = (px +
cubic_h0(fx) + 0.5f) / info.width;
80 float x1 = (px +
cubic_h1(fx) + 0.5f) / info.width;
81 float y0 = (py +
cubic_h0(fy) + 0.5f) / info.height;
82 float y1 = (py +
cubic_h1(fy) + 0.5f) / info.height;
97 x = (
x * info.width) - 0.5f;
98 y = (
y * info.height) - 0.5f;
99 z = (
z * info.depth) - 0.5f;
116 float x0 = (px +
cubic_h0(fx) + 0.5f) / info.width;
117 float x1 = (px +
cubic_h1(fx) + 0.5f) / info.width;
118 float y0 = (py +
cubic_h0(fy) + 0.5f) / info.height;
119 float y1 = (py +
cubic_h1(fy) + 0.5f) / info.height;
120 float z0 = (pz +
cubic_h0(fz) + 0.5f) / info.depth;
121 float z1 = (pz +
cubic_h1(fz) + 0.5f) / info.depth;
134template<
typename OutT,
typename Acc>
141 const float tx =
frac(
x - 0.5f, &ix);
142 const float ty =
frac(
y - 0.5f, &iy);
143 const float tz =
frac(
z - 0.5f, &iz);
162template<
typename OutT,
typename Acc>
171 int nnix, nniy, nniz;
174 const float tx =
frac(
x - 0.5f, &ix);
175 const float ty =
frac(
y - 0.5f, &iy);
176 const float tz =
frac(
z - 0.5f, &iz);
188 const int xc[4] = {pix, ix, nix, nnix};
189 const int yc[4] = {piy, iy, niy, nniy};
190 const int zc[4] = {piz, iz, niz, nniz};
191 float u[4],
v[4],
w[4];
196# define SET_CUBIC_SPLINE_WEIGHTS(u, t) \
198 u[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f); \
199 u[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f); \
200 u[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f); \
201 u[3] = (1.0f / 6.0f) * t * t * t; \
205# define DATA(x, y, z) (OutT(acc.getValue(nanovdb::Coord(xc[x], yc[y], zc[z]))))
206# define COL_TERM(col, row) \
207 (v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
208 u[3] * DATA(3, col, row)))
209# define ROW_TERM(row) \
210 (w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
222# undef SET_CUBIC_SPLINE_WEIGHTS
225# if defined(__KERNEL_METAL__)
226template<
typename OutT,
typename T>
231 const uint interpolation)
233template<
typename OutT,
typename T>
238 const uint interpolation)
245 switch (interpolation) {
249 return OutT(acc.getValue(coord));
253 return kernel_tex_image_interp_trilinear_nanovdb<OutT>(acc,
x,
y,
z);
257 return kernel_tex_image_interp_tricubic_nanovdb<OutT>(acc,
x,
y,
z);
268 const int texture_type = info.data_type;
303 if (info.use_transform_3d) {
312 const int texture_type = info.data_type;
316 float f = kernel_tex_image_interp_nanovdb<float, float>(info,
x,
y,
z, interpolation);
320 float3 f = kernel_tex_image_interp_nanovdb<float3, packed_float3>(
321 info,
x,
y,
z, interpolation);
325 float f = kernel_tex_image_interp_nanovdb<float, nanovdb::FpN>(info,
x,
y,
z, interpolation);
329 float f = kernel_tex_image_interp_nanovdb<float, nanovdb::Fp16>(info,
x,
y,
z, interpolation);
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
static __attribute__((constructor)) void cpu_check()
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
ccl_device float cubic_g0(const float a)
ccl_device_noinline T kernel_tex_image_interp_bicubic(const ccl_global TextureInfo &info, float x, float y)
ccl_device float cubic_h1(const float a)
ccl_device float cubic_w3(const float a)
CCL_NAMESPACE_BEGIN ccl_device_inline float frac(const float x, ccl_private int *ix)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, const int id, float3 P, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y)
ccl_device float cubic_g1(const float a)
ccl_device_noinline T kernel_tex_image_interp_tricubic(const ccl_global TextureInfo &info, float x, float y, float z)
ccl_device float cubic_w2(const float a)
ccl_device float cubic_h0(const float a)
ccl_device float cubic_w0(const float a)
ccl_device float cubic_w1(const float a)
#define kernel_data_fetch(name, index)
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define ccl_device_noinline
ccl_device_forceinline T ccl_gpu_tex_object_read_2D(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
CUtexObject ccl_gpu_tex_object_3D
ccl_device_forceinline T ccl_gpu_tex_object_read_3D(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
#define CCL_NAMESPACE_END
CUtexObject ccl_gpu_tex_object_2D
ccl_device_forceinline float4 ccl_gpu_tex_object_read_2D< float4 >(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
ccl_device_forceinline float ccl_gpu_tex_object_read_3D< float >(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
ccl_device_forceinline float4 ccl_gpu_tex_object_read_3D< float4 >(const ccl_gpu_tex_object_3D texobj, const float x, const float y, const float z)
ccl_device_forceinline float ccl_gpu_tex_object_read_2D< float >(const ccl_gpu_tex_object_2D texobj, const float x, const float y)
VecBase< float, 4 > float4
ccl_device_inline int float_to_int(const float f)
ccl_device_inline float interp(const float a, const float b, const float t)
Grid< NanoTree< BuildT > > NanoGrid
@ IMAGE_DATA_TYPE_NANOVDB_FP16
@ IMAGE_DATA_TYPE_USHORT4
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
@ IMAGE_DATA_TYPE_NANOVDB_FPN