Blender
V3.3
|
#include <shader_graph.h>
Public Member Functions | |
ShaderGraph () | |
~ShaderGraph () | |
ShaderNode * | add (ShaderNode *node) |
OutputNode * | output () |
void | connect (ShaderOutput *from, ShaderInput *to) |
void | disconnect (ShaderOutput *from) |
void | disconnect (ShaderInput *to) |
void | relink (ShaderInput *from, ShaderInput *to) |
void | relink (ShaderOutput *from, ShaderOutput *to) |
void | relink (ShaderNode *node, ShaderOutput *from, ShaderOutput *to) |
void | remove_proxy_nodes () |
void | compute_displacement_hash () |
void | simplify (Scene *scene) |
void | finalize (Scene *scene, bool do_bump=false, bool do_simplify=false, bool bump_in_object_space=false) |
int | get_num_closures () |
void | dump_graph (const char *filename) |
template<typename T , typename... Args> | |
T * | create_node (Args &&...args) |
template<typename T > | |
void | delete_node (T *node) |
![]() | |
virtual | ~NodeOwner () |
Public Attributes | |
list< ShaderNode * > | nodes |
size_t | num_node_ids |
bool | finalized |
bool | simplified |
string | displacement_hash |
Protected Types | |
typedef pair< ShaderNode *const, ShaderNode * > | NodePair |
Protected Member Functions | |
void | find_dependencies (ShaderNodeSet &dependencies, ShaderInput *input) |
void | clear_nodes () |
void | copy_nodes (ShaderNodeSet &nodes, ShaderNodeMap &nnodemap) |
void | break_cycles (ShaderNode *node, vector< bool > &visited, vector< bool > &on_stack) |
void | bump_from_displacement (bool use_object_space) |
void | refine_bump_nodes () |
void | expand () |
void | default_inputs (bool do_osl) |
void | transform_multi_closure (ShaderNode *node, ShaderOutput *weight_out, bool volume) |
void | clean (Scene *scene) |
void | constant_fold (Scene *scene) |
void | simplify_settings (Scene *scene) |
void | deduplicate_nodes () |
void | verify_volume_output () |
Definition at line 297 of file shader_graph.h.
|
protected |
Definition at line 349 of file shader_graph.h.
ShaderGraph::ShaderGraph | ( | ) |
Definition at line 206 of file shader_graph.cpp.
References add(), finalized, num_node_ids, and simplified.
ShaderGraph::~ShaderGraph | ( | ) |
Definition at line 214 of file shader_graph.cpp.
References clear_nodes().
ShaderNode * ShaderGraph::add | ( | ShaderNode * | node | ) |
Definition at line 219 of file shader_graph.cpp.
References finalized, node, nodes, num_node_ids, and simplified.
Referenced by bump_from_displacement(), connect(), BumpNode::constant_fold(), constant_fold(), default_inputs(), refine_bump_nodes(), ShaderGraph(), and transform_multi_closure().
|
protected |
Definition at line 708 of file shader_graph.cpp.
References disconnect(), ShaderNode::id, input, node, and visited.
Referenced by clean().
Definition at line 944 of file shader_graph.cpp.
References add(), connect(), copy_nodes(), find_dependencies(), input, ShaderNode::input(), ShaderInput::link, NODE_VECTOR_MATH_DOT_PRODUCT, usdtokens::out(), output(), ShaderNode::output(), SHADER_BUMP_CENTER, SHADER_BUMP_DX, and SHADER_BUMP_DY.
Referenced by finalize().
Definition at line 766 of file shader_graph.cpp.
References break_cycles(), constant_fold(), deduplicate_nodes(), delete_node(), from, ShaderInput::link, node, nodes, NULL, num_node_ids, output(), blender::bke::attribute_accessor_functions::remove(), scene, SHADER_SPECIAL_TYPE_OUTPUT_AOV, simplify_settings(), verify_volume_output(), and visited.
Referenced by simplify().
|
protected |
Definition at line 403 of file shader_graph.cpp.
References delete_node(), node, and nodes.
Referenced by ~ShaderGraph().
void ShaderGraph::compute_displacement_hash | ( | ) |
Definition at line 732 of file shader_graph.cpp.
References MD5Hash::append(), OSLNode::bytecode_hash, displacement_hash, find_dependencies(), MD5Hash::get_hex(), input, ShaderNode::input(), ShaderInput::link, node, output(), and SHADER_SPECIAL_TYPE_OSL.
Referenced by Shader::set_graph().
void ShaderGraph::connect | ( | ShaderOutput * | from, |
ShaderInput * | to | ||
) |
Definition at line 234 of file shader_graph.cpp.
References add(), SocketType::CLOSURE, PixelFormat::convert(), finalized, SocketType::FLOAT, from, ShaderInput::link, Node::name, ShaderInput::name(), one_float3(), ShaderInput::parent, and ShaderInput::type().
Referenced by bump_from_displacement(), ConstantFolder::bypass(), constant_fold(), copy_nodes(), default_inputs(), refine_bump_nodes(), relink(), and transform_multi_closure().
Definition at line 525 of file shader_graph.cpp.
References add(), CCL_NAMESPACE_BEGIN::check_node_inputs_has_links(), CCL_NAMESPACE_BEGIN::check_node_inputs_traversed(), connect(), input, ShaderNode::input(), ShaderInput::link, node, nodes, NULL, output(), ShaderNode::output(), scene, and Node::set_value().
Referenced by clean().
|
protected |
Definition at line 411 of file shader_graph.cpp.
References connect(), ShaderNode::create_inputs_outputs(), input, ShaderNode::input(), ShaderNode::inputs, node, nodes, ShaderNode::output(), ShaderNode::outputs, and Node::type.
Referenced by bump_from_displacement(), and refine_bump_nodes().
|
inline |
Definition at line 333 of file shader_graph.h.
Referenced by BumpNode::constant_fold().
|
protected |
Definition at line 591 of file shader_graph.cpp.
References CCL_NAMESPACE_BEGIN::check_node_inputs_has_links(), CCL_NAMESPACE_BEGIN::check_node_inputs_traversed(), input, node, nodes, NULL, output(), ShaderNode::outputs, relink(), and VLOG_DEBUG.
Referenced by clean().
Definition at line 826 of file shader_graph.cpp.
References add(), connect(), input, SocketType::LINK_INCOMING, SocketType::LINK_NORMAL, SocketType::LINK_POSITION, SocketType::LINK_TANGENT, SocketType::LINK_TEXTURE_GENERATED, SocketType::LINK_TEXTURE_NORMAL, SocketType::LINK_TEXTURE_UV, node, nodes, NULL, SocketType::OSL_INTERNAL, and ShaderNode::output().
Referenced by simplify().
Definition at line 342 of file shader_graph.h.
References node.
Referenced by clean(), clear_nodes(), and remove_proxy_nodes().
void ShaderGraph::disconnect | ( | ShaderInput * | to | ) |
Definition at line 297 of file shader_graph.cpp.
References ShaderInput::disconnect(), finalized, ShaderInput::link, and simplified.
void ShaderGraph::disconnect | ( | ShaderOutput * | from | ) |
Definition at line 289 of file shader_graph.cpp.
References finalized, from, and simplified.
Referenced by break_cycles(), ConstantFolder::bypass(), ConstantFolder::discard(), ConstantFolder::make_constant(), refine_bump_nodes(), relink(), remove_proxy_nodes(), transform_multi_closure(), ConstantFolder::try_bypass_or_make_constant(), and verify_volume_output().
void ShaderGraph::dump_graph | ( | const char * | filename | ) |
Definition at line 1153 of file shader_graph.cpp.
References input, Node::name, ShaderInput::name(), ShaderOutput::name(), node, nodes, NULL, output(), SHADER_BUMP_CENTER, SHADER_BUMP_DX, and SHADER_BUMP_DY.
|
protected |
Definition at line 818 of file shader_graph.cpp.
Referenced by simplify().
void ShaderGraph::finalize | ( | Scene * | scene, |
bool | do_bump = false , |
||
bool | do_simplify = false , |
||
bool | bump_in_object_space = false |
||
) |
Definition at line 360 of file shader_graph.cpp.
References bump_from_displacement(), finalized, ShaderNode::input(), ShaderInput::link, NULL, output(), ShaderOutput::parent, scene, simplify(), simplify_settings(), and transform_multi_closure().
Referenced by SVMCompiler::compile().
|
protected |
Definition at line 390 of file shader_graph.cpp.
References if(), input, node, and NULL.
Referenced by bump_from_displacement(), compute_displacement_hash(), and refine_bump_nodes().
int ShaderGraph::get_num_closures | ( | ) |
Definition at line 1118 of file shader_graph.cpp.
References CLOSURE_BSDF_HAIR_PRINCIPLED_ID, CLOSURE_IS_BSDF_MULTISCATTER, CLOSURE_IS_BSSRDF, CLOSURE_IS_GLASS, CLOSURE_IS_PRINCIPLED, CLOSURE_IS_VOLUME, CLOSURE_NONE_ID, MAX_VOLUME_STACK_SIZE, node, and nodes.
Referenced by Scene::get_max_closure_count().
OutputNode * ShaderGraph::output | ( | ) |
Definition at line 229 of file shader_graph.cpp.
References nodes.
Referenced by bump_from_displacement(), clean(), SVMCompiler::compile(), compute_displacement_hash(), constant_fold(), deduplicate_nodes(), dump_graph(), finalize(), ShaderManager::get_kernel_features(), Shader::is_constant_emission(), remove_proxy_nodes(), Shader::set_graph(), Shader::tag_update(), and verify_volume_output().
|
protected |
Definition at line 889 of file shader_graph.cpp.
References add(), connect(), copy_nodes(), disconnect(), find_dependencies(), ShaderInput::link, node, nodes, usdtokens::out(), SHADER_BUMP_CENTER, SHADER_BUMP_DX, SHADER_BUMP_DY, and SHADER_SPECIAL_TYPE_BUMP.
Referenced by simplify().
void ShaderGraph::relink | ( | ShaderInput * | from, |
ShaderInput * | to | ||
) |
Definition at line 306 of file shader_graph.cpp.
References connect(), Node::copy_value(), disconnect(), from, usdtokens::out(), ShaderInput::parent, and ShaderInput::socket_type.
Referenced by deduplicate_nodes(), and remove_proxy_nodes().
void ShaderGraph::relink | ( | ShaderNode * | node, |
ShaderOutput * | from, | ||
ShaderOutput * | to | ||
) |
Definition at line 328 of file shader_graph.cpp.
References connect(), disconnect(), from, ShaderInput::link, node, outputs, and simplified.
void ShaderGraph::relink | ( | ShaderOutput * | from, |
ShaderOutput * | to | ||
) |
Definition at line 316 of file shader_graph.cpp.
References connect(), disconnect(), from, and outputs.
void ShaderGraph::remove_proxy_nodes | ( | ) |
Definition at line 454 of file shader_graph.cpp.
References Node::copy_value(), SocketType::DEFAULT_LINK_MASK, delete_node(), disconnect(), ShaderInput::flags(), ShaderNode::id, input, ShaderNode::inputs, node, nodes, num_node_ids, output(), ShaderNode::outputs, ShaderInput::parent, relink(), SHADER_SPECIAL_TYPE_AUTOCONVERT, SHADER_SPECIAL_TYPE_PROXY, ShaderInput::socket_type, and ShaderNode::special_type.
Referenced by Shader::set_graph().
Definition at line 348 of file shader_graph.cpp.
References clean(), default_inputs(), expand(), refine_bump_nodes(), scene, Scene::shader_manager, simplified, and ShaderManager::use_osl().
Referenced by finalize().
Definition at line 583 of file shader_graph.cpp.
References node, nodes, and scene.
Referenced by clean(), and finalize().
|
protected |
Definition at line 1040 of file shader_graph.cpp.
References add(), connect(), disconnect(), ShaderNode::input(), ShaderInput::link, node, ShaderNode::output(), ShaderOutput::parent, SHADER_SPECIAL_TYPE_COMBINE_CLOSURE, and ShaderInput::socket_type.
Referenced by finalize().
|
protected |
Definition at line 669 of file shader_graph.cpp.
References disconnect(), input, ShaderNode::input(), ShaderInput::link, node, NULL, output(), ShaderOutput::parent, and VLOG_DEBUG.
Referenced by clean().
string ShaderGraph::displacement_hash |
Definition at line 303 of file shader_graph.h.
Referenced by compute_displacement_hash(), and Shader::set_graph().
bool ShaderGraph::finalized |
Definition at line 301 of file shader_graph.h.
Referenced by add(), connect(), disconnect(), finalize(), and ShaderGraph().
list<ShaderNode *> ShaderGraph::nodes |
Definition at line 299 of file shader_graph.h.
Referenced by add(), clean(), clear_nodes(), constant_fold(), copy_nodes(), deduplicate_nodes(), default_inputs(), LightManager::device_update_background(), GeometryManager::device_update_displacement_images(), dump_graph(), expand(), get_num_closures(), Shader::is_constant_emission(), output(), refine_bump_nodes(), remove_proxy_nodes(), simplify_settings(), and Shader::tag_update().
size_t ShaderGraph::num_node_ids |
Definition at line 300 of file shader_graph.h.
Referenced by add(), clean(), remove_proxy_nodes(), and ShaderGraph().
bool ShaderGraph::simplified |
Definition at line 302 of file shader_graph.h.
Referenced by add(), disconnect(), relink(), ShaderGraph(), and simplify().