@@ -629,7 +629,7 @@ static constexpr float2 min(float2 a, float2 b, float2 c) noexcept { return min(
629629static constexpr float2 max (float2 a, float2 b, float2 c) noexcept { return max (max (a, b), c); }
630630
631631/* *
632- * @brief Clamps vector components between min and max values.
632+ * @brief Clamps vector components between min and max values. (Inclusive range)
633633 *
634634 * @param v target vector to clamp
635635 * @param min vector with minimum values
@@ -639,6 +639,14 @@ static constexpr float2 clamp(float2 v, float2 min, float2 max) noexcept
639639{
640640 return float2 (std::clamp (v.x , min.x , max.x ), std::clamp (v.y , min.y , max.y ));
641641}
642+ /* *
643+ * @brief Clamps vector components between the 0.0f and 1.0f. (Inclusive range)
644+ * @param v target vector to saturate
645+ */
646+ static constexpr float2 saturate (float2 v) noexcept
647+ {
648+ return float2 (std::clamp (v.x , 0 .0f , 1 .0f ), std::clamp (v.y , 0 .0f , 1 .0f ));
649+ }
642650
643651/* **********************************************************************************************************************
644652 * @brief Fused multiply add, calculates: mul1 * mul2 + add
@@ -916,7 +924,7 @@ static constexpr float3 min(float3 a, float3 b, float3 c) noexcept { return min(
916924static constexpr float3 max (float3 a, float3 b, float3 c) noexcept { return max (max (a, b), c); }
917925
918926/* *
919- * @brief Clamps vector components between min and max values.
927+ * @brief Clamps vector components between min and max values. (Inclusive range)
920928 *
921929 * @param v target vector to clamp
922930 * @param min vector with minimum values
@@ -926,6 +934,14 @@ static constexpr float3 clamp(float3 v, float3 min, float3 max) noexcept
926934{
927935 return float3 (std::clamp (v.x , min.x , max.x ), std::clamp (v.y , min.y , max.y ), std::clamp (v.z , min.z , max.z ));
928936}
937+ /* *
938+ * @brief Clamps vector components between the 0.0f and 1.0f. (Inclusive range)
939+ * @param v target vector to saturate
940+ */
941+ static constexpr float3 saturate (float3 v) noexcept
942+ {
943+ return float3 (std::clamp (v.x , 0 .0f , 1 .0f ), std::clamp (v.y , 0 .0f , 1 .0f ), std::clamp (v.z , 0 .0f , 1 .0f ));
944+ }
929945
930946/* **********************************************************************************************************************
931947 * @brief Fused multiply add, calculates: mul1 * mul2 + add
@@ -1225,7 +1241,7 @@ static constexpr float4 min(float4 a, float4 b, float4 c) noexcept { return min(
12251241static constexpr float4 max (float4 a, float4 b, float4 c) noexcept { return max (max (a, b), c); }
12261242
12271243/* *
1228- * @brief Clamps vector components between min and max values.
1244+ * @brief Clamps vector components between min and max values. (Inclusive range)
12291245 *
12301246 * @param v target vector to clamp
12311247 * @param min vector with minimum values
@@ -1236,6 +1252,15 @@ static constexpr float4 clamp(float4 v, float4 min, float4 max) noexcept
12361252 return float4 (std::clamp (v.x , min.x , max.x ), std::clamp (v.y , min.y , max.y ),
12371253 std::clamp (v.z , min.z , max.z ), std::clamp (v.w , min.w , max.w ));
12381254}
1255+ /* *
1256+ * @brief Clamps vector components between the 0.0f and 1.0f. (Inclusive range)
1257+ * @param v target vector to saturate
1258+ */
1259+ static constexpr float4 saturate (float4 v) noexcept
1260+ {
1261+ return float4 (std::clamp (v.x , 0 .0f , 1 .0f ), std::clamp (v.y , 0 .0f , 1 .0f ),
1262+ std::clamp (v.z , 0 .0f , 1 .0f ), std::clamp (v.w , 0 .0f , 1 .0f ));
1263+ }
12391264
12401265/* **********************************************************************************************************************
12411266 * @brief Fused multiply add, calculates: mul1 * mul2 + add
0 commit comments