diff options
author | Thomas Dinges <blender@dingto.org> | 2013-05-20 18:38:47 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2013-05-20 18:38:47 +0400 |
commit | 38dc85f296a27a5641d296c8f41834db41dac18b (patch) | |
tree | b47567b3c6fd455a6a92b359fc92509ff33e85fb /source/blender/nodes | |
parent | 0fb5c9117fdb9ad24184a2dad2ad1c8c66565aaa (diff) |
Math Node:
* Added a Modulo operation to the math node, available in Compositor, Shader and Texture Nodes.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 10 | ||||
-rw-r--r-- | source/blender/nodes/texture/nodes/node_texture_math.c | 9 |
2 files changed, 18 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 c3e2fc54c78..bef777e5d59 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -203,6 +203,14 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode out[0]->vec[0] = 0.0f; } break; + case 17: /* Modulo */ + { + if (in[1]->vec[0] == 0.0f) + out[0]->vec[0] = 0.0f; + else + out[0]->vec[0] = fmod(in[0]->vec[0], in[1]->vec[0]); + } + break; } } @@ -211,7 +219,7 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( static const char *names[] = {"math_add", "math_subtract", "math_multiply", "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_round", "math_less_than", "math_greater_than", "math_modulo"}; switch (node->custom1) { case 0: diff --git a/source/blender/nodes/texture/nodes/node_texture_math.c b/source/blender/nodes/texture/nodes/node_texture_math.c index 03349a57832..1e456416159 100644 --- a/source/blender/nodes/texture/nodes/node_texture_math.c +++ b/source/blender/nodes/texture/nodes/node_texture_math.c @@ -174,6 +174,15 @@ static void valuefn(float *out, TexParams *p, bNode *node, bNodeStack **in, shor } break; + case 17: /* Modulo */ + { + if (in1 == 0.0f) + *out = 0.0f; + else + *out= fmod(in0, in1); + } + break; + default: fprintf(stderr, "%s:%d: unhandeld value in switch statement: %d\n", |