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:
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/attribute.cpp2
-rw-r--r--intern/cycles/render/graph.cpp6
-rw-r--r--intern/cycles/render/graph.h1
-rw-r--r--intern/cycles/render/nodes.cpp31
-rw-r--r--intern/cycles/render/nodes.h2
5 files changed, 42 insertions, 0 deletions
diff --git a/intern/cycles/render/attribute.cpp b/intern/cycles/render/attribute.cpp
index 5122c1af410..4bcaef0fb17 100644
--- a/intern/cycles/render/attribute.cpp
+++ b/intern/cycles/render/attribute.cpp
@@ -162,6 +162,8 @@ Attribute *AttributeSet::add(AttributeStandard std, ustring name)
attr = add(name, TypeDesc::TypeNormal, Attribute::FACE);
else if(std == ATTR_STD_UV)
attr = add(name, TypeDesc::TypePoint, Attribute::CORNER);
+ else if(std == ATTR_STD_TANGENT)
+ attr = add(name, TypeDesc::TypeVector, Attribute::VERTEX);
else if(std == ATTR_STD_GENERATED)
attr = add(name, TypeDesc::TypePoint, Attribute::VERTEX);
else if(std == ATTR_STD_POSITION_UNDEFORMED)
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index 62758128a73..c13102e9567 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -468,6 +468,12 @@ void ShaderGraph::default_inputs(bool do_osl)
connect(geom->output("Position"), input);
}
+ else if(input->default_value == ShaderInput::TANGENT) {
+ if(!geom)
+ geom = new GeometryNode();
+
+ connect(geom->output("Tangent"), input);
+ }
}
}
}
diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h
index c3b674d0f23..d485ed02150 100644
--- a/intern/cycles/render/graph.h
+++ b/intern/cycles/render/graph.h
@@ -112,6 +112,7 @@ public:
INCOMING,
NORMAL,
POSITION,
+ TANGENT,
NONE
};
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 4e16eea2774..da31a528310 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1221,12 +1221,35 @@ WardBsdfNode::WardBsdfNode()
{
closure = CLOSURE_BSDF_WARD_ID;
+ add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT);
+
add_input("Roughness U", SHADER_SOCKET_FLOAT, 0.2f);
add_input("Roughness V", SHADER_SOCKET_FLOAT, 0.2f);
}
+void WardBsdfNode::attributes(AttributeRequestSet *attributes)
+{
+ ShaderInput *tangent_in = input("Tangent");
+
+ if(!tangent_in->link)
+ attributes->add(ATTR_STD_TANGENT);
+
+ ShaderNode::attributes(attributes);
+}
+
void WardBsdfNode::compile(SVMCompiler& compiler)
{
+ ShaderInput *tangent_in = input("Tangent");
+
+ if(tangent_in->link) {
+ int attr = compiler.attribute(ATTR_STD_TANGENT);
+ compiler.stack_assign(tangent_in);
+ compiler.add_node(NODE_ATTR, attr, tangent_in->stack_offset, NODE_ATTR_FLOAT3);
+ compiler.add_node(NODE_CLOSURE_TANGENT, tangent_in->stack_offset);
+ }
+ else
+ compiler.add_node(NODE_CLOSURE_SET_TANGENT, tangent_in->value);
+
BsdfNode::compile(compiler, input("Roughness U"), input("Roughness V"));
}
@@ -1566,6 +1589,14 @@ GeometryNode::GeometryNode()
add_output("Backfacing", SHADER_SOCKET_FLOAT);
}
+void GeometryNode::attributes(AttributeRequestSet *attributes)
+{
+ if(!output("Tangent")->links.empty())
+ attributes->add(ATTR_STD_TANGENT);
+
+ ShaderNode::attributes(attributes);
+}
+
void GeometryNode::compile(SVMCompiler& compiler)
{
ShaderOutput *out;
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index e8e584dd8ef..6e5d7be0091 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -201,6 +201,7 @@ public:
class WardBsdfNode : public BsdfNode {
public:
SHADER_NODE_CLASS(WardBsdfNode)
+ void attributes(AttributeRequestSet *attributes);
};
class DiffuseBsdfNode : public BsdfNode {
@@ -278,6 +279,7 @@ public:
class GeometryNode : public ShaderNode {
public:
SHADER_NODE_CLASS(GeometryNode)
+ void attributes(AttributeRequestSet *attributes);
};
class TextureCoordinateNode : public ShaderNode {