diff options
author | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-07-07 10:54:46 +0400 |
---|---|---|
committer | Tamito Kajiyama <rd6t-kjym@asahi-net.or.jp> | 2014-07-07 11:19:51 +0400 |
commit | 7915d7277ac8c605f016f30f943080556244fb59 (patch) | |
tree | 4e137b5a4e98fad4911815a938cae8fd00783030 /release/scripts/freestyle | |
parent | dc40928087e9b1183a6df2b38bb6a9a610e4ed13 (diff) |
Per-material line color settings for Freestyle.
New properties 'line_color' and 'line_priority' are added to Material ID data blocks.
The 'line_color' property allows users to specify a per-material line color that can be
used as a Freestyle line color through Material color modifiers of line style settings.
The new line color property is intended to provide a solution for line color
stylization when a proper Freestyle support for Cycles is implemented (likely
as part of the upcoming Blender 2.72 release; see Patch D632). Materials in
Cycles are usually set up using shader nodes, and Freestyle won't be capable
of retrieving colors and other properties from node-based materials any soon.
The new line color property of materials addresses this foreseen limitation by
providing artists with an intuitive alternative mean to specify line colors on a
per-material basis independently from node trees.
The 'line_priority' property gives users a way to control line colors at material
boundaries. When a line is drawn along a feature edge at material boundaries,
one of the two materials on both sides of the edge has to be picked up to
determine the line color. So far there was no way to control this selection
(which was in effect at random). Now the material with a higher line color
priority will be selected.
The new per-material line settings are shown in the new Freestyle Line tab in
the Material context of the Properties window (only when Freestyle is enabled).
Diffstat (limited to 'release/scripts/freestyle')
-rw-r--r-- | release/scripts/freestyle/modules/freestyle/functions.py | 11 | ||||
-rw-r--r-- | release/scripts/freestyle/modules/parameter_editor.py | 21 |
2 files changed, 25 insertions, 7 deletions
diff --git a/release/scripts/freestyle/modules/freestyle/functions.py b/release/scripts/freestyle/modules/freestyle/functions.py index 773d04ddeab..9e03f8f5dbb 100644 --- a/release/scripts/freestyle/modules/freestyle/functions.py +++ b/release/scripts/freestyle/modules/freestyle/functions.py @@ -98,14 +98,21 @@ from mathutils import Vector class CurveMaterialF0D(UnaryFunction0DMaterial): """ A replacement of the built-in MaterialF0D for stroke creation. - MaterialF0D does not work with Curves and Strokes. + MaterialF0D does not work with Curves and Strokes. Line color + priority is used to pick one of the two materials at material + boundaries. """ def __call__(self, inter): cp = inter.object assert(isinstance(cp, CurvePoint)) fe = cp.first_svertex.get_fedge(cp.second_svertex) assert(fe is not None), "CurveMaterialF0D: fe is None" - return fe.material if fe.is_smooth else fe.material_left + if fe.is_smooth: + return fe.material + elif fe.material_right.priority > fe.material_left.priority: + return fe.material_right + else: + return fe.material_left class pyInverseCurvature2DAngleF0D(UnaryFunction0DDouble): diff --git a/release/scripts/freestyle/modules/parameter_editor.py b/release/scripts/freestyle/modules/parameter_editor.py index 34645b9cb62..3529221c5b5 100644 --- a/release/scripts/freestyle/modules/parameter_editor.py +++ b/release/scripts/freestyle/modules/parameter_editor.py @@ -447,7 +447,9 @@ def iter_material_color(stroke, material_attribute): it = stroke.stroke_vertices_begin() while not it.is_end: material = func(Interface0DIterator(it)) - if material_attribute == 'DIFF': + if material_attribute == 'LINE': + color = material.line[0:3] + elif material_attribute == 'DIFF': color = material.diffuse[0:3] elif material_attribute == 'SPEC': color = material.specular[0:3] @@ -462,7 +464,18 @@ def iter_material_value(stroke, material_attribute): it = stroke.stroke_vertices_begin() while not it.is_end: material = func(Interface0DIterator(it)) - if material_attribute == 'DIFF': + if material_attribute == 'LINE': + r, g, b = material.line[0:3] + t = 0.35 * r + 0.45 * g + 0.2 * b + elif material_attribute == 'LINE_R': + t = material.line[0] + elif material_attribute == 'LINE_G': + t = material.line[1] + elif material_attribute == 'LINE_B': + t = material.line[2] + elif material_attribute == 'ALPHA': + t = material.line[3] + elif material_attribute == 'DIFF': r, g, b = material.diffuse[0:3] t = 0.35 * r + 0.45 * g + 0.2 * b elif material_attribute == 'DIFF_R': @@ -482,8 +495,6 @@ def iter_material_value(stroke, material_attribute): t = material.specular[2] elif material_attribute == 'SPEC_HARDNESS': t = material.shininess - elif material_attribute == 'ALPHA': - t = material.diffuse[3] else: raise ValueError("unexpected material attribute: " + material_attribute) yield it, t @@ -497,7 +508,7 @@ class ColorMaterialShader(ColorRampModifier): self.__use_ramp = use_ramp def shade(self, stroke): - if self.__material_attribute in {'DIFF', 'SPEC'} and not self.__use_ramp: + if self.__material_attribute in {'LINE', 'DIFF', 'SPEC'} and not self.__use_ramp: for it, b in iter_material_color(stroke, self.__material_attribute): sv = it.object a = sv.attribute.color |