diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-11-04 14:50:29 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2014-11-04 14:55:40 +0300 |
commit | 176f0102eaacc9f9caa5de24326137a8c3fa0f89 (patch) | |
tree | 1cf7a2ac76cba32606919483d776b2755c8e75a5 /source/blender/nodes | |
parent | 988b3d718835c1474353ff3aa04fce5e17ed2f2e (diff) |
Fix T42445: Clamp flag has no effect on result value in Math and MixRGB shader nodes (Blender Render)
Quite striaghtforward implementation, with the only weird thing that for some reason
my video driver wasn't happy with calling the function "clamp" giving some weirdo
shader compilation error messages.
Called the GPU function clamp_val which can handle float and vec3.
Diffstat (limited to 'source/blender/nodes')
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_math.c | 12 | ||||
-rw-r--r-- | source/blender/nodes/shader/nodes/node_shader_mixRgb.c | 12 |
2 files changed, 20 insertions, 4 deletions
diff --git a/source/blender/nodes/shader/nodes/node_shader_math.c b/source/blender/nodes/shader/nodes/node_shader_math.c index dc5971909d2..a33b33682ce 100644 --- a/source/blender/nodes/shader/nodes/node_shader_math.c +++ b/source/blender/nodes/shader/nodes/node_shader_math.c @@ -222,7 +222,9 @@ static void node_shader_exec_math(void *UNUSED(data), int UNUSED(thread), bNode break; } } - + if (node->custom2 & SHD_MATH_CLAMP) { + CLAMP(r, 0.0f, 1.0f); + } out[0]->vec[0] = r; } @@ -272,7 +274,13 @@ static int gpu_shader_math(GPUMaterial *mat, bNode *node, bNodeExecData *UNUSED( default: return 0; } - + + if (node->custom2 & SHD_MATH_CLAMP) { + float min[3] = {0.0f, 0.0f, 0.0f}; + float max[3] = {1.0f, 1.0f, 1.0f}; + GPU_link(mat, "clamp_val", out[0].link, GPU_uniform(min), GPU_uniform(max), &out[0].link); + } + return 1; } diff --git a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c index 2da51c19ef8..7d052810489 100644 --- a/source/blender/nodes/shader/nodes/node_shader_mixRgb.c +++ b/source/blender/nodes/shader/nodes/node_shader_mixRgb.c @@ -59,6 +59,9 @@ static void node_shader_exec_mix_rgb(void *UNUSED(data), int UNUSED(thread), bNo nodestack_get_vec(vec, SOCK_VECTOR, in[2]); ramp_blend(node->custom1, col, fac, vec); + if (node->custom2 & SHD_MIXRGB_CLAMP) { + CLAMP3(col, 0.0f, 1.0f); + } copy_v3_v3(out[0]->vec, col); } @@ -68,8 +71,13 @@ static int gpu_shader_mix_rgb(GPUMaterial *mat, bNode *node, bNodeExecData *UNUS "mix_screen", "mix_div", "mix_diff", "mix_dark", "mix_light", "mix_overlay", "mix_dodge", "mix_burn", "mix_hue", "mix_sat", "mix_val", "mix_color", "mix_soft", "mix_linear"}; - - return GPU_stack_link(mat, names[node->custom1], in, out); + int ret = GPU_stack_link(mat, names[node->custom1], in, out); + if (ret && node->custom2 & SHD_MIXRGB_CLAMP) { + float min[3] = {0.0f, 0.0f, 0.0f}; + float max[3] = {1.0f, 1.0f, 1.0f}; + GPU_link(mat, "clamp_val", out[0].link, GPU_uniform(min), GPU_uniform(max), &out[0].link); + } + return ret; } |