|
Blender V5.0
|
#include <shader_graph.h>
Inherits NodeOwner.
Public Member Functions | |
| ShaderGraph () | |
| ~ShaderGraph () override | |
| 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 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, typename... Args> | |
| T * | create_osl_node (void *node_memory, Args &&...args) |
| ShaderNode * | create_node (const NodeType *node_type) |
| Public Member Functions inherited from NodeOwner | |
| virtual | ~NodeOwner () |
Public Attributes | |
| unique_ptr_vector< ShaderNode > | nodes |
| size_t | num_node_ids |
| bool | finalized |
| bool | simplified |
| string | displacement_hash |
Protected Types | |
| using | NodePair = pair<ShaderNode *const, ShaderNode *> |
Protected Member Functions | |
| void | add_node (unique_ptr< ShaderNode > &&node) |
| 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 | optimize_volume_output () |
Definition at line 315 of file shader_graph.h.
|
protected |
Definition at line 373 of file shader_graph.h.
| ShaderGraph::ShaderGraph | ( | ) |
Definition at line 218 of file shader_graph.cpp.
References create_node(), finalized, num_node_ids, and simplified.
|
override |
Definition at line 226 of file shader_graph.cpp.
References clear_nodes().
|
protected |
Definition at line 231 of file shader_graph.cpp.
References assert, finalized, nodes, num_node_ids, and simplified.
Referenced by create_node(), create_node(), and create_osl_node().
|
protected |
Definition at line 741 of file shader_graph.cpp.
References break_cycles(), disconnect(), ShaderNode::id, input, ShaderNode::inputs, and LOG_WARNING.
Referenced by break_cycles(), and clean().
|
protected |
Definition at line 1003 of file shader_graph.cpp.
References connect(), copy_nodes(), create_node(), find_dependencies(), input, ShaderNode::input(), ShaderInput::link, NODE_VECTOR_MATH_DOT_PRODUCT, out, output(), ShaderNode::output(), SHADER_BUMP_CENTER, SHADER_BUMP_DX, and SHADER_BUMP_DY.
Referenced by finalize().
|
protected |
Definition at line 799 of file shader_graph.cpp.
References break_cycles(), constant_fold(), deduplicate_nodes(), i, ShaderInput::link, ShaderOutput::links, nodes, num_node_ids, optimize_volume_output(), output(), unique_ptr_vector< T >::push_back(), SHADER_SPECIAL_TYPE_OUTPUT_AOV, and simplify_settings().
Referenced by simplify().
|
protected |
| void ShaderGraph::compute_displacement_hash | ( | ) |
Definition at line 765 of file shader_graph.cpp.
References MD5Hash::append(), OSLNode::bytecode_hash, displacement_hash, find_dependencies(), MD5Hash::get_hex(), input, ShaderNode::input(), ShaderInput::link, output(), and SHADER_SPECIAL_TYPE_OSL.
| void ShaderGraph::connect | ( | ShaderOutput * | from, |
| ShaderInput * | to ) |
Definition at line 246 of file shader_graph.cpp.
References assert, SocketType::CLOSURE, connect(), create_node(), finalized, SocketType::FLOAT, EmissionNode::from_auto_conversion, ShaderInput::link, ShaderOutput::links, LOG_WARNING, Node::name, ShaderInput::name(), ShaderOutput::name(), one_float3(), ShaderInput::parent, ShaderOutput::parent, ShaderInput::type(), and ShaderOutput::type().
Referenced by add_nodes_inlined(), bump_from_displacement(), connect(), constant_fold(), copy_nodes(), default_inputs(), MapRangeNode::expand(), MathNode::expand(), refine_bump_nodes(), relink(), relink(), relink(), and transform_multi_closure().
|
protected |
Definition at line 531 of file shader_graph.cpp.
References connect(), ShaderNode::constant_fold(), create_node(), input, ShaderNode::input(), ShaderInput::link, nodes, output(), ShaderNode::output(), ShaderNode::outputs, and Node::set_value().
Referenced by clean().
|
protected |
Definition at line 421 of file shader_graph.cpp.
References ShaderNode::clone(), connect(), input, ShaderNode::input(), nodes, and ShaderNode::output().
Referenced by bump_from_displacement(), and refine_bump_nodes().
Definition at line 345 of file shader_graph.h.
References add_node(), and T.
Referenced by add_node(), add_nodes_inlined(), bump_from_displacement(), EnvironmentTextureNode::clone(), IESLightNode::clone(), ImageTextureNode::clone(), connect(), BumpNode::constant_fold(), constant_fold(), default_inputs(), MapRangeNode::expand(), MathNode::expand(), VolumeInfoNode::expand(), ShaderGraph(), CCL_NAMESPACE_BEGIN::ShaderNodeBuilder< T >::ShaderNodeBuilder(), and transform_multi_closure().
|
inline |
Definition at line 363 of file shader_graph.h.
References add_node(), and NodeType::create.
|
inline |
Definition at line 354 of file shader_graph.h.
References add_node(), and T.
Referenced by OSLNode::create().
|
protected |
Definition at line 598 of file shader_graph.cpp.
References ShaderNode::equals(), i, input, LOG_TRACE, NodeType::name, nodes, output(), ShaderNode::outputs, relink(), unique_ptr_vector< T >::size(), and Node::type.
Referenced by clean().
|
protected |
Definition at line 862 of file shader_graph.cpp.
References connect(), create_node(), i, input, ShaderNode::input(), ShaderNode::inputs, SocketType::LINK_INCOMING, SocketType::LINK_NORMAL, SocketType::LINK_POSITION, SocketType::LINK_TANGENT, SocketType::LINK_TEXTURE_GENERATED, SocketType::LINK_TEXTURE_INCOMING, SocketType::LINK_TEXTURE_NORMAL, SocketType::LINK_TEXTURE_UV, NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT, NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD, NODE_VECTOR_TRANSFORM_TYPE_NORMAL, nodes, SocketType::OSL_INTERNAL, and ShaderNode::output().
Referenced by simplify().
| void ShaderGraph::disconnect | ( | ShaderInput * | to | ) |
Definition at line 306 of file shader_graph.cpp.
References assert, ShaderInput::disconnect(), finalized, ShaderInput::link, and simplified.
| void ShaderGraph::disconnect | ( | ShaderOutput * | from | ) |
Definition at line 298 of file shader_graph.cpp.
References assert, ShaderOutput::disconnect(), finalized, and simplified.
Referenced by break_cycles(), optimize_volume_output(), refine_bump_nodes(), relink(), relink(), relink(), remove_proxy_nodes(), and transform_multi_closure().
| void ShaderGraph::dump_graph | ( | const char * | filename | ) |
Definition at line 1227 of file shader_graph.cpp.
References input, LOG_ERROR, ShaderInput::name(), ShaderOutput::name(), nodes, output(), SHADER_BUMP_CENTER, SHADER_BUMP_DX, and SHADER_BUMP_DY.
|
protected |
Definition at line 851 of file shader_graph.cpp.
References ShaderNode::expand(), i, and nodes.
Referenced by simplify().
| void ShaderGraph::finalize | ( | Scene * | scene, |
| bool | do_bump = false, | ||
| bool | bump_in_object_space = false ) |
Definition at line 372 of file shader_graph.cpp.
References bump_from_displacement(), finalized, ShaderNode::input(), ShaderInput::link, output(), ShaderOutput::parent, simplify(), and transform_multi_closure().
|
protected |
Definition at line 402 of file shader_graph.cpp.
References find_dependencies(), in, input, and ShaderNode::inputs.
Referenced by bump_from_displacement(), compute_displacement_hash(), find_dependencies(), and refine_bump_nodes().
| int ShaderGraph::get_num_closures | ( | ) |
Definition at line 1189 of file shader_graph.cpp.
References CLOSURE_BSDF_F82_CONDUCTOR, CLOSURE_BSDF_HAIR_CHIANG_ID, CLOSURE_BSDF_HAIR_HUANG_ID, CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID, CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID, CLOSURE_BSDF_PHYSICAL_CONDUCTOR, CLOSURE_IS_BSDF_MULTISCATTER, CLOSURE_IS_BSSRDF, CLOSURE_IS_PRINCIPLED, CLOSURE_IS_VOLUME, CLOSURE_NONE_ID, MAX_VOLUME_STACK_SIZE, and nodes.
|
protected |
Definition at line 677 of file shader_graph.cpp.
References disconnect(), input, ShaderNode::input(), ShaderInput::link, LOG_IS_ON, LOG_LEVEL_TRACE, LOG_TRACE, nodes, output(), ShaderOutput::parent, and AttributeNode::stochastic_sample.
Referenced by clean().
| OutputNode * ShaderGraph::output | ( | ) |
Definition at line 241 of file shader_graph.cpp.
References nodes.
Referenced by add_nodes_inlined(), bump_from_displacement(), clean(), SVMCompiler::compile_type(), compute_displacement_hash(), constant_fold(), deduplicate_nodes(), dump_graph(), finalize(), optimize_volume_output(), and remove_proxy_nodes().
|
protected |
Definition at line 944 of file shader_graph.cpp.
References ShaderNode::bump, ShaderNode::bump_filter_width, connect(), copy_nodes(), disconnect(), find_dependencies(), i, ShaderNode::input(), ShaderInput::link, nodes, out, SHADER_BUMP_CENTER, SHADER_BUMP_DX, SHADER_BUMP_DY, SHADER_SPECIAL_TYPE_BUMP, and ShaderNode::special_type.
Referenced by simplify().
| void ShaderGraph::relink | ( | ShaderInput * | from, |
| ShaderInput * | to ) |
Definition at line 315 of file shader_graph.cpp.
References connect(), Node::copy_value(), disconnect(), ShaderInput::link, out, ShaderInput::parent, and ShaderInput::socket_type.
Referenced by deduplicate_nodes(), MapRangeNode::expand(), MathNode::expand(), VolumeInfoNode::expand(), and remove_proxy_nodes().
| void ShaderGraph::relink | ( | ShaderNode * | node, |
| ShaderOutput * | from, | ||
| ShaderOutput * | to ) |
Definition at line 338 of file shader_graph.cpp.
References connect(), disconnect(), ShaderNode::inputs, ShaderInput::link, ShaderOutput::links, outputs, and simplified.
| void ShaderGraph::relink | ( | ShaderOutput * | from, |
| ShaderOutput * | to ) |
Definition at line 325 of file shader_graph.cpp.
References connect(), disconnect(), ShaderOutput::links, and outputs.
| void ShaderGraph::remove_proxy_nodes | ( | ) |
Definition at line 457 of file shader_graph.cpp.
References Node::copy_value(), SocketType::DEFAULT_LINK_MASK, disconnect(), i, ShaderNode::id, input, ShaderNode::inputs, nodes, num_node_ids, output(), ShaderNode::outputs, unique_ptr_vector< T >::push_back(), relink(), SHADER_SPECIAL_TYPE_AUTOCONVERT, SHADER_SPECIAL_TYPE_PROXY, and ShaderNode::special_type.
| void ShaderGraph::simplify | ( | Scene * | scene | ) |
Definition at line 360 of file shader_graph.cpp.
References clean(), default_inputs(), expand(), refine_bump_nodes(), Scene::shader_manager, and simplified.
Referenced by finalize().
|
protected |
|
protected |
Definition at line 1099 of file shader_graph.cpp.
References connect(), create_node(), disconnect(), Node::get_float(), ShaderNode::input(), ShaderInput::link, ShaderNode::output(), ShaderOutput::parent, Node::set(), SHADER_SPECIAL_TYPE_COMBINE_CLOSURE, ShaderInput::socket_type, ShaderNode::special_type, and transform_multi_closure().
Referenced by finalize(), and transform_multi_closure().
| string ShaderGraph::displacement_hash |
Definition at line 321 of file shader_graph.h.
Referenced by compute_displacement_hash().
| bool ShaderGraph::finalized |
Definition at line 319 of file shader_graph.h.
Referenced by add_node(), connect(), disconnect(), disconnect(), finalize(), and ShaderGraph().
| unique_ptr_vector<ShaderNode> ShaderGraph::nodes |
Definition at line 317 of file shader_graph.h.
Referenced by add_node(), clean(), clear_nodes(), SVMCompiler::compile_type(), SVMCompiler::CompilerState::CompilerState(), constant_fold(), copy_nodes(), deduplicate_nodes(), default_inputs(), dump_graph(), expand(), SVMCompiler::find_aov_nodes_and_dependencies(), ShaderManager::get_graph_kernel_features(), get_num_closures(), optimize_volume_output(), output(), refine_bump_nodes(), remove_proxy_nodes(), and simplify_settings().
| size_t ShaderGraph::num_node_ids |
Definition at line 318 of file shader_graph.h.
Referenced by add_node(), clean(), remove_proxy_nodes(), and ShaderGraph().
| bool ShaderGraph::simplified |
Definition at line 320 of file shader_graph.h.
Referenced by add_node(), disconnect(), disconnect(), relink(), ShaderGraph(), and simplify().