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:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-12 15:39:30 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2019-05-13 16:56:11 +0300
commit8f71a84496a95528303fbe0bb7c1406060353425 (patch)
treeebebb3cb4dd35b83a7f4aba960f616fffdc36800 /intern/cycles/render/graph.cpp
parent21854575a4ede7d0c16fbe31ac90e66493f607fe (diff)
Cycles/Eevee: add Emission and Alpha inputs to Principled BSDF
This makes it easier to set up materials with emission and transparency. Importers/exporters and add-ons are recommended to now use these rather than creating separate transparent BSDF and emission nodes.
Diffstat (limited to 'intern/cycles/render/graph.cpp')
-rw-r--r--intern/cycles/render/graph.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp
index e5fd39f08b7..9203c4468d2 100644
--- a/intern/cycles/render/graph.cpp
+++ b/intern/cycles/render/graph.cpp
@@ -127,6 +127,12 @@ ShaderOutput *ShaderNode::output(ustring name)
return NULL;
}
+void ShaderNode::remove_input(ShaderInput *input)
+{
+ assert(input->link == NULL);
+ inputs.erase(remove(inputs.begin(), inputs.end(), input), inputs.end());
+}
+
void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes)
{
foreach (ShaderInput *input, inputs) {
@@ -297,6 +303,28 @@ void ShaderGraph::disconnect(ShaderInput *to)
from->links.erase(remove(from->links.begin(), from->links.end(), to), from->links.end());
}
+void ShaderGraph::relink(ShaderInput *from, ShaderInput *to)
+{
+ ShaderOutput *out = from->link;
+ if (out) {
+ disconnect(from);
+ connect(out, to);
+ }
+ to->parent->copy_value(to->socket_type, *(from->parent), from->socket_type);
+}
+
+void ShaderGraph::relink(ShaderOutput *from, ShaderOutput *to)
+{
+ /* Copy because disconnect modifies this list. */
+ vector<ShaderInput *> outputs = from->links;
+
+ foreach (ShaderInput *sock, outputs) {
+ disconnect(sock);
+ if (to)
+ connect(to, sock);
+ }
+}
+
void ShaderGraph::relink(ShaderNode *node, ShaderOutput *from, ShaderOutput *to)
{
simplified = false;
@@ -320,6 +348,7 @@ void ShaderGraph::relink(ShaderNode *node, ShaderOutput *from, ShaderOutput *to)
void ShaderGraph::simplify(Scene *scene)
{
if (!simplified) {
+ expand();
default_inputs(scene->shader_manager->use_osl());
clean(scene);
refine_bump_nodes();
@@ -780,6 +809,14 @@ void ShaderGraph::clean(Scene *scene)
nodes = newnodes;
}
+void ShaderGraph::expand()
+{
+ /* Call expand on all nodes, to generate additional nodes. */
+ foreach (ShaderNode *node, nodes) {
+ node->expand(this);
+ }
+}
+
void ShaderGraph::default_inputs(bool do_osl)
{
/* nodes can specify default texture coordinates, for now we give