From ed5dbb0a7b2bc7bef3776d31eaf466ec8740560f Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 4 Dec 2015 20:17:25 +0500 Subject: 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 --- intern/cycles/blender/blender_shader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'intern/cycles/blender/blender_shader.cpp') diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 38e019eb0c1..74dee206c0e 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -220,8 +220,13 @@ static ShaderNode *add_node(Scene *scene, /* existing blender nodes */ if(b_node.is_a(&RNA_ShaderNodeRGBCurve)) { BL::ShaderNodeRGBCurve b_curve_node(b_node); + BL::CurveMapping mapping(b_curve_node.mapping()); RGBCurvesNode *curves = new RGBCurvesNode(); - curvemapping_color_to_array(b_curve_node.mapping(), curves->curves, RAMP_TABLE_SIZE, true); + curvemapping_color_to_array(mapping, + curves->curves, + RAMP_TABLE_SIZE, + true); + curvemapping_minmax(mapping, true, &curves->min_x, &curves->max_x); node = curves; } if(b_node.is_a(&RNA_ShaderNodeVectorCurve)) { -- cgit v1.2.3