15 const float3 *ramp,
float f,
bool interpolate,
bool extrapolate,
const int table_size)
17 if ((f < 0.0f || f > 1.0f) && extrapolate) {
22 dy = t0 - ramp[1], f = -f;
25 t0 = ramp[table_size - 1];
26 dy = t0 - ramp[table_size - 2];
29 return t0 + dy * f * (table_size - 1);
32 f =
clamp(f, 0.0f, 1.0f) * (table_size - 1);
36 const float t = f - (
float)
i;
40 if (interpolate && t > 0.0f) {
48 const float *ramp,
float f,
bool interpolate,
bool extrapolate,
const int table_size)
50 if ((f < 0.0f || f > 1.0f) && extrapolate) {
55 dy = t0 - ramp[1], f = -f;
58 t0 = ramp[table_size - 1];
59 dy = t0 - ramp[table_size - 2];
62 return t0 + dy * f * (table_size - 1);
65 f =
clamp(f, 0.0f, 1.0f) * (table_size - 1);
69 const float t = f - (
float)
i;
73 if (interpolate && t > 0.0f) {
#define ccl_device_inline
#define CCL_NAMESPACE_END
constexpr T clamp(T, U, U) RET
ccl_device_inline int float_to_int(const float f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 rgb_ramp_lookup(const float3 *ramp, float f, bool interpolate, bool extrapolate, const int table_size)
ccl_device float float_ramp_lookup(const float *ramp, float f, bool interpolate, bool extrapolate, const int table_size)