diff options
Diffstat (limited to 'source/blender/nodes/shader')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index 0a75a0f8bf0..605c869099a 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -226,6 +226,46 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode r = atan2(a, b); break; } + case NODE_MATH_FLOOR: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = floorf(a); + else + r = floorf(b); + break; + } + case NODE_MATH_CEIL: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = ceilf(a); + else + r = ceilf(b); + break; + } + case NODE_MATH_FRACT: + { + if (in[0]->hasinput || !in[1]->hasinput) /* This one only takes one input, so we've got to choose. */ + r = a - floorf(a); + else + r = b - floorf(b); + break; + } + case NODE_MATH_SQRT: + { + if (in[0]->hasinput || !in[1]->hasinput) { /* This one only takes one input, so we've got to choose. */ + if (a > 0) + r = sqrt(a); + else + r = 0.0; + } + else { + if (b > 0) + r = sqrt(b); + else + r = 0.0; + } + break; + } } if (node->custom2 & SHD_MATH_CLAMP) { CLAMP(r, 0.0f, 1.0f); @@ -240,7 +280,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( "math_divide", "math_sine", "math_cosine", "math_tangent", "math_asin", "math_acos", "math_atan", "math_pow", "math_log", "math_min", "math_max", "math_round", "math_less_than", "math_greater_than", "math_modulo", "math_abs", - "math_atan2" + "math_atan2", "math_floor", "math_ceil", "math_fract", "math_sqrt" }; switch (node->custom1) { @@ -266,6 +306,10 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( case NODE_MATH_ATAN: case NODE_MATH_ROUND: case NODE_MATH_ABS: + case NODE_MATH_FLOOR: + case NODE_MATH_FRACT: + case NODE_MATH_CEIL: + case NODE_MATH_SQRT: if (in[0].hasinput || !in[1].hasinput) { /* use only first item and terminator */ GPUNodeStack tmp_in[2]; |