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:
authorPhilipp Oeser <info@graphics-engineer.com>2020-02-18 19:19:16 +0300
committerPhilipp Oeser <info@graphics-engineer.com>2020-02-19 14:10:33 +0300
commit65ea5020c4a1647bcacd4933dc9e5fc519982536 (patch)
tree5ec266a21726fc63720b07bf7d407015fb9f6bdf /intern/cycles/render
parent3b01dbdeb14a9deca0857ca6c3b038840fb96388 (diff)
Fix T73938: Cycles Vertex Color wrong if no layer is specified
The node would render black in this case (but should use the 'active_render' layer choosen in the object data properties -- this is now in line to how this is handled for e.g. UVs) This introduces ATTR_STD_VERTEX_COLOR and uses this thoughout, if no particular layer is specified in the node. Maniphest Tasks: T73938 Differential Revision: https://developer.blender.org/D6887
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/attribute.cpp5
-rw-r--r--intern/cycles/render/nodes.cpp28
2 files changed, 30 insertions, 3 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index 05c0b5693bc..4fbf831087f 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -301,6 +301,8 @@ const char *Attribute::standard_name(AttributeStandard std)
return "tangent";
case ATTR_STD_UV_TANGENT_SIGN:
return "tangent_sign";
+ case ATTR_STD_VERTEX_COLOR:
+ return "vertex_color";
case ATTR_STD_POSITION_UNDEFORMED:
return "undeformed";
case ATTR_STD_POSITION_UNDISPLACED:
@@ -480,6 +482,9 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
case ATTR_STD_UV_TANGENT_SIGN:
attr = add(name, TypeDesc::TypeFloat, ATTR_ELEMENT_CORNER);
break;
+ case ATTR_STD_VERTEX_COLOR:
+ attr = add(name,TypeRGBA, ATTR_ELEMENT_CORNER_BYTE);
+ break;
case ATTR_STD_GENERATED:
case ATTR_STD_POSITION_UNDEFORMED:
case ATTR_STD_POSITION_UNDISPLACED:
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 41b4b05ba19..9c909c2131f 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -4519,7 +4519,10 @@ VertexColorNode::VertexColorNode() : ShaderNode(node_type)
void VertexColorNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
if (!(output("Color")->links.empty() && output("Alpha")->links.empty())) {
- attributes->add_standard(layer_name);
+ if (layer_name != "")
+ attributes->add_standard(layer_name);
+ else
+ attributes->add(ATTR_STD_VERTEX_COLOR);
}
ShaderNode::attributes(shader, attributes);
}
@@ -4528,7 +4531,14 @@ void VertexColorNode::compile(SVMCompiler &compiler)
{
ShaderOutput *color_out = output("Color");
ShaderOutput *alpha_out = output("Alpha");
- int layer_id = compiler.attribute(layer_name);
+ int layer_id = 0;
+
+ if (layer_name != "") {
+ layer_id = compiler.attribute(layer_name);
+ }
+ else {
+ layer_id = compiler.attribute(ATTR_STD_VERTEX_COLOR);
+ }
ShaderNodeType node;
@@ -4555,7 +4565,19 @@ void VertexColorNode::compile(OSLCompiler &compiler)
else {
compiler.parameter("bump_offset", "center");
}
- compiler.parameter("layer_name", layer_name.c_str());
+
+ if (layer_name.empty()) {
+ compiler.parameter("layer_name", ustring("geom:vertex_color"));
+ }
+ else {
+ if (Attribute::name_standard(layer_name.c_str()) != ATTR_STD_NONE) {
+ compiler.parameter("name", (string("geom:") + layer_name.c_str()).c_str());
+ }
+ else {
+ compiler.parameter("layer_name", layer_name.c_str());
+ }
+ }
+
compiler.add(this, "node_vertex_color");
}