diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2020-02-18 19:19:16 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2020-02-19 14:10:33 +0300 |
commit | 65ea5020c4a1647bcacd4933dc9e5fc519982536 (patch) | |
tree | 5ec266a21726fc63720b07bf7d407015fb9f6bdf /intern/cycles/blender | |
parent | 3b01dbdeb14a9deca0857ca6c3b038840fb96388 (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/blender')
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 4be07ac5e8e..509da1601f3 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -285,14 +285,27 @@ static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, BL::Mesh::vertex_colors_iterator l; for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { - if (!mesh->need_attribute(scene, ustring(l->name().c_str()))) + const bool active_render = l->active_render(); + AttributeStandard vcol_std = (active_render) ? ATTR_STD_VERTEX_COLOR : ATTR_STD_NONE; + ustring vcol_name = ustring(l->name().c_str()); + + const bool need_vcol = mesh->need_attribute(scene, vcol_name) || + mesh->need_attribute(scene, vcol_std); + + if (!need_vcol) { continue; + } - Attribute *attr = mesh->subd_attributes.add( - ustring(l->name().c_str()), TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); + Attribute *vcol_attr = NULL; + if (active_render) { + vcol_attr = mesh->subd_attributes.add(vcol_std, vcol_name); + } + else { + vcol_attr = mesh->subd_attributes.add(vcol_name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); + } BL::Mesh::polygons_iterator p; - uchar4 *cdata = attr->data_uchar4(); + uchar4 *cdata = vcol_attr->data_uchar4(); for (b_mesh.polygons.begin(p); p != b_mesh.polygons.end(); ++p) { int n = p->loop_total(); @@ -307,14 +320,27 @@ static void attr_create_vertex_color(Scene *scene, Mesh *mesh, BL::Mesh &b_mesh, else { BL::Mesh::vertex_colors_iterator l; for (b_mesh.vertex_colors.begin(l); l != b_mesh.vertex_colors.end(); ++l) { - if (!mesh->need_attribute(scene, ustring(l->name().c_str()))) + const bool active_render = l->active_render(); + AttributeStandard vcol_std = (active_render) ? ATTR_STD_VERTEX_COLOR : ATTR_STD_NONE; + ustring vcol_name = ustring(l->name().c_str()); + + const bool need_vcol = mesh->need_attribute(scene, vcol_name) || + mesh->need_attribute(scene, vcol_std); + + if (!need_vcol) { continue; + } - Attribute *attr = mesh->attributes.add( - ustring(l->name().c_str()), TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); + Attribute *vcol_attr = NULL; + if (active_render) { + vcol_attr = mesh->attributes.add(vcol_std, vcol_name); + } + else { + vcol_attr = mesh->attributes.add(vcol_name, TypeRGBA, ATTR_ELEMENT_CORNER_BYTE); + } BL::Mesh::loop_triangles_iterator t; - uchar4 *cdata = attr->data_uchar4(); + uchar4 *cdata = vcol_attr->data_uchar4(); for (b_mesh.loop_triangles.begin(t); t != b_mesh.loop_triangles.end(); ++t) { int3 li = get_int3(t->loops()); |