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).
This commit is contained in:
Tamito Kajiyama 2014-07-07 15:54:46 +09:00
parent dc40928087
commit 7915d7277a
Notes: blender-bot 2023-02-13 23:39:48 +01:00
Referenced by commit f4a260fb3c, Fix T42198: Linked lines only work with linked objects.
14 changed files with 293 additions and 36 deletions

View File

@ -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):

View File

@ -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

View File

@ -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__)

View File

@ -42,7 +42,7 @@ extern "C" {
* and keep comment above the defines.
* Use STRINGIFY() rather than defining with quotes */
#define BLENDER_VERSION 271
#define BLENDER_SUBVERSION 0
#define BLENDER_SUBVERSION 1
/* 262 was the last editmesh release but it has compatibility code for bmesh data */
#define BLENDER_MINVERSION 270
#define BLENDER_MINSUBVERSION 5

View File

@ -279,7 +279,7 @@ LineStyleModifier *BKE_add_linestyle_color_modifier(FreestyleLineStyle *linestyl
break;
case LS_MODIFIER_MATERIAL:
((LineStyleColorModifier_Material *)m)->color_ramp = add_colorband(1);
((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
((LineStyleColorModifier_Material *)m)->mat_attr = LS_MODIFIER_MATERIAL_LINE;
break;
default:
return NULL; /* unknown modifier type */
@ -424,7 +424,7 @@ LineStyleModifier *BKE_add_linestyle_alpha_modifier(FreestyleLineStyle *linestyl
{
LineStyleAlphaModifier_Material *p = (LineStyleAlphaModifier_Material *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
p->mat_attr = LS_MODIFIER_MATERIAL_ALPHA;
break;
}
default:
@ -583,7 +583,7 @@ LineStyleModifier *BKE_add_linestyle_thickness_modifier(FreestyleLineStyle *line
{
LineStyleThicknessModifier_Material *p = (LineStyleThicknessModifier_Material *)m;
p->curve = curvemapping_add(1, 0.0f, 0.0f, 1.0f, 1.0f);
p->mat_attr = LS_MODIFIER_MATERIAL_DIFF;
p->mat_attr = LS_MODIFIER_MATERIAL_LINE;
p->value_min = 0.0f;
p->value_max = 1.0f;
break;

View File

@ -298,4 +298,16 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *main)
}
}
}
if (!MAIN_VERSION_ATLEAST(main, 271, 1)) {
if (!DNA_struct_elem_find(fd->filesdna, "Material", "float", "line[4]")) {
Material *mat;
for (mat = main->mat.first; mat; mat = mat->id.next) {
mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
mat->line_col[3] = mat->alpha;
}
}
}
}

View File

@ -35,6 +35,7 @@
#include "DNA_space_types.h"
#include "DNA_userdef_types.h"
#include "DNA_mesh_types.h"
#include "DNA_material_types.h"
#include "BKE_main.h"
@ -48,6 +49,7 @@ void BLO_update_defaults_startup_blend(Main *main)
SceneRenderLayer *srl;
FreestyleLineStyle *linestyle;
Mesh *me;
Material *mat;
for (scene = main->scene.first; scene; scene = scene->id.next) {
scene->r.im_format.planes = R_IMF_PLANES_RGBA;
@ -86,5 +88,10 @@ void BLO_update_defaults_startup_blend(Main *main)
for (me = main->mesh.first; me; me = me->id.next) {
me->smoothresh = DEG2RADF(180.0f);
}
for (mat = main->mat.first; mat; mat = mat->id.next) {
mat->line_col[0] = mat->line_col[1] = mat->line_col[2] = 0.0f;
mat->line_col[3] = 1.0f;
}
}

View File

@ -578,12 +578,14 @@ void BlenderFileLoader::insertShapeNode(ObjectInstanceRen *obi, int id)
Material *mat = vlr->mat;
if (mat) {
tmpMat.setLine(mat->line_col[0], mat->line_col[1], mat->line_col[2], mat->line_col[3]);
tmpMat.setDiffuse(mat->r, mat->g, mat->b, mat->alpha);
tmpMat.setSpecular(mat->specr, mat->specg, mat->specb, mat->spectra);
float s = 1.0 * (mat->har + 1) / 4 ; // in Blender: [1;511] => in OpenGL: [0;128]
if (s > 128.f)
s = 128.f;
tmpMat.setShininess(s);
tmpMat.setPriority(mat->line_priority);
}
if (meshFrsMaterials.empty()) {

View File

@ -64,11 +64,13 @@ PyDoc_STRVAR(FrsMaterial_doc,
" :arg brother: A Material object.\n"
" :type brother: :class:`Material`\n"
"\n"
".. method:: __init__(diffuse, ambient, specular, emission, shininess)\n"
".. method:: __init__(line, diffuse, ambient, specular, emission, shininess, priority)\n"
"\n"
" Builds a Material from its diffuse, ambient, specular, emissive\n"
" colors and a shininess coefficient.\n"
" Builds a Material from its line, diffuse, ambient, specular, emissive\n"
" colors, a shininess coefficient and line color priority.\n"
"\n"
" :arg line: The line color.\n"
" :type line: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
" :arg diffuse: The diffuse color.\n"
" :type diffuse: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
" :arg ambient: The ambient color.\n"
@ -78,14 +80,17 @@ PyDoc_STRVAR(FrsMaterial_doc,
" :arg emission: The emissive color.\n"
" :type emission: :class:`mathutils.Vector`, list or tuple of 4 float values\n"
" :arg shininess: The shininess coefficient.\n"
" :type shininess: :class:float");
" :type shininess: :class:float\n"
" :arg priority: The line color priority.\n"
" :type priority: :class:int");
static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist_1[] = {"brother", NULL};
static const char *kwlist_2[] = {"diffuse", "ambient", "specular", "emission", "shininess", NULL};
static const char *kwlist_2[] = {"line", "diffuse", "ambient", "specular", "emission", "shininess", "priority", NULL};
PyObject *brother = 0;
float diffuse[4], ambient[4], specular[4], emission[4], shininess;
float line[4], diffuse[4], ambient[4], specular[4], emission[4], shininess;
int priority;
if (PyArg_ParseTupleAndKeywords(args, kwds, "|O!", (char **)kwlist_1, &FrsMaterial_Type, &brother)) {
if (!brother) {
@ -101,14 +106,15 @@ static int FrsMaterial_init(BPy_FrsMaterial *self, PyObject *args, PyObject *kwd
}
}
else if (PyErr_Clear(),
PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&f", (char **)kwlist_2,
PyArg_ParseTupleAndKeywords(args, kwds, "O&O&O&O&O&fi", (char **)kwlist_2,
convert_v4, line,
convert_v4, diffuse,
convert_v4, ambient,
convert_v4, specular,
convert_v4, emission,
&shininess))
&shininess, &priority))
{
self->m = new FrsMaterial(diffuse, ambient, specular, emission, shininess);
self->m = new FrsMaterial(line, diffuse, ambient, specular, emission, shininess, priority);
}
else {
PyErr_SetString(PyExc_TypeError, "invalid argument(s)");
@ -135,6 +141,7 @@ static PyObject *FrsMaterial_repr(BPy_FrsMaterial *self)
#define MATHUTILS_SUBTYPE_SPECULAR 2
#define MATHUTILS_SUBTYPE_AMBIENT 3
#define MATHUTILS_SUBTYPE_EMISSION 4
#define MATHUTILS_SUBTYPE_LINE 5
static int FrsMaterial_mathutils_check(BaseMathObject *bmo)
{
@ -147,6 +154,12 @@ static int FrsMaterial_mathutils_get(BaseMathObject *bmo, int subtype)
{
BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user;
switch (subtype) {
case MATHUTILS_SUBTYPE_LINE:
bmo->data[0] = self->m->lineR();
bmo->data[1] = self->m->lineG();
bmo->data[2] = self->m->lineB();
bmo->data[3] = self->m->lineA();
break;
case MATHUTILS_SUBTYPE_DIFFUSE:
bmo->data[0] = self->m->diffuseR();
bmo->data[1] = self->m->diffuseG();
@ -181,6 +194,9 @@ static int FrsMaterial_mathutils_set(BaseMathObject *bmo, int subtype)
{
BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user;
switch (subtype) {
case MATHUTILS_SUBTYPE_LINE:
self->m->setLine(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
break;
case MATHUTILS_SUBTYPE_DIFFUSE:
self->m->setDiffuse(bmo->data[0], bmo->data[1], bmo->data[2], bmo->data[3]);
break;
@ -203,6 +219,12 @@ static int FrsMaterial_mathutils_get_index(BaseMathObject *bmo, int subtype, int
{
BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user;
switch (subtype) {
case MATHUTILS_SUBTYPE_LINE:
{
const float *color = self->m->line();
bmo->data[index] = color[index];
}
break;
case MATHUTILS_SUBTYPE_DIFFUSE:
{
const float *color = self->m->diffuse();
@ -238,6 +260,11 @@ static int FrsMaterial_mathutils_set_index(BaseMathObject *bmo, int subtype, int
BPy_FrsMaterial *self = (BPy_FrsMaterial *)bmo->cb_user;
float color[4];
switch (subtype) {
case MATHUTILS_SUBTYPE_LINE:
copy_v4_v4(color, self->m->line());
color[index] = bmo->data[index];
self->m->setLine(color[0], color[1], color[2], color[3]);
break;
case MATHUTILS_SUBTYPE_DIFFUSE:
copy_v4_v4(color, self->m->diffuse());
color[index] = bmo->data[index];
@ -281,6 +308,28 @@ void FrsMaterial_mathutils_register_callback()
/*----------------------FrsMaterial get/setters ----------------------------*/
PyDoc_STRVAR(FrsMaterial_line_doc,
"RGBA components of the line color of the material.\n"
"\n"
":type: mathutils.Vector");
static PyObject *FrsMaterial_line_get(BPy_FrsMaterial *self, void *UNUSED(closure))
{
return Vector_CreatePyObject_cb((PyObject *)self, 4, FrsMaterial_mathutils_cb_index, MATHUTILS_SUBTYPE_LINE);
}
static int FrsMaterial_line_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
{
float color[4];
if (mathutils_array_parse(color, 4, 4, value,
"value must be a 4-dimensional vector") == -1)
{
return -1;
}
self->m->setLine(color[0], color[1], color[2], color[3]);
return 0;
}
PyDoc_STRVAR(FrsMaterial_diffuse_doc,
"RGBA components of the diffuse color of the material.\n"
"\n"
@ -390,7 +439,30 @@ static int FrsMaterial_shininess_set(BPy_FrsMaterial *self, PyObject *value, voi
return 0;
}
PyDoc_STRVAR(FrsMaterial_priority_doc,
"Line color priority of the material.\n"
"\n"
":type: int");
static PyObject *FrsMaterial_priority_get(BPy_FrsMaterial *self, void *UNUSED(closure))
{
return PyLong_FromLong(self->m->priority());
}
static int FrsMaterial_priority_set(BPy_FrsMaterial *self, PyObject *value, void *UNUSED(closure))
{
int scalar;
if ((scalar = PyLong_AsLong(value)) == -1 && PyErr_Occurred()) {
PyErr_SetString(PyExc_TypeError, "value must be an integer");
return -1;
}
self->m->setPriority(scalar);
return 0;
}
static PyGetSetDef BPy_FrsMaterial_getseters[] = {
{(char *)"line", (getter)FrsMaterial_line_get, (setter)FrsMaterial_line_set,
(char *)FrsMaterial_line_doc, NULL},
{(char *)"diffuse", (getter)FrsMaterial_diffuse_get, (setter)FrsMaterial_diffuse_set,
(char *)FrsMaterial_diffuse_doc, NULL},
{(char *)"specular", (getter)FrsMaterial_specular_get, (setter)FrsMaterial_specular_set,
@ -401,6 +473,8 @@ static PyGetSetDef BPy_FrsMaterial_getseters[] = {
(char *)FrsMaterial_emission_doc, NULL},
{(char *)"shininess", (getter)FrsMaterial_shininess_get, (setter)FrsMaterial_shininess_set,
(char *)FrsMaterial_shininess_doc, NULL},
{(char *)"priority", (getter)FrsMaterial_priority_get, (setter)FrsMaterial_priority_set,
(char *)FrsMaterial_priority_doc, NULL},
{NULL, NULL, NULL, NULL, NULL} /* Sentinel */
};

View File

@ -43,7 +43,10 @@ public:
/*! Default constructor */
inline FrsMaterial();
/*! Builds a Material from its diffuse, ambiant, specular, emissive colors and a shininess coefficient.
/*! Builds a Material from its line, diffuse, ambiant, specular, emissive
* colors, a shininess coefficient and line color priority.
* \param iLine
* A 4 element float-array containing the line color.
* \param iDiffuse
* A 4 element float-array containing the diffuse color.
* \param iAmbiant
@ -54,9 +57,11 @@ public:
* A 4 element float-array containing the emissive color.
* \param iShininess
* The shininess coefficient.
* \param iPriority
* The line color priority.
*/
inline FrsMaterial(const float *iDiffuse, const float *iAmbiant, const float *iSpecular, const float *iEmission,
const float iShininess);
inline FrsMaterial(const float *iLine, const float *iDiffuse, const float *iAmbiant, const float *iSpecular,
const float *iEmission, const float iShininess, const int iPriority);
/*! Copy constructor */
inline FrsMaterial(const FrsMaterial& m);
@ -64,6 +69,35 @@ public:
/*! Destructor */
virtual ~FrsMaterial() {}
/*! Returns the line color as a 4 float array */
inline const float *line() const
{
return Line;
}
/*! Returns the red component of the line color */
inline const float lineR() const
{
return Line[0];
}
/*! Returns the green component of the line color */
inline const float lineG() const
{
return Line[1];
}
/*! Returns the blue component of the line color */
inline const float lineB() const
{
return Line[2];
}
/*! Returns the alpha component of the line color */
inline const float lineA() const
{
return Line[3];
}
/*! Returns the diffuse color as a 4 float array */
inline const float *diffuse() const
@ -191,6 +225,24 @@ public:
return Shininess;
}
/*! Returns the line color priority */
inline const int priority() const
{
return Priority;
}
/*! Sets the line color.
* \param r
* Red component
* \param g
* Green component
* \param b
* Blue component
* \param a
* Alpha component
*/
inline void setLine(const float r, const float g, const float b, const float a);
/*! Sets the diffuse color.
* \param r
* Red component
@ -245,6 +297,12 @@ public:
*/
inline void setShininess(const float s);
/*! Sets the line color priority.
* \param priority
* Priority
*/
inline void setPriority(const int priority);
/* operators */
inline FrsMaterial& operator=(const FrsMaterial& m);
inline bool operator!=(const FrsMaterial& m) const;
@ -252,11 +310,13 @@ public:
private:
/*! Material properties */
float Line[4];
float Diffuse[4];
float Specular[4];
float Ambient[4];
float Emission[4];
float Shininess;
int Priority;
#ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("Freestyle:FrsMaterial")
@ -265,6 +325,9 @@ private:
FrsMaterial::FrsMaterial()
{
Line[0] = Line[1] = Line[2] = 0.0f;
Line[3] = 1.0f;
Ambient[0] = Ambient[1] = Ambient[2] = 0.2f;
Ambient[3] = 1.0f;
@ -278,12 +341,14 @@ FrsMaterial::FrsMaterial()
Specular[3] = 1.0f;
Shininess = 0.0f;
Priority = 0;
}
FrsMaterial::FrsMaterial(const float *iDiffuse, const float *iAmbiant, const float *iSpecular, const float *iEmission,
const float iShininess)
FrsMaterial::FrsMaterial(const float *iLine, const float *iDiffuse, const float *iAmbiant, const float *iSpecular,
const float *iEmission, const float iShininess, const int iPriority)
{
for (int i = 0; i < 4; i++) {
Line[i] = iLine[i];
Diffuse[i] = iDiffuse[i];
Specular[i] = iSpecular[i];
Ambient[i] = iAmbiant[i];
@ -291,11 +356,13 @@ FrsMaterial::FrsMaterial(const float *iDiffuse, const float *iAmbiant, const flo
}
Shininess = iShininess;
Priority = iPriority;
}
FrsMaterial::FrsMaterial(const FrsMaterial& m)
{
for (int i = 0; i < 4; i++) {
Line[i] = m.line()[i];
Diffuse[i] = m.diffuse()[i];
Specular[i] = m.specular()[i];
Ambient[i] = m.ambient()[i];
@ -303,6 +370,15 @@ FrsMaterial::FrsMaterial(const FrsMaterial& m)
}
Shininess = m.shininess();
Priority = m.priority();
}
void FrsMaterial::setLine(const float r, const float g, const float b, const float a)
{
Line[0] = r;
Line[1] = g;
Line[2] = b;
Line[3] = a;
}
void FrsMaterial::setDiffuse(const float r, const float g, const float b, const float a)
@ -342,9 +418,15 @@ void FrsMaterial::setShininess(const float s)
Shininess = s;
}
void FrsMaterial::setPriority(const int priority)
{
Priority = priority;
}
FrsMaterial& FrsMaterial::operator=(const FrsMaterial& m)
{
for (int i = 0; i < 4; i++) {
Line[i] = m.line()[i];
Diffuse[i] = m.diffuse()[i];
Specular[i] = m.specular()[i];
Ambient[i] = m.ambient()[i];
@ -352,6 +434,7 @@ FrsMaterial& FrsMaterial::operator=(const FrsMaterial& m)
}
Shininess = m.shininess();
Priority = m.priority();
return *this;
}
@ -359,8 +442,12 @@ bool FrsMaterial::operator!=(const FrsMaterial& m) const
{
if (Shininess != m.shininess())
return true;
if (Priority != m.priority())
return true;
for (int i = 0; i < 4; i++) {
if (Line[i] != m.line()[i])
return true;
if (Diffuse[i] != m.diffuse()[i])
return true;
if (Specular[i] != m.specular()[i])

View File

@ -199,6 +199,10 @@ typedef struct LineStyleThicknessModifier_DistanceFromObject {
#define LS_MODIFIER_MATERIAL_SPEC_B 8
#define LS_MODIFIER_MATERIAL_SPEC_HARD 9
#define LS_MODIFIER_MATERIAL_ALPHA 10
#define LS_MODIFIER_MATERIAL_LINE 11
#define LS_MODIFIER_MATERIAL_LINE_R 12
#define LS_MODIFIER_MATERIAL_LINE_G 13
#define LS_MODIFIER_MATERIAL_LINE_B 14
typedef struct LineStyleColorModifier_Material {
struct LineStyleModifier modifier;

View File

@ -178,8 +178,11 @@ typedef struct Material {
short shadowonly_flag; /* "shadowsonly" type */
short index; /* custom index for render passes */
/* Freestyle line settings */
float line_col[4];
short line_priority;
short vcol_alpha;
short pad4[3];
int pad4;
ListBase gpumaterial; /* runtime */
} Material;

View File

@ -681,16 +681,20 @@ static void rna_def_modifier_material_common(StructRNA *srna)
PropertyRNA *prop;
static EnumPropertyItem mat_attr_items[] = {
{LS_MODIFIER_MATERIAL_DIFF, "DIFF", 0, "Diffuse", ""},
{LS_MODIFIER_MATERIAL_DIFF_R, "DIFF_R", 0, "Diffuse Red", ""},
{LS_MODIFIER_MATERIAL_DIFF_G, "DIFF_G", 0, "Diffuse Green", ""},
{LS_MODIFIER_MATERIAL_DIFF_B, "DIFF_B", 0, "Diffuse Blue", ""},
{LS_MODIFIER_MATERIAL_SPEC, "SPEC", 0, "Specular", ""},
{LS_MODIFIER_MATERIAL_SPEC_R, "SPEC_R", 0, "Specular Red", ""},
{LS_MODIFIER_MATERIAL_SPEC_G, "SPEC_G", 0, "Specular Green", ""},
{LS_MODIFIER_MATERIAL_SPEC_B, "SPEC_B", 0, "Specular Blue", ""},
{LS_MODIFIER_MATERIAL_LINE, "LINE", 0, "Line Color", ""},
{LS_MODIFIER_MATERIAL_LINE_R, "LINE_R", 0, "Line Color Red", ""},
{LS_MODIFIER_MATERIAL_LINE_G, "LINE_G", 0, "Line Color Green", ""},
{LS_MODIFIER_MATERIAL_LINE_B, "LINE_B", 0, "Line Color Blue", ""},
{LS_MODIFIER_MATERIAL_DIFF, "DIFF", 0, "Diffuse Color", ""},
{LS_MODIFIER_MATERIAL_DIFF_R, "DIFF_R", 0, "Diffuse Color Red", ""},
{LS_MODIFIER_MATERIAL_DIFF_G, "DIFF_G", 0, "Diffuse Color Green", ""},
{LS_MODIFIER_MATERIAL_DIFF_B, "DIFF_B", 0, "Diffuse Color Blue", ""},
{LS_MODIFIER_MATERIAL_SPEC, "SPEC", 0, "Specular Color", ""},
{LS_MODIFIER_MATERIAL_SPEC_R, "SPEC_R", 0, "Specular Color Red", ""},
{LS_MODIFIER_MATERIAL_SPEC_G, "SPEC_G", 0, "Specular Color Green", ""},
{LS_MODIFIER_MATERIAL_SPEC_B, "SPEC_B", 0, "Specular Color Blue", ""},
{LS_MODIFIER_MATERIAL_SPEC_HARD, "SPEC_HARD", 0, "Specular Hardness", ""},
{LS_MODIFIER_MATERIAL_ALPHA, "ALPHA", 0, "Alpha", ""},
{LS_MODIFIER_MATERIAL_ALPHA, "ALPHA", 0, "Alpha Transparency", ""},
{0, NULL, 0, NULL, NULL}
};

View File

@ -931,6 +931,20 @@ static void rna_def_material_colors(StructRNA *srna)
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Specular Ramp Factor", "Blending factor (also uses alpha in Colorband)");
RNA_def_property_update(prop, 0, "rna_Material_update");
/* Freestyle line color */
prop = RNA_def_property(srna, "line_color", PROP_FLOAT, PROP_COLOR);
RNA_def_property_float_sdna(prop, NULL, "line_col");
RNA_def_property_array(prop, 4);
RNA_def_property_ui_text(prop, "Line Color", "Line color used for Freestyle line rendering");
RNA_def_property_update(prop, 0, "rna_Material_update");
prop = RNA_def_property(srna, "line_priority", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "line_priority");
RNA_def_property_range(prop, 0, 32767);
RNA_def_property_ui_text(prop, "Line Priority",
"The line color of a higher priority is used at material boundaries");
RNA_def_property_update(prop, 0, "rna_Material_update");
}
static void rna_def_material_diffuse(StructRNA *srna)