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:
Diffstat (limited to 'source/blender/nodes')
-rw-r--r--source/blender/nodes/shader/nodes/node_shader_math.c46
-rw-r--r--source/blender/nodes/texture/nodes/node_texture_math.c27
2 files changed, 72 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];
diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c
index d8dc2a62625..f786a293080 100644
--- a/source/blender/nodes/texture/nodes/node_texture_math.c
+++ b/source/blender/nodes/texture/nodes/node_texture_math.c
@@ -195,6 +195,33 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor
break;
}
+ case NODE_MATH_FLOOR:
+ {
+ *out = floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_CEIL:
+ {
+ *out = ceilf(in0);
+ break;
+ }
+
+ case NODE_MATH_FRACT:
+ {
+ *out = in0 - floorf(in0);
+ break;
+ }
+
+ case NODE_MATH_SQRT:
+ {
+ if (in0 > 0.0f)
+ *out = sqrtf(in0);
+ else
+ *out = 0.0f;
+ break;
+ }
+
default:
{
BLI_assert(0);