diff options
author | Alexander Gavrilov <angavrilov@gmail.com> | 2016-07-31 00:30:36 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-07-31 03:18:23 +0300 |
commit | ea2ebf7a00f9adef9c14aaa24b79532b44043eba (patch) | |
tree | 3d683f671a4051cd8421739592e8cb70fdac88ea /intern/cycles/kernel/shaders/node_rgb_ramp.osl | |
parent | f4bcc97729c430aac16c41f7c012a0f4c1fe6bb2 (diff) |
Cycles: constant folding for RGB/Vector Curves and Color Ramp.
These are complex nodes, and it's conceivable they may end up constant
in some circumstances within node groups, so folding support is useful.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D2084
Diffstat (limited to 'intern/cycles/kernel/shaders/node_rgb_ramp.osl')
-rw-r--r-- | intern/cycles/kernel/shaders/node_rgb_ramp.osl | 21 |
1 files changed, 3 insertions, 18 deletions
diff --git a/intern/cycles/kernel/shaders/node_rgb_ramp.osl b/intern/cycles/kernel/shaders/node_rgb_ramp.osl index c0ae74d6b33..24b8728b999 100644 --- a/intern/cycles/kernel/shaders/node_rgb_ramp.osl +++ b/intern/cycles/kernel/shaders/node_rgb_ramp.osl @@ -14,8 +14,7 @@ * limitations under the License. */ -#include "stdosl.h" -#include "oslutil.h" +#include "node_ramp_util.h" shader node_rgb_ramp( color ramp_color[] = {0.0}, @@ -26,21 +25,7 @@ shader node_rgb_ramp( output color Color = 0.0, output float Alpha = 1.0) { - int table_size = arraylength(ramp_color); - float f = clamp(Fac, 0.0, 1.0) * (table_size - 1); - - /* clamp int as well in case of NaN */ - int i = (int)f; - if (i < 0) i = 0; - if (i >= table_size) i = table_size - 1; - float t = f - (float)i; - - Color = ramp_color[i]; - Alpha = ramp_alpha[i]; - - if (interpolate && t > 0.0) { - Color = (1.0 - t) * Color + t * ramp_color[i + 1]; - Alpha = (1.0 - t) * Alpha + t * ramp_alpha[i + 1]; - } + Color = rgb_ramp_lookup(ramp_color, Fac, interpolate, 0); + Alpha = rgb_ramp_lookup(ramp_alpha, Fac, interpolate, 0); } |