46 template<
typename Callback>
50 if (info ==
nullptr) {
58 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
59 callback(exec_preset, math_function, *info);
65 return dispatch(exec_preset_slow, [](
float a) {
return expf(
a); });
67 return dispatch(exec_preset_fast, [](
float a) {
return safe_sqrtf(
a); });
71 return dispatch(exec_preset_fast, [](
float a) {
return fabs(
a); });
73 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
DEG2RAD(
a); });
75 return dispatch(exec_preset_fast, [](
float a) {
return (
float)
RAD2DEG(
a); });
79 return dispatch(exec_preset_fast, [](
float a) {
return floorf(
a + 0.5f); });
81 return dispatch(exec_preset_fast, [](
float a) {
return floorf(
a); });
83 return dispatch(exec_preset_fast, [](
float a) {
return ceilf(
a); });
85 return dispatch(exec_preset_fast, [](
float a) {
return a -
floorf(
a); });
87 return dispatch(exec_preset_fast, [](
float a) {
return a >= 0.0f ?
floorf(
a) :
ceilf(
a); });
89 return dispatch(exec_preset_slow, [](
float a) {
return sinf(
a); });
91 return dispatch(exec_preset_slow, [](
float a) {
return cosf(
a); });
93 return dispatch(exec_preset_slow, [](
float a) {
return tanf(
a); });
95 return dispatch(exec_preset_slow, [](
float a) {
return sinhf(
a); });
97 return dispatch(exec_preset_slow, [](
float a) {
return coshf(
a); });
99 return dispatch(exec_preset_slow, [](
float a) {
return tanhf(
a); });
101 return dispatch(exec_preset_slow, [](
float a) {
return safe_asinf(
a); });
103 return dispatch(exec_preset_slow, [](
float a) {
return safe_acosf(
a); });
105 return dispatch(exec_preset_slow, [](
float a) {
return atanf(
a); });
113 template<
typename Callback>
117 if (info ==
nullptr) {
125 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
126 callback(exec_preset, math_function, *info);
132 return dispatch(exec_preset_fast, [](
float a,
float b) {
return a +
b; });
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 safe_divide(
a,
b); });
140 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_powf(
a,
b); });
142 return dispatch(exec_preset_slow, [](
float a,
float b) {
return safe_logf(
a,
b); });
144 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::min(
a,
b); });
146 return dispatch(exec_preset_fast, [](
float a,
float b) {
return std::max(
a,
b); });
148 return dispatch(exec_preset_fast, [](
float a,
float b) {
return (
float)(
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 safe_modf(
a,
b); });
154 return dispatch(exec_preset_fast,
157 return dispatch(exec_preset_slow, [](
float a,
float b) {
return atan2f(
a,
b); });
159 return dispatch(exec_preset_fast, [](
float a,
float b) {
return pingpongf(
a,
b); });
167 template<
typename Callback>
171 if (info ==
nullptr) {
176 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
177 callback(exec_preset, math_function, *info);
184 [](
float a,
float b,
float c) {
return a *
b +
c; });
187 [](
float a,
float b,
float c) ->
float {
188 return ((
a ==
b) || (
fabsf(
a -
b) <=
fmaxf(
c, FLT_EPSILON))) ? 1.0f : 0.0f;
198 [](
float a,
float b,
float c) {
return wrapf(
a,
b,
c); });
206 template<
typename Callback>
213 if (info ==
nullptr) {
221 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
222 callback(exec_preset, math_function, *info);
228 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a +
b; });
230 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a -
b; });
232 return dispatch(exec_preset_fast, [](
float3 a,
float3 b) {
return a *
b; });
236 return dispatch(exec_preset_fast,
241 return dispatch(exec_preset_fast,
244 return dispatch(exec_preset_fast,
261 template<
typename Callback>
268 if (info ==
nullptr) {
275 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
276 callback(exec_preset, math_function, *info);
294 template<
typename Callback>
301 if (info ==
nullptr) {
309 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
310 callback(exec_preset, math_function, *info);
322 return dispatch(exec_preset_fast,
333 template<
typename Callback>
340 if (info ==
nullptr) {
347 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
348 callback(exec_preset, math_function, *info);
354 return dispatch(exec_preset_slow,
365 template<
typename Callback>
372 if (info ==
nullptr) {
379 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
380 callback(exec_preset, math_function, *info);
386 return dispatch(exec_preset_fast, [](
float3 in) {
return length(in); });
396 template<
typename Callback>
401 if (info ==
nullptr) {
408 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
409 callback(exec_preset, math_function, *info);
415 return dispatch(exec_preset_fast, [](
float3 a,
float b) {
return a *
b; });
425 template<
typename Callback>
432 if (info ==
nullptr) {
440 auto dispatch = [&](
auto exec_preset,
auto math_function) ->
bool {
441 callback(exec_preset, math_function, *info);
447 return dispatch(exec_preset_fast,
450 return dispatch(exec_preset_fast, [](
float3 in) {
return floor(in); });
452 return dispatch(exec_preset_fast, [](
float3 in) {
return ceil(in); });
454 return dispatch(exec_preset_fast, [](
float3 in) {
return fract(in); });
456 return dispatch(exec_preset_fast, [](
float3 in) {
return abs(in); });
458 return dispatch(exec_preset_slow,
461 return dispatch(exec_preset_slow,
464 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_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
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)
ccl_device_inline float2 fabs(const float2 &a)
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)
ccl_device_inline float3 reflect(const float3 incident, const float3 normal)
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
T length(const vec_base< T, Size > &a)
T distance(const T &a, const T &b)
vec_base< T, Size > normalize(const vec_base< T, Size > &v)
vec_base< T, Size > project(const vec_base< T, Size > &p, const vec_base< T, Size > &v_proj)
T safe_divide(const T &a, const T &b)
vec_base< float, 3 > cross_high_precision(const vec_base< float, 3 > &a, const vec_base< float, 3 > &b)
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)
vec_base< float, 3 > float3
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
StringRefNull shader_name
StringRefNull title_case_name
FloatMathOperationInfo()=delete
FloatMathOperationInfo(StringRefNull title_case_name, StringRefNull shader_name)
ccl_device_inline int mod(int x, int m)