Cycles: Fix displacement code creating cyclic dependencies in graph
Bump result was passed to set_normal node and then set_node was connected to all unconnected Normal inputs, including the one from original Bump node, causing cycles.
This commit is contained in:
@@ -727,10 +727,18 @@ void ShaderGraph::bump_from_displacement()
|
|||||||
/* connect bump output to normal input nodes that aren't set yet. actually
|
/* connect bump output to normal input nodes that aren't set yet. actually
|
||||||
* this will only set the normal input to the geometry node that we created
|
* this will only set the normal input to the geometry node that we created
|
||||||
* and connected to all other normal inputs already. */
|
* and connected to all other normal inputs already. */
|
||||||
foreach(ShaderNode *node, nodes)
|
foreach(ShaderNode *node, nodes) {
|
||||||
foreach(ShaderInput *input, node->inputs)
|
/* Don't connect normal to the bump node we're coming from,
|
||||||
|
* otherwise it'll be a cycle in graph.
|
||||||
|
*/
|
||||||
|
if(node == bump) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach(ShaderInput *input, node->inputs) {
|
||||||
if(!input->link && input->default_value == ShaderInput::NORMAL)
|
if(!input->link && input->default_value == ShaderInput::NORMAL)
|
||||||
connect(set_normal->output("Normal"), input);
|
connect(set_normal->output("Normal"), input);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* for displacement bump, clear the normal input in case the above loop
|
/* for displacement bump, clear the normal input in case the above loop
|
||||||
* connected the setnormal out to the bump normalin */
|
* connected the setnormal out to the bump normalin */
|
||||||
|
Reference in New Issue
Block a user