Cycles: nodify shader nodes

Differential Revision: https://developer.blender.org/D2038
This commit is contained in:
Brecht Van Lommel
2016-05-07 19:48:28 +02:00
parent 4df6474f01
commit 42aec3b355
10 changed files with 2185 additions and 1997 deletions

View File

@@ -192,14 +192,16 @@ int SVMCompiler::stack_assign(ShaderInput *input)
input->stack_offset = input->link->stack_offset;
}
else {
Node *node = input->parent;
/* not linked to output -> add nodes to load default value */
input->stack_offset = stack_find_offset(input->type());
if(input->type() == SocketType::FLOAT) {
add_node(NODE_VALUE_F, __float_as_int(input->value_float()), input->stack_offset);
add_node(NODE_VALUE_F, __float_as_int(node->get_float(input->socket_type)), input->stack_offset);
}
else if(input->type() == SocketType::INT) {
add_node(NODE_VALUE_F, (int)input->value_float(), input->stack_offset);
add_node(NODE_VALUE_F, node->get_int(input->socket_type), input->stack_offset);
}
else if(input->type() == SocketType::VECTOR ||
input->type() == SocketType::NORMAL ||
@@ -208,7 +210,7 @@ int SVMCompiler::stack_assign(ShaderInput *input)
{
add_node(NODE_VALUE_V, input->stack_offset);
add_node(NODE_VALUE_V, input->value());
add_node(NODE_VALUE_V, node->get_float3(input->socket_type));
}
else /* should not get called for closure */
assert(0);
@@ -446,7 +448,7 @@ void SVMCompiler::generate_closure_node(ShaderNode *node,
const char *weight_name = (current_type == SHADER_TYPE_VOLUME)? "VolumeMixWeight": "SurfaceMixWeight";
ShaderInput *weight_in = node->input(weight_name);
if(weight_in && (weight_in->link || weight_in->value_float() != 1.0f))
if(weight_in && (weight_in->link || node->get_float(weight_in->socket_type) != 1.0f))
mix_weight_offset = stack_assign(weight_in);
else
mix_weight_offset = SVM_STACK_INVALID;