Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrii Symkin <pembem22>2022-06-23 15:29:17 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-06-23 16:02:53 +0300
commitc2a2f3553aed58ae9e4c165f8bfcad2b31dcf74b (patch)
tree236fca0080484dc7e9b1f8816e2770b4422db00d /intern/cycles/kernel/svm
parentb8403b065e222faff3dfb3e2e9aa1b3d3f56c555 (diff)
Cycles: unify math functions names
This patch unifies the names of math functions for different data types and uses overloading instead. The goal is to make it possible to swap out all the float3 variables containing RGB data with something else, with as few as possible changes to the code. It's a requirement for future spectral rendering patches. Differential Revision: https://developer.blender.org/D15276
Diffstat (limited to 'intern/cycles/kernel/svm')
-rw-r--r--intern/cycles/kernel/svm/color_util.h2
-rw-r--r--intern/cycles/kernel/svm/map_range.h8
-rw-r--r--intern/cycles/kernel/svm/mapping_util.h7
-rw-r--r--intern/cycles/kernel/svm/math_util.h4
-rw-r--r--intern/cycles/kernel/svm/voronoi.h4
5 files changed, 12 insertions, 13 deletions
diff --git a/intern/cycles/kernel/svm/color_util.h b/intern/cycles/kernel/svm/color_util.h
index fa22d4bc8c2..41f44378ff0 100644
--- a/intern/cycles/kernel/svm/color_util.h
+++ b/intern/cycles/kernel/svm/color_util.h
@@ -244,7 +244,7 @@ ccl_device float3 svm_mix_linear(float t, float3 col1, float3 col2)
ccl_device float3 svm_mix_clamp(float3 col)
{
- return saturate3(col);
+ return saturate(col);
}
ccl_device_noinline_cpu float3 svm_mix(NodeMix type, float fac, float3 c1, float3 c2)
diff --git a/intern/cycles/kernel/svm/map_range.h b/intern/cycles/kernel/svm/map_range.h
index ff0e462041c..ea85bc43b74 100644
--- a/intern/cycles/kernel/svm/map_range.h
+++ b/intern/cycles/kernel/svm/map_range.h
@@ -112,10 +112,10 @@ ccl_device_noinline int svm_node_vector_map_range(KernelGlobals kg,
switch (range_type_stack_offset) {
default:
case NODE_MAP_RANGE_LINEAR:
- factor = safe_divide_float3_float3((value - from_min), (from_max - from_min));
+ factor = safe_divide((value - from_min), (from_max - from_min));
break;
case NODE_MAP_RANGE_STEPPED: {
- factor = safe_divide_float3_float3((value - from_min), (from_max - from_min));
+ factor = safe_divide((value - from_min), (from_max - from_min));
factor = make_float3((steps.x > 0.0f) ? floorf(factor.x * (steps.x + 1.0f)) / steps.x : 0.0f,
(steps.y > 0.0f) ? floorf(factor.y * (steps.y + 1.0f)) / steps.y : 0.0f,
(steps.z > 0.0f) ? floorf(factor.z * (steps.z + 1.0f)) / steps.z :
@@ -123,13 +123,13 @@ ccl_device_noinline int svm_node_vector_map_range(KernelGlobals kg,
break;
}
case NODE_MAP_RANGE_SMOOTHSTEP: {
- factor = safe_divide_float3_float3((value - from_min), (from_max - from_min));
+ factor = safe_divide((value - from_min), (from_max - from_min));
factor = clamp(factor, zero_float3(), one_float3());
factor = (make_float3(3.0f, 3.0f, 3.0f) - 2.0f * factor) * (factor * factor);
break;
}
case NODE_MAP_RANGE_SMOOTHERSTEP: {
- factor = safe_divide_float3_float3((value - from_min), (from_max - from_min));
+ factor = safe_divide((value - from_min), (from_max - from_min));
factor = clamp(factor, zero_float3(), one_float3());
factor = factor * factor * factor * (factor * (factor * 6.0f - 15.0f) + 10.0f);
break;
diff --git a/intern/cycles/kernel/svm/mapping_util.h b/intern/cycles/kernel/svm/mapping_util.h
index c616d4018c4..13257c762e7 100644
--- a/intern/cycles/kernel/svm/mapping_util.h
+++ b/intern/cycles/kernel/svm/mapping_util.h
@@ -13,13 +13,12 @@ svm_mapping(NodeMappingType type, float3 vector, float3 location, float3 rotatio
case NODE_MAPPING_TYPE_POINT:
return transform_direction(&rotationTransform, (vector * scale)) + location;
case NODE_MAPPING_TYPE_TEXTURE:
- return safe_divide_float3_float3(
- transform_direction_transposed(&rotationTransform, (vector - location)), scale);
+ return safe_divide(transform_direction_transposed(&rotationTransform, (vector - location)),
+ scale);
case NODE_MAPPING_TYPE_VECTOR:
return transform_direction(&rotationTransform, (vector * scale));
case NODE_MAPPING_TYPE_NORMAL:
- return safe_normalize(
- transform_direction(&rotationTransform, safe_divide_float3_float3(vector, scale)));
+ return safe_normalize(transform_direction(&rotationTransform, safe_divide(vector, scale)));
default:
return make_float3(0.0f, 0.0f, 0.0f);
}
diff --git a/intern/cycles/kernel/svm/math_util.h b/intern/cycles/kernel/svm/math_util.h
index 89bd4a501a7..d90d4f0f794 100644
--- a/intern/cycles/kernel/svm/math_util.h
+++ b/intern/cycles/kernel/svm/math_util.h
@@ -24,7 +24,7 @@ ccl_device void svm_vector_math(ccl_private float *value,
*vector = a * b;
break;
case NODE_VECTOR_MATH_DIVIDE:
- *vector = safe_divide_float3_float3(a, b);
+ *vector = safe_divide(a, b);
break;
case NODE_VECTOR_MATH_CROSS_PRODUCT:
*vector = cross(a, b);
@@ -60,7 +60,7 @@ ccl_device void svm_vector_math(ccl_private float *value,
*vector = safe_normalize(a);
break;
case NODE_VECTOR_MATH_SNAP:
- *vector = floor(safe_divide_float3_float3(a, b)) * b;
+ *vector = floor(safe_divide(a, b)) * b;
break;
case NODE_VECTOR_MATH_FLOOR:
*vector = floor(a);
diff --git a/intern/cycles/kernel/svm/voronoi.h b/intern/cycles/kernel/svm/voronoi.h
index 4ff1047aab7..53c1bda0904 100644
--- a/intern/cycles/kernel/svm/voronoi.h
+++ b/intern/cycles/kernel/svm/voronoi.h
@@ -1079,7 +1079,7 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
default:
kernel_assert(0);
}
- position_out = safe_divide_float3_float(position_out, scale);
+ position_out = safe_divide(position_out, scale);
break;
}
@@ -1126,7 +1126,7 @@ ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg,
default:
kernel_assert(0);
}
- position_out_4d = safe_divide_float4_float(position_out_4d, scale);
+ position_out_4d = safe_divide(position_out_4d, scale);
position_out = make_float3(position_out_4d.x, position_out_4d.y, position_out_4d.z);
w_out = position_out_4d.w;
}