diff options
author | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-21 21:22:24 +0300 |
---|---|---|
committer | OmarSquircleArt <omar.squircleart@gmail.com> | 2019-08-21 21:22:24 +0300 |
commit | e83f0922011243a0085975fe41930ed34bb6c009 (patch) | |
tree | d8708217ccd31e26799b49b1a8678c6eceaa979d /intern/cycles | |
parent | 133dfdd704b6a2a4d46337696773b331a44304ea (diff) |
Shading: Add Volume Info node.
The Volume Info node provides the Color, Desnity, Flame, and Temperature
of smoke domains.
Reviewers: brecht
Differential Revision: https://developer.blender.org/D5551
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 3 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 84 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 15 |
3 files changed, 102 insertions, 0 deletions
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index fdefe2140bd..720f521c589 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -607,6 +607,9 @@ static ShaderNode *add_node(Scene *scene, else if (b_node.is_a(&RNA_ShaderNodeHairInfo)) { node = new HairInfoNode(); } + else if (b_node.is_a(&RNA_ShaderNodeVolumeInfo)) { + node = new VolumeInfoNode(); + } else if (b_node.is_a(&RNA_ShaderNodeBump)) { BL::ShaderNodeBump b_bump_node(b_node); BumpNode *bump = new BumpNode(); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 6435894d41a..3a5d65039c8 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -4168,6 +4168,90 @@ void HairInfoNode::compile(OSLCompiler &compiler) compiler.add(this, "node_hair_info"); } +/* Volume Info */ + +NODE_DEFINE(VolumeInfoNode) +{ + NodeType *type = NodeType::add("volume_info", create, NodeType::SHADER); + + SOCKET_OUT_COLOR(color, "Color"); + SOCKET_OUT_FLOAT(density, "Density"); + SOCKET_OUT_FLOAT(flame, "Flame"); + SOCKET_OUT_FLOAT(temperature, "Temperature"); + + return type; +} + +VolumeInfoNode::VolumeInfoNode() : ShaderNode(node_type) +{ +} + +/* The requested attributes are not updated after node expansion. + * So we explicitly request the required attributes. + */ +void VolumeInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) +{ + if (shader->has_volume) { + if (!output("Color")->links.empty()) { + attributes->add(ATTR_STD_VOLUME_COLOR); + } + if (!output("Density")->links.empty()) { + attributes->add(ATTR_STD_VOLUME_DENSITY); + } + if (!output("Flame")->links.empty()) { + attributes->add(ATTR_STD_VOLUME_FLAME); + } + if (!output("Temperature")->links.empty()) { + attributes->add(ATTR_STD_VOLUME_TEMPERATURE); + } + attributes->add(ATTR_STD_GENERATED_TRANSFORM); + } + ShaderNode::attributes(shader, attributes); +} + +void VolumeInfoNode::expand(ShaderGraph *graph) +{ + ShaderOutput *color_out = output("Color"); + if (!color_out->links.empty()) { + AttributeNode *attr = new AttributeNode(); + attr->attribute = "color"; + graph->add(attr); + graph->relink(color_out, attr->output("Color")); + } + + ShaderOutput *density_out = output("Density"); + if (!density_out->links.empty()) { + AttributeNode *attr = new AttributeNode(); + attr->attribute = "density"; + graph->add(attr); + graph->relink(density_out, attr->output("Fac")); + } + + ShaderOutput *flame_out = output("Flame"); + if (!flame_out->links.empty()) { + AttributeNode *attr = new AttributeNode(); + attr->attribute = "flame"; + graph->add(attr); + graph->relink(flame_out, attr->output("Fac")); + } + + ShaderOutput *temperature_out = output("Temperature"); + if (!temperature_out->links.empty()) { + AttributeNode *attr = new AttributeNode(); + attr->attribute = "temperature"; + graph->add(attr); + graph->relink(temperature_out, attr->output("Fac")); + } +} + +void VolumeInfoNode::compile(SVMCompiler &) +{ +} + +void VolumeInfoNode::compile(OSLCompiler &) +{ +} + /* Value */ NODE_DEFINE(ValueNode) diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 9c4e643e727..fbed2ff0ef6 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -961,6 +961,21 @@ class HairInfoNode : public ShaderNode { } }; +class VolumeInfoNode : public ShaderNode { + public: + SHADER_NODE_CLASS(VolumeInfoNode) + void attributes(Shader *shader, AttributeRequestSet *attributes); + bool has_attribute_dependency() + { + return true; + } + bool has_spatial_varying() + { + return true; + } + void expand(ShaderGraph *graph); +}; + class ValueNode : public ShaderNode { public: SHADER_NODE_CLASS(ValueNode) |