diff options
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index f10b956a482..908acb3e6aa 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2328,6 +2328,62 @@ void TextureCoordinateNode::compile(OSLCompiler& compiler) compiler.add(this, "node_texture_coordinate"); } +UVMapNode::UVMapNode() +: ShaderNode("uvmap") +{ + attribute = ""; + from_dupli = false; + + add_output("UV", SHADER_SOCKET_POINT); +} + +void UVMapNode::attributes(Shader *shader, AttributeRequestSet *attributes) +{ + if(shader->has_surface) { + if(!from_dupli) { + if(!output("UV")->links.empty()) { + if (attribute != "") + attributes->add(attribute); + else + attributes->add(ATTR_STD_UV); + } + } + } + + ShaderNode::attributes(shader, attributes); +} + +void UVMapNode::compile(SVMCompiler& compiler) +{ + ShaderOutput *out = output("UV"); + NodeType texco_node = NODE_TEX_COORD; + NodeType attr_node = NODE_ATTR; + int attr; + + if(!out->links.empty()) { + if(from_dupli) { + compiler.stack_assign(out); + compiler.add_node(texco_node, NODE_TEXCO_DUPLI_UV, out->stack_offset); + } + else { + if (attribute != "") + attr = compiler.attribute(attribute); + else + attr = compiler.attribute(ATTR_STD_UV); + + compiler.stack_assign(out); + compiler.add_node(attr_node, attr, out->stack_offset, NODE_ATTR_FLOAT3); + } + } +} + +void UVMapNode::compile(OSLCompiler& compiler) +{ + compiler.parameter("from_dupli", from_dupli); + compiler.parameter("name", attribute.c_str()); + compiler.add(this, "node_uv_map"); +} + /* Light Path */ LightPathNode::LightPathNode() |