diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-12-04 18:17:25 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2015-12-05 23:21:14 +0300 |
commit | ed5dbb0a7b2bc7bef3776d31eaf466ec8740560f (patch) | |
tree | 37c12781edd198932cdd4e47c950460d9f4271cc /intern/cycles/render/nodes.cpp | |
parent | 258564a7b4b26098dc2fabc28aa5a203d2754eff (diff) |
Cycles: Implement extrapolation for RGB curves
Previously RGB Curves node will clamp input to 0..1 which is rather useless
when one wants to use HDR image textures and do bit of correction on them.
Now kernel code supports extrapolation of baked LUT based on first/last two
table points and performs linear extrapolation.
The only tricky part is to guess the range to bake the LUT for. Currently
it's using simple approach -- minmax of the input curves. While this behaves
ok for the simple cases it's easy to trick the system up causing incorrect
results.
Not sure we can solve those issues in a general case and since the new code
is giving more expected results it's not that bad actually. In the worst
case artist migh always create explicit point to make sure LUT is created
for the needed HDR range.
Reviewers: brecht, juicyfruit
Subscribers: sebastian_k
Differential Revision: https://developer.blender.org/D1658
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index cece0c37f59..fd8410ce71b 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -4316,6 +4316,9 @@ RGBCurvesNode::RGBCurvesNode() add_input("Fac", SHADER_SOCKET_FLOAT); add_input("Color", SHADER_SOCKET_COLOR); add_output("Color", SHADER_SOCKET_COLOR); + + min_x = 0.0f; + max_x = 1.0f; } void RGBCurvesNode::compile(SVMCompiler& compiler) @@ -4328,7 +4331,12 @@ void RGBCurvesNode::compile(SVMCompiler& compiler) compiler.stack_assign(color_in); compiler.stack_assign(color_out); - compiler.add_node(NODE_RGB_CURVES, fac_in->stack_offset, color_in->stack_offset, color_out->stack_offset); + compiler.add_node(NODE_RGB_CURVES, + compiler.encode_uchar4(fac_in->stack_offset, + color_in->stack_offset, + color_out->stack_offset), + __float_as_int(min_x), + __float_as_int(max_x)); compiler.add_array(curves, RAMP_TABLE_SIZE); } @@ -4343,6 +4351,8 @@ void RGBCurvesNode::compile(OSLCompiler& compiler) } compiler.parameter_color_array("ramp", ramp, RAMP_TABLE_SIZE); + compiler.parameter("min_x", min_x); + compiler.parameter("max_x", max_x); compiler.add(this, "node_rgb_curves"); } |