48template<
typename Callback>
52 if (info ==
nullptr) {
56 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
57 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
60 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
61 callback(exec_preset, math_function, *info);
67 return dispatch(exec_preset_slow, [](
float a) {
return expf(a); });
69 return dispatch(exec_preset_fast, [](
float a) {
return safe_sqrtf(a); });
73 return dispatch(exec_preset_fast, [](
float a) {
return fabs(a); });
75 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
DEG2RAD(a); });
77 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
RAD2DEG(a); });
79 return dispatch(exec_preset_fast, [](
float a) {
return compatible_signf(a); });
81 return dispatch(exec_preset_fast, [](
float a) {
return floorf(a + 0.5f); });
83 return dispatch(exec_preset_fast, [](
float a) {
return floorf(a); });
85 return dispatch(exec_preset_fast, [](
float a) {
return ceilf(a); });
87 return dispatch(exec_preset_fast, [](
float a) {
return a -
floorf(a); });
89 return dispatch(exec_preset_fast, [](
float a) {
return a >= 0.0f ?
floorf(a) :
ceilf(a); });
91 return dispatch(exec_preset_slow, [](
float a) {
return sinf(a); });
93 return dispatch(exec_preset_slow, [](
float a) {
return cosf(a); });
95 return dispatch(exec_preset_slow, [](
float a) {
return tanf(a); });
97 return dispatch(exec_preset_slow, [](
float a) {
return sinhf(a); });
99 return dispatch(exec_preset_slow, [](
float a) {
return coshf(a); });
101 return dispatch(exec_preset_slow, [](
float a) {
return tanhf(a); });
103 return dispatch(exec_preset_slow, [](
float a) {
return safe_asinf(a); });
105 return dispatch(exec_preset_slow, [](
float a) {
return safe_acosf(a); });
107 return dispatch(exec_preset_slow, [](
float a) {
return atanf(a); });
115template<
typename Callback>
119 if (info ==
nullptr) {
123 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
124 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
127 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
128 callback(exec_preset, math_function, *info);
134 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a +
b; });
136 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a -
b; });
138 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a *
b; });
140 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_divide(a,
b); });
142 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_powf(a,
b); });
144 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_logf(a,
b); });
146 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::min(a,
b); });
148 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::max(a,
b); });
150 return dispatch(exec_preset_fast, [](
float a,
float b) {
return (
float)(a <
b); });
152 return dispatch(exec_preset_fast, [](
float a,
float b) {
return (
float)(a >
b); });
154 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_modf(a,
b); });
156 return dispatch(exec_preset_fast, [](
float a,
float b) {
return safe_floored_modf(a,
b); });
158 return dispatch(exec_preset_fast,
161 return dispatch(exec_preset_slow, [](
float a,
float b) {
return atan2f(a,
b); });
163 return dispatch(exec_preset_fast, [](
float a,
float b) {
return pingpongf(a,
b); });
171template<
typename Callback>
175 if (info ==
nullptr) {
180 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
181 callback(exec_preset, math_function, *info);
187 return dispatch(mf::build::exec_presets::AllSpanOrSingle(),
188 [](
float a,
float b,
float c) {
return a *
b + c; });
190 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
191 [](
float a,
float b,
float c) ->
float {
192 return ((a ==
b) || (
fabsf(a -
b) <=
fmaxf(c, FLT_EPSILON))) ? 1.0f : 0.0f;
195 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
196 [](
float a,
float b,
float c) {
return smoothminf(a,
b, c); });
198 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0, 1>(),
199 [](
float a,
float b,
float c) {
return -
smoothminf(-a, -
b, c); });
201 return dispatch(mf::build::exec_presets::SomeSpanOrSingle<0>(),
202 [](
float a,
float b,
float c) {
return wrapf(a,
b, c); });
210template<
typename Callback>
217 if (info ==
nullptr) {
221 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
222 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
225 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
226 callback(exec_preset, math_function, *info);
232 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a +
b; });
234 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a -
b; });
236 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a *
b; });
240 return dispatch(exec_preset_fast,
245 return dispatch(exec_preset_fast,
248 return dispatch(exec_preset_fast,
265template<
typename Callback>
272 if (info ==
nullptr) {
276 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
279 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
280 callback(exec_preset, math_function, *info);
298template<
typename Callback>
305 if (info ==
nullptr) {
309 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
310 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
313 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
314 callback(exec_preset, math_function, *info);
326 return dispatch(exec_preset_fast,
337template<
typename Callback>
344 if (info ==
nullptr) {
348 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
351 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
352 callback(exec_preset, math_function, *info);
358 return dispatch(exec_preset_slow,
369template<
typename Callback>
376 if (info ==
nullptr) {
380 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
383 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
384 callback(exec_preset, math_function, *info);
390 return dispatch(exec_preset_fast, [](
float3 in) {
return length(in); });
400template<
typename Callback>
405 if (info ==
nullptr) {
409 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
412 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
413 callback(exec_preset, math_function, *info);
419 return dispatch(exec_preset_fast, [](
float3 a,
float b) {
return a *
b; });
429template<
typename Callback>
436 if (info ==
nullptr) {
440 static auto exec_preset_fast = mf::build::exec_presets::AllSpanOrSingle();
441 static auto exec_preset_slow = mf::build::exec_presets::Materialized();
444 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
445 callback(exec_preset, math_function, *info);
452 return dispatch(exec_preset_fast, [](
float3 in) {
return normalize(in); });
454 return dispatch(exec_preset_fast, [](
float3 in) {
return floor(in); });
456 return dispatch(exec_preset_fast, [](
float3 in) {
return ceil(in); });
458 return dispatch(exec_preset_fast, [](
float3 in) {
return fract(in); });
460 return dispatch(exec_preset_fast, [](
float3 in) {
return abs(in); });
462 return dispatch(exec_preset_slow,
465 return dispatch(exec_preset_slow,
468 return dispatch(exec_preset_slow,
MINLINE float safe_sqrtf(float a)
MINLINE float safe_logf(float a, float base)
MINLINE float safe_acosf(float a)
MINLINE float safe_modf(float a, float b)
MINLINE float safe_powf(float base, float exponent)
MINLINE float safe_divide(float a, float b)
MINLINE float safe_asinf(float a)
MINLINE float safe_inverse_sqrtf(float a)
@ NODE_VECTOR_MATH_NORMALIZE
@ NODE_VECTOR_MATH_LENGTH
@ NODE_VECTOR_MATH_CROSS_PRODUCT
@ NODE_VECTOR_MATH_MODULO
@ NODE_VECTOR_MATH_COSINE
@ NODE_VECTOR_MATH_REFLECT
@ NODE_VECTOR_MATH_REFRACT
@ NODE_VECTOR_MATH_DOT_PRODUCT
@ NODE_VECTOR_MATH_ABSOLUTE
@ NODE_VECTOR_MATH_DIVIDE
@ NODE_VECTOR_MATH_TANGENT
@ NODE_VECTOR_MATH_DISTANCE
@ NODE_VECTOR_MATH_FRACTION
@ NODE_VECTOR_MATH_PROJECT
@ NODE_VECTOR_MATH_MULTIPLY
@ NODE_VECTOR_MATH_MAXIMUM
@ NODE_VECTOR_MATH_FACEFORWARD
@ NODE_VECTOR_MATH_SUBTRACT
@ NODE_VECTOR_MATH_MULTIPLY_ADD
@ NODE_VECTOR_MATH_MINIMUM
@ NODE_MATH_FLOORED_MODULO
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
local_group_size(16, 16) .push_constant(Type b
DEGForeachIDComponentCallback callback
MINLINE float smoothminf(float a, float b, float c)
MINLINE float pingpongf(float value, float scale)
MINLINE float compatible_signf(float f)
MINLINE float wrapf(float value, float max, float min)
MINLINE float safe_floored_modf(float a, float b)
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float3 reflect(const float3 incident, const float3 unit_normal)
ccl_device_inline float3 refract(const float3 incident, const float3 normal, const float eta)
ccl_device_inline float3 faceforward(const float3 vector, const float3 incident, const float3 reference)
ccl_device_inline float3 ceil(const float3 a)
bool try_dispatch_float_math_fl_fl_to_fl(const int operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback)
const FloatMathOperationInfo * get_float3_math_operation_info(const int operation)
bool try_dispatch_float_math_fl3_fl3_to_fl(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl_to_fl(const int operation, Callback &&callback)
const FloatMathOperationInfo * get_float_compare_operation_info(const int operation)
const FloatMathOperationInfo * get_float_math_operation_info(const int operation)
bool try_dispatch_float_math_fl3_fl_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_fl_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
bool try_dispatch_float_math_fl_fl_fl_to_fl(const int operation, Callback &&callback)
bool try_dispatch_float_math_fl3_fl3_fl3_to_fl3(const NodeVectorMathOperation operation, Callback &&callback)
VecBase< float, 3 > float3
vector project(vector v, vector v_proj)
float distance(float a, float b)
StringRefNull shader_name
StringRefNull title_case_name
FloatMathOperationInfo()=delete
FloatMathOperationInfo(StringRefNull title_case_name, StringRefNull shader_name)
ccl_device_inline int abs(int x)
ccl_device_inline int mod(int x, int m)