Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Dietrich <kevin.dietrich@mailoo.org>2014-04-02 13:40:29 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2014-04-02 13:53:44 +0400
commitcb7cfd3ab6be1cfba96cb2070ac60d224126f1ea (patch)
treeec8de38de655c8fe74835eabc7f9c68e20df322a /intern/cycles
parent288147334ce81cf0be533c15f3698b88ef7c63f3 (diff)
Cycles: add dedicated UV Map node, easier to find and has convenient auto complete.
Fixes T37954. Reviewed By: brecht, dingto Differential Revision: https://developer.blender.org/D230
Diffstat (limited to 'intern/cycles')
-rw-r--r--intern/cycles/app/cycles_xml.cpp5
-rw-r--r--intern/cycles/blender/blender_shader.cpp7
-rw-r--r--intern/cycles/kernel/shaders/CMakeLists.txt1
-rw-r--r--intern/cycles/kernel/shaders/node_uv_map.osl34
-rw-r--r--intern/cycles/kernel/svm/svm_types.h3
-rw-r--r--intern/cycles/render/nodes.cpp56
-rw-r--r--intern/cycles/render/nodes.h9
7 files changed, 114 insertions, 1 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp
index 04408eb6bc0..1faf290f0ea 100644
--- a/intern/cycles/app/cycles_xml.cpp
+++ b/intern/cycles/app/cycles_xml.cpp
@@ -649,6 +649,11 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
xml_read_ustring(&attr->attribute, node, "attribute");
snode = attr;
}
+ else if(string_iequals(node.name(), "uv_map")) {
+ UVMapNode *uvm = new UVMapNode();
+ xml_read_ustring(&uvm->attribute, node, "uv_map");
+ snode = uvm;
+ }
else if(string_iequals(node.name(), "camera")) {
snode = new CameraNode();
}
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 1559a96a3d3..2eafcecf026 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -668,6 +668,13 @@ static ShaderNode *add_node(Scene *scene, BL::BlendData b_data, BL::Scene b_scen
tangent->attribute = b_tangent_node.uv_map();
node = tangent;
}
+ else if (b_node.is_a(&RNA_ShaderNodeUVMap)) {
+ BL::ShaderNodeUVMap b_uvmap_node(b_node);
+ UVMapNode *uvm = new UVMapNode();
+ uvm->attribute = b_uvmap_node.uv_map();
+ uvm->from_dupli = b_uvmap_node.from_dupli();
+ node = uvm;
+ }
if(node)
graph->add(node);
diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt
index 045abdb80af..5518d652bf9 100644
--- a/intern/cycles/kernel/shaders/CMakeLists.txt
+++ b/intern/cycles/kernel/shaders/CMakeLists.txt
@@ -77,6 +77,7 @@ set(SRC_OSL
node_wave_texture.osl
node_wireframe.osl
node_hair_bsdf.osl
+ node_uv_map.osl
)
set(SRC_OSL_HEADERS
diff --git a/intern/cycles/kernel/shaders/node_uv_map.osl b/intern/cycles/kernel/shaders/node_uv_map.osl
new file mode 100644
index 00000000000..fd039beaee8
--- /dev/null
+++ b/intern/cycles/kernel/shaders/node_uv_map.osl
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2011-2013 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+#include "stdosl.h"
+
+shader node_uv_map(
+ string name = "",
+ int from_dupli = 0,
+ output point UV = point(0.0, 0.0, 0.0))
+
+{
+ if (from_dupli) {
+ getattribute("geom:dupli_uv", UV);
+ }
+ else {
+ if (name == "")
+ getattribute("geom:uv", UV);
+ else
+ getattribute(name, UV);
+ }
+}
diff --git a/intern/cycles/kernel/svm/svm_types.h b/intern/cycles/kernel/svm/svm_types.h
index ad5e1ea6d2e..3285ea5cd31 100644
--- a/intern/cycles/kernel/svm/svm_types.h
+++ b/intern/cycles/kernel/svm/svm_types.h
@@ -102,7 +102,8 @@ typedef enum NodeType {
NODE_CLOSURE_AMBIENT_OCCLUSION,
NODE_TANGENT,
NODE_NORMAL_MAP,
- NODE_HAIR_INFO
+ NODE_HAIR_INFO,
+ NODE_UVMAP
} NodeType;
typedef enum NodeAttributeType {
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()
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index 497a367a2a6..31caf9507eb 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -350,6 +350,15 @@ public:
bool from_dupli;
};
+class UVMapNode : public ShaderNode {
+public:
+ SHADER_NODE_CLASS(UVMapNode)
+ void attributes(Shader *shader, AttributeRequestSet *attributes);
+
+ ustring attribute;
+ bool from_dupli;
+};
+
class LightPathNode : public ShaderNode {
public:
SHADER_NODE_CLASS(LightPathNode)