16 return x *
x *
x * (
x * (
x * 6.0f - 15.0f) + 10.0f);
22 const uint value_stack_offset,
23 const uint parameters_stack_offsets,
24 const uint results_stack_offsets,
27 uint from_min_stack_offset;
28 uint from_max_stack_offset;
29 uint to_min_stack_offset;
30 uint to_max_stack_offset;
31 uint type_stack_offset;
32 uint steps_stack_offset;
33 uint result_stack_offset;
35 &from_min_stack_offset,
36 &from_max_stack_offset,
38 &to_max_stack_offset);
40 results_stack_offsets, &type_stack_offset, &steps_stack_offset, &result_stack_offset);
54 if (from_max != from_min) {
56 switch (type_stack_offset) {
59 factor = (value - from_min) / (from_max - from_min);
62 factor = (value - from_min) / (from_max - from_min);
67 factor = (from_min > from_max) ? 1.0f -
smoothstep(from_max, from_min, factor) :
72 factor = (from_min > from_max) ? 1.0f -
smootherstep(from_max, from_min, factor) :
77 result = to_min + factor * (to_max - to_min);
89 const uint value_stack_offset,
90 const uint parameters_stack_offsets,
91 const uint results_stack_offsets,
94 uint from_min_stack_offset;
95 uint from_max_stack_offset;
96 uint to_min_stack_offset;
97 uint to_max_stack_offset;
98 uint steps_stack_offset;
99 uint clamp_stack_offset;
100 uint range_type_stack_offset;
101 uint result_stack_offset;
103 &from_min_stack_offset,
104 &from_max_stack_offset,
105 &to_min_stack_offset,
106 &to_max_stack_offset);
110 &range_type_stack_offset,
111 &result_stack_offset);
120 const int type = range_type_stack_offset;
127 switch (range_type_stack_offset) {
130 factor =
safe_divide((value - from_min), (from_max - from_min));
133 factor =
safe_divide((value - from_min), (from_max - from_min));
141 factor =
safe_divide((value - from_min), (from_max - from_min));
143 factor = (
make_float3(3.0f, 3.0f, 3.0f) - 2.0f * factor) * (factor * factor);
147 factor =
safe_divide((value - from_min), (from_max - from_min));
149 factor = factor * factor * factor * (factor * (factor * 6.0f - 15.0f) + 10.0f);
153 result = to_min + factor * (to_max - to_min);
MINLINE float safe_divide(float a, float b)
@ NODE_MAP_RANGE_SMOOTHERSTEP
@ NODE_MAP_RANGE_SMOOTHSTEP
ccl_device_inline float stack_load_float(const ccl_private float *stack, const uint a)
ccl_device_inline void stack_store_float(ccl_private float *stack, const uint a, const float f)
ccl_device_inline uint4 read_node(KernelGlobals kg, ccl_private int *const offset)
ccl_device_inline void stack_store_float3(ccl_private float *stack, const uint a, const float3 f)
ccl_device_inline float stack_load_float_default(const ccl_private float *stack, const uint a, const uint value)
ccl_device_forceinline void svm_unpack_node_uchar3(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_forceinline void svm_unpack_node_uchar4(const uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z, ccl_private uint *w)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(const ccl_private float *stack, const uint a)
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define ccl_device_noinline
#define CCL_NAMESPACE_END
constexpr T clamp(T, U, U) RET
ccl_device_noinline int svm_node_map_range(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, const uint value_stack_offset, const uint parameters_stack_offsets, const uint results_stack_offsets, int offset)
ccl_device_noinline int svm_node_vector_map_range(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, const uint value_stack_offset, const uint parameters_stack_offsets, const uint results_stack_offsets, const int offset)
CCL_NAMESPACE_BEGIN ccl_device_inline float smootherstep(const float edge0, const float edge1, float x)
MINLINE float smoothstep(float edge0, float edge1, float x)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()