diff options
author | OmarSquircleArt <mail@OmarEmara.dev> | 2019-11-27 13:07:20 +0300 |
---|---|---|
committer | OmarSquircleArt <mail@OmarEmara.dev> | 2019-11-27 13:07:20 +0300 |
commit | 1c2f7b022a56b034e3e24d8bd5bf03d3beb5ca94 (patch) | |
tree | c40ab4fb676efce962fe833f858c311af6c0c8e4 /intern/cycles/render/nodes.cpp | |
parent | fc1a073bcdc9d2a9ecd4b765724b0f4f4cab4d46 (diff) |
Cycles: Add Random Per Island attribute.
The Random Per Island attribute is a random float associated with each
connected component (island) of the mesh. It is particularly useful
when artists want to add variations to meshes composed of separate
units. Like tree leaves created using particle systems, wood planks
created using array modifiers, or abstract splines created using AN.
Reviewed By: Sergey Sharybin, Jacques Lucke
Differential Revision: https://developer.blender.org/D6154
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index b58e10a7b52..f637fbf3b37 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -3502,6 +3502,7 @@ NODE_DEFINE(GeometryNode) SOCKET_OUT_POINT(parametric, "Parametric"); SOCKET_OUT_FLOAT(backfacing, "Backfacing"); SOCKET_OUT_FLOAT(pointiness, "Pointiness"); + SOCKET_OUT_FLOAT(random_per_island, "Random Per Island"); return type; } @@ -3520,6 +3521,9 @@ void GeometryNode::attributes(Shader *shader, AttributeRequestSet *attributes) if (!output("Pointiness")->links.empty()) { attributes->add(ATTR_STD_POINTINESS); } + if (!output("Random Per Island")->links.empty()) { + attributes->add(ATTR_STD_RANDOM_PER_ISLAND); + } } ShaderNode::attributes(shader, attributes); @@ -3585,6 +3589,17 @@ void GeometryNode::compile(SVMCompiler &compiler) compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), compiler.stack_assign(out)); } } + + out = output("Random Per Island"); + if (!out->links.empty()) { + if (compiler.output_type() != SHADER_TYPE_VOLUME) { + compiler.add_node( + attr_node, ATTR_STD_RANDOM_PER_ISLAND, compiler.stack_assign(out), NODE_ATTR_FLOAT); + } + else { + compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), compiler.stack_assign(out)); + } + } } void GeometryNode::compile(OSLCompiler &compiler) |