21#define SET_CUBIC_SPLINE_WEIGHTS(u, t) \
23 u[0] = (((-1.0f / 6.0f) * t + 0.5f) * t - 0.5f) * t + (1.0f / 6.0f); \
24 u[1] = ((0.5f * t - 1.0f) * t) * t + (2.0f / 3.0f); \
25 u[2] = ((-0.5f * t + 0.5f) * t + 0.5f) * t + (1.0f / 6.0f); \
26 u[3] = (1.0f / 6.0f) * t * t * t; \
34 if constexpr (std::is_same_v<OutT, float4>) {
49 const float f = 1.0f / 255.0f;
55 return r * (1.0f / 255.0f);
75 return r * (1.0f / 65535.0f);
80 const float f = 1.0f / 65535.0f;
121 return clamp(
x, 0, width - 1);
126 const int m =
abs(
x + (
x < 0)) % (2 * width);
128 return 2 * width - m - 1;
139 const int width = info.width;
140 const int height = info.height;
144 switch (info.extension) {
151 if (ix < 0 || ix >= width || iy < 0 || iy >= height) {
169 return read(data, ix, iy, width, height);
176 const int width = info.width;
177 const int height = info.height;
182 const float tx =
frac(
x - 0.5f, &ix);
183 const float ty =
frac(
y - 0.5f, &iy);
186 switch (info.extension) {
196 if (ix < -1 || ix >= width || iy < -1 || iy >= height) {
201 return (1.0f - ty) * (1.0f - tx) *
read_clip(data, ix, iy, width, height) +
202 (1.0f - ty) * tx *
read_clip(data, nix, iy, width, height) +
203 ty * (1.0f - tx) *
read_clip(data, ix, niy, width, height) +
204 ty * tx *
read_clip(data, nix, niy, width, height);
222 return (1.0f - ty) * (1.0f - tx) *
read(data, ix, iy, width, height) +
223 (1.0f - ty) * tx *
read(data, nix, iy, width, height) +
224 ty * (1.0f - tx) *
read(data, ix, niy, width, height) +
225 ty * tx *
read(data, nix, niy, width, height);
232 const int width = info.width;
233 const int height = info.height;
237 const float tx =
frac(
x - 0.5f, &ix);
238 const float ty =
frac(
y - 0.5f, &iy);
244 switch (info.extension) {
258 if (ix < -2 || ix > width || iy < -2 || iy > height) {
298 const int xc[4] = {pix, ix, nix, nnix};
299 const int yc[4] = {piy, iy, niy, nniy};
305#define DATA(x, y) (read_clip(data, xc[x], yc[y], width, height))
308 (u[0] * DATA(0, col) + u[1] * DATA(1, col) + u[2] * DATA(2, col) + u[3] * DATA(3, col)))
323 switch (info.interpolation) {
334#undef SET_CUBIC_SPLINE_WEIGHTS
338 const int image_texture_id,
340 const float4 missing_rgba)
350 if (tex.tile_descriptor_offset !=
UINT_MAX) {
358 kg, sd, tex, image_texture_id, uv, xy);
381 switch (info->data_type) {
416 const float4 missing_rgba)
426#ifndef __KERNEL_GPU__
#define SET_CUBIC_SPLINE_WEIGHTS(u, t)
#define kernel_assert(cond)
#define ccl_device_forceinline
#define kernel_data_fetch(name, index)
#define ccl_always_inline
#define CCL_NAMESPACE_END
constexpr T clamp(T, U, U) RET
ccl_device_inline float4 half4_to_float4_image(const half4 h)
ccl_device_inline float half_to_float_image(half h)
ccl_device_forceinline bool kernel_image_tile_wrap(const ExtensionType extension, ccl_private float2 &uv)
ccl_device_forceinline KernelTileDescriptor kernel_image_tile_map(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_global KernelImageTexture &tex, const uint image_texture_id, const dual2 uv, ccl_private float2 &xy)
CCL_NAMESPACE_BEGIN ccl_device_forceinline int kernel_image_udim_map(KernelGlobals kg, const int id, ccl_private float2 &uv)
ccl_device_inline int float_to_int(const float f)
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
#define KERNEL_TILE_LOAD_FAILED
#define KERNEL_IMAGE_NONE
ccl_device float4 kernel_image_interp(KernelGlobals kg, ccl_private ShaderData *sd, const int image_texture_id, dual2 uv, const float4 missing_rgba)
ccl_device_forceinline float4 kernel_image_interp_with_udim(KernelGlobals kg, ccl_private ShaderData *sd, const int udim_id, dual2 uv, const float4 missing_rgba)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
static ccl_always_inline OutT zero()
static ccl_always_inline float4 read(half4 r)
static ccl_always_inline float read(const uint16_t r)
static ccl_always_inline float read(half r)
static ccl_always_inline OutT interp_closest(const ccl_global KernelImageInfo &info, const float x, float y)
static ccl_always_inline float4 read(ushort4 r)
static ccl_always_inline OutT interp_cubic(const ccl_global KernelImageInfo &info, const float x, float y)
static ccl_always_inline float4 read(const float4 r)
static ccl_always_inline OutT interp_linear(const ccl_global KernelImageInfo &info, const float x, float y)
static ccl_always_inline float4 read(const uchar4 r)
static ccl_always_inline OutT interp(const ccl_global KernelImageInfo &info, const float x, float y)
static ccl_always_inline int wrap_mirror(const int x, const int width)
static ccl_always_inline OutT read_clip(const ccl_global TexT *data, const int x, int y, const int width, const int height)
static ccl_always_inline int wrap_periodic(int x, const int width)
static ccl_always_inline OutT read(const ccl_global TexT *data, const int x, int y, const int width, const int)
static ccl_always_inline float frac(const float x, ccl_private int *ix)
static ccl_always_inline float read(const uchar r)
static ccl_always_inline float read(const float r)
static ccl_always_inline int wrap_clamp(const int x, const int width)
uint KernelTileDescriptor
@ IMAGE_DATA_TYPE_USHORT4
ccl_device_inline bool kernel_tile_descriptor_loaded(const KernelTileDescriptor tile)
ccl_device_inline uint kernel_tile_descriptor_image_info_id(const KernelTileDescriptor tile)