forked from bartvdbraak/blender
Code cleanup: use special type instead of node names.
This commit is contained in:
parent
dfe9aa25c3
commit
a815e10211
@ -910,7 +910,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight
|
||||
* avoid building a closure tree and then flattening it, and instead write it
|
||||
* directly to an array */
|
||||
|
||||
if(node->name == ustring("mix_closure") || node->name == ustring("add_closure")) {
|
||||
if(node->special_type == SHADER_SPECIAL_TYPE_COMBINE_CLOSURE) {
|
||||
ShaderInput *fin = node->input("Fac");
|
||||
ShaderInput *cl1in = node->input("Closure1");
|
||||
ShaderInput *cl2in = node->input("Closure2");
|
||||
|
@ -81,6 +81,8 @@ enum ShaderNodeSpecialType {
|
||||
SHADER_SPECIAL_TYPE_SCRIPT,
|
||||
SHADER_SPECIAL_TYPE_IMAGE_SLOT,
|
||||
SHADER_SPECIAL_TYPE_CLOSURE,
|
||||
SHADER_SPECIAL_TYPE_COMBINE_CLOSURE,
|
||||
SHADER_SPECIAL_TYPE_OUTPUT,
|
||||
SHADER_SPECIAL_TYPE_BUMP,
|
||||
};
|
||||
|
||||
|
@ -3126,6 +3126,8 @@ void ColorNode::compile(OSLCompiler& compiler)
|
||||
AddClosureNode::AddClosureNode()
|
||||
: ShaderNode("add_closure")
|
||||
{
|
||||
special_type = SHADER_SPECIAL_TYPE_COMBINE_CLOSURE;
|
||||
|
||||
add_input("Closure1", SHADER_SOCKET_CLOSURE);
|
||||
add_input("Closure2", SHADER_SOCKET_CLOSURE);
|
||||
add_output("Closure", SHADER_SOCKET_CLOSURE);
|
||||
@ -3146,6 +3148,8 @@ void AddClosureNode::compile(OSLCompiler& compiler)
|
||||
MixClosureNode::MixClosureNode()
|
||||
: ShaderNode("mix_closure")
|
||||
{
|
||||
special_type = SHADER_SPECIAL_TYPE_COMBINE_CLOSURE;
|
||||
|
||||
add_input("Fac", SHADER_SOCKET_FLOAT, 0.5f);
|
||||
add_input("Closure1", SHADER_SOCKET_CLOSURE);
|
||||
add_input("Closure2", SHADER_SOCKET_CLOSURE);
|
||||
@ -3963,6 +3967,8 @@ void BlackbodyNode::compile(OSLCompiler& compiler)
|
||||
OutputNode::OutputNode()
|
||||
: ShaderNode("output")
|
||||
{
|
||||
special_type = SHADER_SPECIAL_TYPE_OUTPUT;
|
||||
|
||||
add_input("Surface", SHADER_SOCKET_CLOSURE);
|
||||
add_input("Volume", SHADER_SOCKET_CLOSURE);
|
||||
add_input("Displacement", SHADER_SOCKET_FLOAT);
|
||||
|
@ -473,7 +473,7 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input)
|
||||
if(!(input->usage & ShaderInput::USE_OSL))
|
||||
return true;
|
||||
|
||||
if(node->name == ustring("output")) {
|
||||
if(node->special_type == SHADER_SPECIAL_TYPE_OUTPUT) {
|
||||
if(strcmp(input->name, "Surface") == 0 && current_type != SHADER_TYPE_SURFACE)
|
||||
return true;
|
||||
if(strcmp(input->name, "Volume") == 0 && current_type != SHADER_TYPE_VOLUME)
|
||||
|
@ -506,7 +506,7 @@ void SVMCompiler::generate_multi_closure(ShaderNode *root_node,
|
||||
|
||||
state->closure_done.insert(node);
|
||||
|
||||
if(node->name == ustring("mix_closure") || node->name == ustring("add_closure")) {
|
||||
if(node->special_type == SHADER_SPECIAL_TYPE_COMBINE_CLOSURE) {
|
||||
/* weighting is already taken care of in ShaderGraph::transform_multi_closure */
|
||||
ShaderInput *cl1in = node->input("Closure1");
|
||||
ShaderInput *cl2in = node->input("Closure2");
|
||||
|
Loading…
Reference in New Issue
Block a user