diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-22 15:26:09 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-22 15:26:09 +0300 |
commit | 08ab3cbcce1eb9c2de4953a83b50cabc44479d3c (patch) | |
tree | ef169595562509b0e3338cecb36a3b3210bd64ce /intern/cycles/render | |
parent | a2443848646cdb5d13980157a8c62eb4cd578388 (diff) |
Shading: Add object color to Object Info node.
The object color property is added as an additional output in
the Object Info node.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5554
Diffstat (limited to 'intern/cycles/render')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/object.cpp | 5 | ||||
-rw-r--r-- | intern/cycles/render/object.h | 1 |
3 files changed, 12 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 3a5d65039c8..69c1c06f846 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3940,6 +3940,7 @@ NODE_DEFINE(ObjectInfoNode) NodeType *type = NodeType::add("object_info", create, NodeType::SHADER); SOCKET_OUT_VECTOR(location, "Location"); + SOCKET_OUT_COLOR(color, "Color"); SOCKET_OUT_FLOAT(object_index, "Object Index"); SOCKET_OUT_FLOAT(material_index, "Material Index"); SOCKET_OUT_FLOAT(random, "Random"); @@ -3958,6 +3959,11 @@ void ObjectInfoNode::compile(SVMCompiler &compiler) compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_LOCATION, compiler.stack_assign(out)); } + out = output("Color"); + if (!out->links.empty()) { + compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_COLOR, compiler.stack_assign(out)); + } + out = output("Object Index"); if (!out->links.empty()) { compiler.add_node(NODE_OBJECT_INFO, NODE_INFO_OB_INDEX, compiler.stack_assign(out)); diff --git a/intern/cycles/render/object.cpp b/intern/cycles/render/object.cpp index 6c6f8810412..849329a086d 100644 --- a/intern/cycles/render/object.cpp +++ b/intern/cycles/render/object.cpp @@ -90,6 +90,7 @@ NODE_DEFINE(Object) SOCKET_NODE(mesh, "Mesh", &Mesh::node_type); SOCKET_TRANSFORM(tfm, "Transform", transform_identity()); SOCKET_UINT(visibility, "Visibility", ~0); + SOCKET_COLOR(color, "Color", make_float3(0.0f, 0.0f, 0.0f)); SOCKET_UINT(random_id, "Random ID", 0); SOCKET_INT(pass_id, "Pass ID", 0); SOCKET_BOOLEAN(use_holdout, "Use Holdout", false); @@ -371,6 +372,7 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s */ float uniform_scale; float surface_area = 0.0f; + float3 color = ob->color; float pass_id = ob->pass_id; float random_number = (float)ob->random_id * (1.0f / (float)0xFFFFFFFF); int particle_index = (ob->particle_system) ? @@ -425,6 +427,9 @@ void ObjectManager::device_update_object_transform(UpdateObjectTransformState *s kobject.tfm = tfm; kobject.itfm = itfm; kobject.surface_area = surface_area; + kobject.color[0] = color.x; + kobject.color[1] = color.y; + kobject.color[2] = color.z; kobject.pass_id = pass_id; kobject.random_number = random_number; kobject.particle_index = particle_index; diff --git a/intern/cycles/render/object.h b/intern/cycles/render/object.h index 2fd43900da1..cbbff0d4c6d 100644 --- a/intern/cycles/render/object.h +++ b/intern/cycles/render/object.h @@ -51,6 +51,7 @@ class Object : public Node { BoundBox bounds; uint random_id; int pass_id; + float3 color; ustring asset_name; vector<ParamValue> attributes; uint visibility; |