Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release')
-rw-r--r--release/scripts/freestyle/modules/freestyle/functions.py11
-rw-r--r--release/scripts/freestyle/modules/parameter_editor.py21
-rw-r--r--release/scripts/startup/bl_ui/properties_freestyle.py34
3 files changed, 58 insertions, 8 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
diff --git a/release/scripts/startup/bl_ui/properties_freestyle.py b/release/scripts/startup/bl_ui/properties_freestyle.py
index 31a638d3c7e..c5716dff86d 100644
--- a/release/scripts/startup/bl_ui/properties_freestyle.py
+++ b/release/scripts/startup/bl_ui/properties_freestyle.py
@@ -344,7 +344,7 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
row.prop(modifier, "material_attribute", text="")
sub = row.column()
sub.prop(modifier, "use_ramp")
- if modifier.material_attribute in {'DIFF', 'SPEC'}:
+ if modifier.material_attribute in {'LINE', 'DIFF', 'SPEC'}:
sub.active = True
show_ramp = modifier.use_ramp
else:
@@ -691,5 +691,37 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
pass
+# Material properties
+
+class MaterialFreestyleButtonsPanel():
+ bl_space_type = 'PROPERTIES'
+ bl_region_type = 'WINDOW'
+ bl_context = "material"
+ # COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
+
+ @classmethod
+ def poll(cls, context):
+ scene = context.scene
+ material = context.material
+ with_freestyle = bpy.app.build_options.freestyle
+ return with_freestyle and material and scene and scene.render.use_freestyle and \
+ (scene.render.engine in cls.COMPAT_ENGINES)
+
+
+class MATERIAL_PT_freestyle_line(MaterialFreestyleButtonsPanel, Panel):
+ bl_label = "Freestyle Line"
+ bl_options = {'DEFAULT_CLOSED'}
+ COMPAT_ENGINES = {'BLENDER_RENDER'} # TODO: 'CYCLES'
+
+ def draw(self, context):
+ layout = self.layout
+
+ mat = context.material
+
+ row = layout.row()
+ row.prop(mat, "line_color", text="")
+ row.prop(mat, "line_priority", text="Priority")
+
+
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)