Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_map_range.h
| Show All 18 Lines | |||||
| /* Map Range Node */ | /* Map Range Node */ | ||||
| ccl_device_inline float smootherstep(float edge0, float edge1, float x) | ccl_device_inline float smootherstep(float edge0, float edge1, float x) | ||||
| { | { | ||||
| x = clamp(safe_divide((x - edge0), (edge1 - edge0)), 0.0f, 1.0f); | x = clamp(safe_divide((x - edge0), (edge1 - edge0)), 0.0f, 1.0f); | ||||
| return x * x * x * (x * (x * 6.0f - 15.0f) + 10.0f); | return x * x * x * (x * (x * 6.0f - 15.0f) + 10.0f); | ||||
| } | } | ||||
| ccl_device void svm_node_map_range(KernelGlobals *kg, | ccl_device_noinline int svm_node_map_range(const KernelGlobals *kg, | ||||
| ShaderData *sd, | ShaderData *sd, | ||||
| float *stack, | float *stack, | ||||
| uint value_stack_offset, | uint value_stack_offset, | ||||
| uint parameters_stack_offsets, | uint parameters_stack_offsets, | ||||
| uint results_stack_offsets, | uint results_stack_offsets, | ||||
| int *offset) | int offset) | ||||
| { | { | ||||
| uint from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset; | uint from_min_stack_offset, from_max_stack_offset, to_min_stack_offset, to_max_stack_offset; | ||||
| uint type_stack_offset, steps_stack_offset, result_stack_offset; | uint type_stack_offset, steps_stack_offset, result_stack_offset; | ||||
| svm_unpack_node_uchar4(parameters_stack_offsets, | svm_unpack_node_uchar4(parameters_stack_offsets, | ||||
| &from_min_stack_offset, | &from_min_stack_offset, | ||||
| &from_max_stack_offset, | &from_max_stack_offset, | ||||
| &to_min_stack_offset, | &to_min_stack_offset, | ||||
| &to_max_stack_offset); | &to_max_stack_offset); | ||||
| svm_unpack_node_uchar3( | svm_unpack_node_uchar3( | ||||
| results_stack_offsets, &type_stack_offset, &steps_stack_offset, &result_stack_offset); | results_stack_offsets, &type_stack_offset, &steps_stack_offset, &result_stack_offset); | ||||
| uint4 defaults = read_node(kg, offset); | uint4 defaults = read_node(kg, &offset); | ||||
| uint4 defaults2 = read_node(kg, offset); | uint4 defaults2 = read_node(kg, &offset); | ||||
| float value = stack_load_float(stack, value_stack_offset); | float value = stack_load_float(stack, value_stack_offset); | ||||
| float from_min = stack_load_float_default(stack, from_min_stack_offset, defaults.x); | float from_min = stack_load_float_default(stack, from_min_stack_offset, defaults.x); | ||||
| float from_max = stack_load_float_default(stack, from_max_stack_offset, defaults.y); | float from_max = stack_load_float_default(stack, from_max_stack_offset, defaults.y); | ||||
| float to_min = stack_load_float_default(stack, to_min_stack_offset, defaults.z); | float to_min = stack_load_float_default(stack, to_min_stack_offset, defaults.z); | ||||
| float to_max = stack_load_float_default(stack, to_max_stack_offset, defaults.w); | float to_max = stack_load_float_default(stack, to_max_stack_offset, defaults.w); | ||||
| float steps = stack_load_float_default(stack, steps_stack_offset, defaults2.x); | float steps = stack_load_float_default(stack, steps_stack_offset, defaults2.x); | ||||
| Show All 23 Lines | switch (type_stack_offset) { | ||||
| } | } | ||||
| } | } | ||||
| result = to_min + factor * (to_max - to_min); | result = to_min + factor * (to_max - to_min); | ||||
| } | } | ||||
| else { | else { | ||||
| result = 0.0f; | result = 0.0f; | ||||
| } | } | ||||
| stack_store_float(stack, result_stack_offset, result); | stack_store_float(stack, result_stack_offset, result); | ||||
| return offset; | |||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||