|
Blender V4.5
|
#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 | verify_volume_output () |
Definition at line 294 of file shader_graph.h.
|
protected |
Definition at line 352 of file shader_graph.h.
| ShaderGraph::ShaderGraph | ( | ) |
Definition at line 210 of file shader_graph.cpp.
References create_node(), finalized, num_node_ids, and simplified.
|
override |
Definition at line 218 of file shader_graph.cpp.
References clear_nodes().
|
protected |
Definition at line 223 of file shader_graph.cpp.
References assert, finalized, node, nodes, num_node_ids, unique_ptr_vector< T >::push_back(), and simplified.
Referenced by create_node(), create_node(), and create_osl_node().
|
protected |
Definition at line 712 of file shader_graph.cpp.
References break_cycles(), disconnect(), ShaderNode::id, input, node, and visited.
Referenced by break_cycles(), and clean().
|
protected |
Definition at line 974 of file shader_graph.cpp.
References ShaderNode::bump, 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 770 of file shader_graph.cpp.
References break_cycles(), constant_fold(), deduplicate_nodes(), from, ShaderOutput::links, node, nodes, num_node_ids, output(), unique_ptr_vector< T >::push_back(), scene, SHADER_SPECIAL_TYPE_OUTPUT_AOV, simplify_settings(), unique_ptr_vector< T >::size(), unique_ptr_vector< T >::steal(), verify_volume_output(), and visited.
Referenced by simplify().
|
protected |
Definition at line 412 of file shader_graph.cpp.
References unique_ptr_vector< T >::clear(), and nodes.
Referenced by ~ShaderGraph().
| void ShaderGraph::compute_displacement_hash | ( | ) |
Definition at line 736 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.
| void ShaderGraph::connect | ( | ShaderOutput * | from, |
| ShaderInput * | to ) |
Definition at line 238 of file shader_graph.cpp.
References assert, SocketType::CLOSURE, connect(), create_node(), finalized, SocketType::FLOAT, from, EmissionNode::from_auto_conversion, ShaderInput::link, ShaderOutput::links, Node::name, ShaderInput::name(), one_float3(), ShaderInput::parent, and ShaderInput::type().
Referenced by bump_from_displacement(), ConstantFolder::bypass(), connect(), constant_fold(), copy_nodes(), default_inputs(), refine_bump_nodes(), relink(), relink(), relink(), and transform_multi_closure().
|
protected |
Definition at line 527 of file shader_graph.cpp.
References connect(), create_node(), input, ShaderNode::input(), ShaderInput::link, node, nodes, output(), scene, and value.
Referenced by clean().
|
protected |
Definition at line 417 of file shader_graph.cpp.
References ShaderNode::clone(), connect(), input, ShaderNode::input(), node, nodes, and ShaderNode::output().
Referenced by bump_from_displacement(), and refine_bump_nodes().
Definition at line 324 of file shader_graph.h.
References add_node(), and node.
Referenced by bump_from_displacement(), connect(), BumpNode::constant_fold(), constant_fold(), default_inputs(), ShaderGraph(), and transform_multi_closure().
|
inline |
Definition at line 342 of file shader_graph.h.
References add_node(), NodeType::create, and node.
|
inline |
Definition at line 333 of file shader_graph.h.
References add_node(), node, and T.
|
protected |
Definition at line 594 of file shader_graph.cpp.
References input, node, nodes, output(), ShaderNode::outputs, relink(), and VLOG_DEBUG.
Referenced by clean().
|
protected |
Definition at line 833 of file shader_graph.cpp.
References connect(), create_node(), input, ShaderNode::input(), 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, NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT, NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD, NODE_VECTOR_TRANSFORM_TYPE_NORMAL, nodes, SocketType::OSL_INTERNAL, ShaderNode::output(), and unique_ptr_vector< T >::size().
Referenced by simplify().
| void ShaderGraph::disconnect | ( | ShaderInput * | to | ) |
Definition at line 302 of file shader_graph.cpp.
References assert, ShaderInput::disconnect(), finalized, ShaderInput::link, and simplified.
| void ShaderGraph::disconnect | ( | ShaderOutput * | from | ) |
Definition at line 294 of file shader_graph.cpp.
References assert, finalized, from, and simplified.
Referenced by break_cycles(), ConstantFolder::bypass(), ConstantFolder::discard(), ConstantFolder::make_constant(), ConstantFolder::make_constant(), ConstantFolder::make_constant(), refine_bump_nodes(), relink(), relink(), 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 1198 of file shader_graph.cpp.
References input, Node::name, node, nodes, output(), printf, SHADER_BUMP_CENTER, SHADER_BUMP_DX, and SHADER_BUMP_DY.
|
protected |
Definition at line 822 of file shader_graph.cpp.
References node, nodes, and unique_ptr_vector< T >::size().
Referenced by simplify().
| void ShaderGraph::finalize | ( | Scene * | scene, |
| bool | do_bump = false, | ||
| bool | bump_in_object_space = false ) |
Definition at line 368 of file shader_graph.cpp.
References bump_from_displacement(), finalized, ShaderNode::input(), ShaderInput::link, output(), ShaderOutput::parent, scene, simplify(), and transform_multi_closure().
|
protected |
Definition at line 398 of file shader_graph.cpp.
References find_dependencies(), in, input, and node.
Referenced by bump_from_displacement(), compute_displacement_hash(), find_dependencies(), and refine_bump_nodes().
| int ShaderGraph::get_num_closures | ( | ) |
Definition at line 1160 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, node, and nodes.
| OutputNode * ShaderGraph::output | ( | ) |
Definition at line 233 of file shader_graph.cpp.
References nodes.
Referenced by bump_from_displacement(), clean(), compute_displacement_hash(), constant_fold(), deduplicate_nodes(), dump_graph(), finalize(), remove_proxy_nodes(), and verify_volume_output().
|
protected |
Definition at line 915 of file shader_graph.cpp.
References ShaderNode::bump, connect(), copy_nodes(), disconnect(), find_dependencies(), ShaderInput::link, node, nodes, out, SHADER_BUMP_CENTER, SHADER_BUMP_DX, SHADER_BUMP_DY, SHADER_SPECIAL_TYPE_BUMP, and unique_ptr_vector< T >::size().
Referenced by simplify().
| void ShaderGraph::relink | ( | ShaderInput * | from, |
| ShaderInput * | to ) |
Definition at line 311 of file shader_graph.cpp.
References connect(), Node::copy_value(), disconnect(), from, 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 334 of file shader_graph.cpp.
References connect(), disconnect(), from, node, outputs, and simplified.
| void ShaderGraph::relink | ( | ShaderOutput * | from, |
| ShaderOutput * | to ) |
Definition at line 321 of file shader_graph.cpp.
References connect(), disconnect(), from, and outputs.
| void ShaderGraph::remove_proxy_nodes | ( | ) |
Definition at line 453 of file shader_graph.cpp.
References Node::copy_value(), SocketType::DEFAULT_LINK_MASK, disconnect(), ShaderNode::id, input, ShaderNode::inputs, node, nodes, num_node_ids, output(), ShaderNode::outputs, unique_ptr_vector< T >::push_back(), relink(), SHADER_SPECIAL_TYPE_AUTOCONVERT, SHADER_SPECIAL_TYPE_PROXY, unique_ptr_vector< T >::size(), ShaderNode::special_type, and unique_ptr_vector< T >::steal().
| void ShaderGraph::simplify | ( | Scene * | scene | ) |
Definition at line 356 of file shader_graph.cpp.
References clean(), default_inputs(), expand(), refine_bump_nodes(), scene, Scene::shader_manager, and simplified.
Referenced by finalize().
|
protected |
|
protected |
Definition at line 1070 of file shader_graph.cpp.
References connect(), create_node(), disconnect(), ShaderNode::input(), ShaderInput::link, node, ShaderNode::output(), ShaderOutput::parent, SHADER_SPECIAL_TYPE_COMBINE_CLOSURE, ShaderInput::socket_type, and transform_multi_closure().
Referenced by finalize(), and transform_multi_closure().
|
protected |
Definition at line 673 of file shader_graph.cpp.
References disconnect(), input, ShaderNode::input(), ShaderInput::link, node, output(), ShaderOutput::parent, and VLOG_DEBUG.
Referenced by clean().
| string ShaderGraph::displacement_hash |
Definition at line 300 of file shader_graph.h.
Referenced by compute_displacement_hash().
| bool ShaderGraph::finalized |
Definition at line 298 of file shader_graph.h.
Referenced by add_node(), connect(), disconnect(), disconnect(), finalize(), and ShaderGraph().
| unique_ptr_vector<ShaderNode> ShaderGraph::nodes |
Definition at line 296 of file shader_graph.h.
Referenced by add_node(), clean(), clear_nodes(), constant_fold(), copy_nodes(), deduplicate_nodes(), default_inputs(), dump_graph(), expand(), get_num_closures(), output(), refine_bump_nodes(), remove_proxy_nodes(), and simplify_settings().
| size_t ShaderGraph::num_node_ids |
Definition at line 297 of file shader_graph.h.
Referenced by add_node(), clean(), remove_proxy_nodes(), and ShaderGraph().
| bool ShaderGraph::simplified |
Definition at line 299 of file shader_graph.h.
Referenced by add_node(), disconnect(), disconnect(), relink(), ShaderGraph(), and simplify().