diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-11 18:39:37 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-12-11 18:39:37 +0400 |
commit | 43c04eefe32773b708d85ea0db95564e71f4870e (patch) | |
tree | adcbc13cd57ce4f48f7fc26e123e3ca11c71cb2c /intern/cycles/blender | |
parent | 7c81952179f0ff08cfdd8f571eb1c0f06e224070 (diff) |
Cycles: RGB and Vector Curves nodes now supported, with the limitation that the
range must be left to the default (0..1 and -1..1).
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 14 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 30 |
2 files changed, 41 insertions, 3 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index c9380d8d58b..848a9a199f9 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -173,7 +173,6 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen switch(b_node.type()) { /* not supported */ - case BL::ShaderNode::type_CURVE_VEC: break; case BL::ShaderNode::type_GEOMETRY: break; case BL::ShaderNode::type_MATERIAL: break; case BL::ShaderNode::type_MATERIAL_EXT: break; @@ -193,9 +192,18 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen node = proxy; break; } + case BL::ShaderNode::type_CURVE_VEC: { + BL::ShaderNodeVectorCurve b_curve_node(b_node); + VectorCurvesNode *curves = new VectorCurvesNode(); + curvemapping_color_to_array(b_curve_node.mapping(), curves->curves, RAMP_TABLE_SIZE, false); + node = curves; + break; + } case BL::ShaderNode::type_CURVE_RGB: { - RGBCurvesNode *ramp = new RGBCurvesNode(); - node = ramp; + BL::ShaderNodeRGBCurve b_curve_node(b_node); + RGBCurvesNode *curves = new RGBCurvesNode(); + curvemapping_color_to_array(b_curve_node.mapping(), curves->curves, RAMP_TABLE_SIZE, true); + node = curves; break; } case BL::ShaderNode::type_VALTORGB: { diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index 0a9f2dd06aa..fbcbe15ec5a 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -52,6 +52,36 @@ static inline void colorramp_to_array(BL::ColorRamp ramp, float4 *data, int size } } +static inline void curvemapping_color_to_array(BL::CurveMapping cumap, float4 *data, int size, bool rgb_curve) +{ + cumap.update(); + + BL::CurveMap mapR = cumap.curves[0]; + BL::CurveMap mapG = cumap.curves[1]; + BL::CurveMap mapB = cumap.curves[2]; + + if(rgb_curve) { + BL::CurveMap mapI = cumap.curves[3]; + + for(int i = 0; i < size; i++) { + float t = i/(float)(size-1); + + data[i][0] = mapR.evaluate(mapI.evaluate(t)); + data[i][1] = mapG.evaluate(mapI.evaluate(t)); + data[i][2] = mapB.evaluate(mapI.evaluate(t)); + } + } + else { + for(int i = 0; i < size; i++) { + float t = i/(float)(size-1); + + data[i][0] = mapR.evaluate(t); + data[i][1] = mapG.evaluate(t); + data[i][2] = mapB.evaluate(t); + } + } +} + static inline bool BKE_object_is_modified(BL::Object self, BL::Scene scene, bool preview) { return self.is_modified(scene, (preview)? (1<<0): (1<<1))? true: false; |