26 return clamp(x, 0, width - 1);
31 const int m =
abs(x + (x < 0)) % (2 * width);
33 return 2 * width - m - 1;
50 float f = 1.0f / 255.0f;
56 float f = 1.0f / 65535.f;
67 float f = r * (1.0f / 65535.0f);
81 float f = r * (1.0f / 255.0f);
148#define SET_CUBIC_SPLINE_WEIGHTS(u, t) \
150 u[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f); \
151 u[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f); \
152 u[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f); \
153 u[3] = (1.0f / 6.0f) * t * t * t; \
194 for (
int y = 0; y < 4; y++) {
195 for (
int x = 0; x < 4; x++) {
196 float weight = u[
x] *
v[
y];
205template<
typename TexT,
typename OutT>
struct NanoVDBInterpolator {
217 template<
typename Acc>
218 static ccl_always_inline OutT interp_3d_closest(
const Acc &acc,
float x,
float y,
float z)
221 return read(acc.getValue(coord));
224 template<
typename Acc>
225 static ccl_always_inline OutT interp_3d_linear(
const Acc &acc,
float x,
float y,
float z)
250 template<
typename Acc>
251 static ccl_always_inline OutT interp_3d_cubic(
const Acc &acc,
float x,
float y,
float z)
256 int nnix, nniy, nniz;
273 const int xc[4] = {pix, ix, nix, nnix};
274 const int yc[4] = {piy, iy, niy, nniy};
275 const int zc[4] = {piz, iz, niz, nniz};
276 float u[4],
v[4],
w[4];
281# define DATA(x, y, z) (read(acc.getValue(nanovdb::Coord(xc[x], yc[y], zc[z]))))
282# define COL_TERM(col, row) \
283 (v[col] * (u[0] * DATA(0, col, row) + u[1] * DATA(1, col, row) + u[2] * DATA(2, col, row) + \
284 u[3] * DATA(3, col, row)))
285# define ROW_TERM(row) \
286 (w[row] * (COL_TERM(0, row) + COL_TERM(1, row) + COL_TERM(2, row) + COL_TERM(3, row)))
310 return interp_3d_closest(acc, x, y,
z);
314 return interp_3d_linear(acc, x, y,
z);
318 return interp_3d_cubic(acc, x, y,
z);
342 const float f = NanoVDBInterpolator<float, float>::interp_3d(info, x, y,
z, interpolation);
346 return NanoVDBInterpolator<packed_float3, float4>::interp_3d(info, x, y,
z, interpolation);
349 const float f = NanoVDBInterpolator<nanovdb::FpN, float>::interp_3d(
350 info, x, y,
z, interpolation);
354 const float f = NanoVDBInterpolator<nanovdb::Fp16, float>::interp_3d(
355 info, x, y,
z, interpolation);
409 float u[4],
v[4],
w[4];
416 for (
int z = 0;
z < 4;
z++) {
417 for (
int y = 0; y < 4; y++) {
418 for (
int x = 0; x < 4; x++) {
419 float weight = u[
x] *
v[
y] *
w[
z];
428#undef SET_CUBIC_SPLINE_WEIGHTS
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.
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
CCL_NAMESPACE_BEGIN ccl_device_forceinline T tex_fetch(const TextureInfo &info, int index)
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
static float svm_image_texture_frac(float x, int *ix)
ccl_device_inline float4 svm_image_texture_read_2d(int id, int x, int y)
ccl_device_inline float4 svm_image_texture_read_3d(int id, int x, int y, int z)
ccl_device_inline int svm_image_texture_wrap_periodic(int x, int width)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals, int id, float3 P, int interp)
ccl_device_inline int svm_image_texture_wrap_clamp(int x, int width)
ccl_device float4 kernel_tex_image_interp(KernelGlobals, int id, float x, float y)
ccl_device_inline float4 svm_image_texture_read(const TextureInfo &info, int x, int y, int z)
ccl_device_inline int svm_image_texture_wrap_mirror(int x, int width)
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define kernel_data_fetch(name, index)
#define ccl_device_forceinline
#define ccl_device_inline
#define CCL_NAMESPACE_END
#define ccl_always_inline
draw_view in_light_buf[] float
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
VecBase< float, 4 > float4
ccl_device_inline int abs(int x)
ccl_device_inline int float_to_int(float f)
ccl_device_inline int clamp(int a, int mn, int mx)
@ IMAGE_DATA_TYPE_NANOVDB_FP16
@ IMAGE_DATA_TYPE_USHORT4
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
@ IMAGE_DATA_TYPE_NANOVDB_FPN
#define TEX_IMAGE_MISSING_R
#define TEX_IMAGE_MISSING_B
#define TEX_IMAGE_MISSING_A
#define TEX_IMAGE_MISSING_G