14 if ((f < 0.0f || f > 1.0f) && extrapolate) {
18 dy = t0 - ramp[1], f = -f;
21 t0 = ramp[table_size - 1];
22 dy = t0 - ramp[table_size - 2];
25 return t0 + dy * f * (table_size - 1);
28 f =
clamp(f, 0.0f, 1.0f) * (table_size - 1);
32 float t = f - (
float)i;
36 if (interpolate && t > 0.0f) {
37 result = (1.0f - t) * result + t * ramp[i + 1];
44 const float *ramp,
float f,
bool interpolate,
bool extrapolate,
int table_size)
46 if ((f < 0.0f || f > 1.0f) && extrapolate) {
50 dy = t0 - ramp[1], f = -f;
53 t0 = ramp[table_size - 1];
54 dy = t0 - ramp[table_size - 2];
57 return t0 + dy * f * (table_size - 1);
60 f =
clamp(f, 0.0f, 1.0f) * (table_size - 1);
64 float t = f - (
float)i;
66 float result = ramp[i];
68 if (interpolate && t > 0.0f) {
69 result = (1.0f - t) * result + t * ramp[i + 1];
#define ccl_device_inline
#define CCL_NAMESPACE_END
draw_view in_light_buf[] float
ccl_device float float_ramp_lookup(const float *ramp, float f, bool interpolate, bool extrapolate, int table_size)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 rgb_ramp_lookup(const float3 *ramp, float f, bool interpolate, bool extrapolate, int table_size)
ccl_device_inline int float_to_int(float f)
ccl_device_inline int clamp(int a, int mn, int mx)