diff options
author | Charlie Jolly <charlie> | 2019-12-07 15:35:07 +0300 |
---|---|---|
committer | Charlie Jolly <mistajolly@gmail.com> | 2019-12-07 15:52:42 +0300 |
commit | 958d0d4236b1cfa600a7f36f6bdc51fdd0d98a97 (patch) | |
tree | 567a1e3209e6302dd784c054b858a8b5fb92bc9f /source/blender/makesrna | |
parent | 0406eb110332a863811d7fb6228f9a7ca514e022 (diff) |
Shader Nodes: Add Interpolation modes to Map Range node
Modes: Linear interpolation (default), stepped linear, smoothstep and smootherstep.
This also includes an additional option for the **Clamp node** to switch between **Min Max** (default) and **Range** mode.
This was needed to allow clamping when **To Max** is less than **To Min**.
Reviewed By: JacquesLucke, brecht
Differential Revision: https://developer.blender.org/D5827
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nodetree.c | 47 |
2 files changed, 49 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 9290b81f1af..318522427d8 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -188,6 +188,8 @@ extern const EnumPropertyItem rna_enum_node_math_items[]; extern const EnumPropertyItem rna_enum_mapping_type_items[]; extern const EnumPropertyItem rna_enum_node_vec_math_items[]; extern const EnumPropertyItem rna_enum_node_filter_items[]; +extern const EnumPropertyItem rna_enum_node_map_range_items[]; +extern const EnumPropertyItem rna_enum_node_clamp_items[]; extern const EnumPropertyItem rna_enum_ramp_blend_items[]; diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 272a4522152..0a47830b1e3 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -226,6 +226,36 @@ const EnumPropertyItem rna_enum_node_vec_math_items[] = { {0, NULL, 0, NULL, NULL}, }; +const EnumPropertyItem rna_enum_node_map_range_items[] = { + {NODE_MAP_RANGE_LINEAR, + "LINEAR", + 0, + "Linear", + "Linear interpolation between From Min and From Max values"}, + {NODE_MAP_RANGE_STEPPED, + "STEPPED", + 0, + "Stepped Linear", + "Stepped linear interpolation between From Min and From Max values"}, + {NODE_MAP_RANGE_SMOOTHSTEP, + "SMOOTHSTEP", + 0, + "Smoothstep", + "Smooth hermite edge interpolation between From Min and From Max values"}, + {NODE_MAP_RANGE_SMOOTHERSTEP, + "SMOOTHERSTEP", + 0, + "Smootherstep", + "Smoother hermite edge interpolation between From Min and From Max values"}, + {0, NULL, 0, NULL, NULL}, +}; + +const EnumPropertyItem rna_enum_node_clamp_items[] = { + {NODE_CLAMP_MINMAX, "MINMAX", 0, "Min Max", "Clamp values using Min and Max values"}, + {NODE_CLAMP_RANGE, "RANGE", 0, "Range", "Clamp values between Min and Max range"}, + {0, NULL, 0, NULL, NULL}, +}; + static const EnumPropertyItem rna_enum_node_tex_dimensions_items[] = { {1, "1D", 0, "1D", "Use the scalar value W as input"}, {2, "2D", 0, "2D", "Use the 2D vector (x, y) as input. The z component is ignored"}, @@ -3921,6 +3951,17 @@ static void def_frame(StructRNA *srna) RNA_def_property_update(prop, NC_NODE | ND_DISPLAY, NULL); } +static void def_clamp(StructRNA *srna) +{ + PropertyRNA *prop; + + prop = RNA_def_property(srna, "clamp_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom1"); + RNA_def_property_enum_items(prop, rna_enum_node_clamp_items); + RNA_def_property_ui_text(prop, "Clamp Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); +} + static void def_map_range(StructRNA *srna) { PropertyRNA *prop; @@ -3929,6 +3970,12 @@ static void def_map_range(StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "custom1", 1); RNA_def_property_ui_text(prop, "Clamp", "Clamp the result to the target range [To Min, To Max]"); RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_Node_update"); + + prop = RNA_def_property(srna, "interpolation_type", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "custom2"); + RNA_def_property_enum_items(prop, rna_enum_node_map_range_items); + RNA_def_property_ui_text(prop, "Interpolation Type", ""); + RNA_def_property_update(prop, NC_NODE | NA_EDITED, "rna_ShaderNode_socket_update"); } static void def_math(StructRNA *srna) |