diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2016-05-08 02:32:09 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2016-06-08 22:45:40 +0300 |
commit | 13a7893495d7dacd5b12c9ac6a6fb5035ba1016d (patch) | |
tree | 13ab1244723397d62740f1b14cfe2e9925556266 | |
parent | a6229ba63ab5ffe51a1a4400f8ddd168963badb1 (diff) |
Code refactor: make ShaderNode match Node a bit more, reusing types and enums.
Differential Revision: https://developer.blender.org/D2016
-rw-r--r-- | intern/cycles/app/cycles_xml.cpp | 60 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 72 | ||||
-rw-r--r-- | intern/cycles/render/graph.cpp | 134 | ||||
-rw-r--r-- | intern/cycles/render/graph.h | 105 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 958 | ||||
-rw-r--r-- | intern/cycles/render/nodes.h | 62 | ||||
-rw-r--r-- | intern/cycles/render/osl.cpp | 57 | ||||
-rw-r--r-- | intern/cycles/render/shader.cpp | 6 | ||||
-rw-r--r-- | intern/cycles/render/svm.cpp | 54 | ||||
-rw-r--r-- | intern/cycles/render/svm.h | 6 |
10 files changed, 738 insertions, 776 deletions
diff --git a/intern/cycles/app/cycles_xml.cpp b/intern/cycles/app/cycles_xml.cpp index bee8fa7d996..896a4906161 100644 --- a/intern/cycles/app/cycles_xml.cpp +++ b/intern/cycles/app/cycles_xml.cpp @@ -214,7 +214,7 @@ static bool xml_equal_string(pugi::xml_node node, const char *name, const char * return false; } -static bool xml_read_enum(ustring *str, ShaderEnum& enm, pugi::xml_node node, const char *name) +static bool xml_read_enum(ustring *str, NodeEnum& enm, pugi::xml_node node, const char *name) { pugi::xml_attribute attr = node.attribute(name); @@ -232,7 +232,7 @@ static bool xml_read_enum(ustring *str, ShaderEnum& enm, pugi::xml_node node, co return false; } -static bool xml_read_enum_value(int *value, ShaderEnum& enm, pugi::xml_node node, const char *name) +static bool xml_read_enum_value(int *value, NodeEnum& enm, pugi::xml_node node, const char *name) { pugi::xml_attribute attr = node.attribute(name); @@ -250,33 +250,33 @@ static bool xml_read_enum_value(int *value, ShaderEnum& enm, pugi::xml_node node return false; } -static ShaderSocketType xml_read_socket_type(pugi::xml_node node, const char *name) +static SocketType::Type xml_read_socket_type(pugi::xml_node node, const char *name) { pugi::xml_attribute attr = node.attribute(name); if(attr) { string value = attr.value(); if(string_iequals(value, "float")) - return SHADER_SOCKET_FLOAT; + return SocketType::FLOAT; else if(string_iequals(value, "int")) - return SHADER_SOCKET_INT; + return SocketType::INT; else if(string_iequals(value, "color")) - return SHADER_SOCKET_COLOR; + return SocketType::COLOR; else if(string_iequals(value, "vector")) - return SHADER_SOCKET_VECTOR; + return SocketType::VECTOR; else if(string_iequals(value, "point")) - return SHADER_SOCKET_POINT; + return SocketType::POINT; else if(string_iequals(value, "normal")) - return SHADER_SOCKET_NORMAL; + return SocketType::NORMAL; else if(string_iequals(value, "closure color")) - return SHADER_SOCKET_CLOSURE; + return SocketType::CLOSURE; else if(string_iequals(value, "string")) - return SHADER_SOCKET_STRING; + return SocketType::STRING; else fprintf(stderr, "Unknown shader socket type \"%s\" for attribute \"%s\".\n", value.c_str(), name); } - return SHADER_SOCKET_UNDEFINED; + return SocketType::UNDEFINED; } /* Camera */ @@ -371,8 +371,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml if(!xml_read_string(&name, param, "name")) continue; - ShaderSocketType type = xml_read_socket_type(param, "type"); - if(type == SHADER_SOCKET_UNDEFINED) + SocketType::Type type = xml_read_socket_type(param, "type"); + if(type == SocketType::UNDEFINED) continue; osl->add_input(ustring(name).c_str(), type); @@ -382,8 +382,8 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml if(!xml_read_string(&name, param, "name")) continue; - ShaderSocketType type = xml_read_socket_type(param, "type"); - if(type == SHADER_SOCKET_UNDEFINED) + SocketType::Type type = xml_read_socket_type(param, "type"); + if(type == SocketType::UNDEFINED) continue; osl->add_output(ustring(name).c_str(), type); @@ -699,7 +699,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml ShaderNode *fromnode = nodemap[from_tokens[0]]; foreach(ShaderOutput *out, fromnode->outputs) - if(string_iequals(xml_socket_name(out->name), from_tokens[1])) + if(string_iequals(xml_socket_name(out->name().c_str()), from_tokens[1])) output = out; if(!output) @@ -712,7 +712,7 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml ShaderNode *tonode = nodemap[to_tokens[0]]; foreach(ShaderInput *in, tonode->inputs) - if(string_iequals(xml_socket_name(in->name), to_tokens[1])) + if(string_iequals(xml_socket_name(in->name().c_str()), to_tokens[1])) input = in; if(!input) @@ -744,20 +744,20 @@ static void xml_read_shader_graph(XMLReadState& state, Shader *shader, pugi::xml /* read input values */ for(pugi::xml_attribute attr = node.first_attribute(); attr; attr = attr.next_attribute()) { foreach(ShaderInput *in, snode->inputs) { - if(string_iequals(in->name, attr.name())) { - switch(in->type) { - case SHADER_SOCKET_FLOAT: - case SHADER_SOCKET_INT: - xml_read_float(&in->value.x, node, attr.name()); + if(string_iequals(in->name().c_str(), attr.name())) { + switch(in->type()) { + case SocketType::FLOAT: + case SocketType::INT: + xml_read_float(&in->value_float(), node, attr.name()); break; - case SHADER_SOCKET_COLOR: - case SHADER_SOCKET_VECTOR: - case SHADER_SOCKET_POINT: - case SHADER_SOCKET_NORMAL: - xml_read_float3(&in->value, node, attr.name()); + case SocketType::COLOR: + case SocketType::VECTOR: + case SocketType::POINT: + case SocketType::NORMAL: + xml_read_float3(&in->value(), node, attr.name()); break; - case SHADER_SOCKET_STRING: - xml_read_ustring( &in->value_string, node, attr.name() ); + case SocketType::STRING: + xml_read_ustring( &in->value_string(), node, attr.name() ); break; default: break; diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index a56c2e75e4e..346fe0ca6c4 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -127,42 +127,42 @@ static float3 get_node_output_vector(BL::Node& b_node, const string& name) return make_float3(value[0], value[1], value[2]); } -static ShaderSocketType convert_socket_type(BL::NodeSocket& b_socket) +static SocketType::Type convert_socket_type(BL::NodeSocket& b_socket) { switch(b_socket.type()) { case BL::NodeSocket::type_VALUE: - return SHADER_SOCKET_FLOAT; + return SocketType::FLOAT; case BL::NodeSocket::type_INT: - return SHADER_SOCKET_INT; + return SocketType::INT; case BL::NodeSocket::type_VECTOR: - return SHADER_SOCKET_VECTOR; + return SocketType::VECTOR; case BL::NodeSocket::type_RGBA: - return SHADER_SOCKET_COLOR; + return SocketType::COLOR; case BL::NodeSocket::type_STRING: - return SHADER_SOCKET_STRING; + return SocketType::STRING; case BL::NodeSocket::type_SHADER: - return SHADER_SOCKET_CLOSURE; + return SocketType::CLOSURE; default: - return SHADER_SOCKET_UNDEFINED; + return SocketType::UNDEFINED; } } #ifdef WITH_OSL -static ShaderSocketType convert_osl_socket_type(OSL::OSLQuery& query, +static SocketType::Type convert_osl_socket_type(OSL::OSLQuery& query, BL::NodeSocket& b_socket) { - ShaderSocketType socket_type = convert_socket_type(b_socket); - if(socket_type == SHADER_SOCKET_VECTOR) { + SocketType::Type socket_type = convert_socket_type(b_socket); + if(socket_type == SocketType::VECTOR) { /* TODO(sergey): Do we need compatible_name() here? */ const OSL::OSLQuery::Parameter *param = query.getparam(b_socket.name()); assert(param != NULL); if(param != NULL) { if(param->type.vecsemantics == TypeDesc::POINT) { - socket_type = SHADER_SOCKET_POINT; + socket_type = SocketType::POINT; } else if(param->type.vecsemantics == TypeDesc::NORMAL) { - socket_type = SHADER_SOCKET_NORMAL; + socket_type = SocketType::NORMAL; } } } @@ -177,32 +177,30 @@ static void set_default_value(ShaderInput *input, BL::ID& b_id) { /* copy values for non linked inputs */ - switch(input->type) { - case SHADER_SOCKET_FLOAT: { - input->set(get_float(b_sock.ptr, "default_value")); + switch(input->type()) { + case SocketType::FLOAT: { + input->value_float() = get_float(b_sock.ptr, "default_value"); break; } - case SHADER_SOCKET_INT: { - input->set((float)get_int(b_sock.ptr, "default_value")); + case SocketType::INT: { + input->value_float() = (float)get_int(b_sock.ptr, "default_value"); break; } - case SHADER_SOCKET_COLOR: { - input->set(float4_to_float3(get_float4(b_sock.ptr, "default_value"))); + case SocketType::COLOR: { + input->value() = float4_to_float3(get_float4(b_sock.ptr, "default_value")); break; } - case SHADER_SOCKET_NORMAL: - case SHADER_SOCKET_POINT: - case SHADER_SOCKET_VECTOR: { - input->set(get_float3(b_sock.ptr, "default_value")); + case SocketType::NORMAL: + case SocketType::POINT: + case SocketType::VECTOR: { + input->value() = get_float3(b_sock.ptr, "default_value"); break; } - case SHADER_SOCKET_STRING: { - input->set((ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value"))); + case SocketType::STRING: { + input->value_string() = (ustring)blender_absolute_path(b_data, b_id, get_string(b_sock.ptr, "default_value")); break; } - - case SHADER_SOCKET_CLOSURE: - case SHADER_SOCKET_UNDEFINED: + default: break; } } @@ -341,7 +339,7 @@ static ShaderNode *add_node(Scene *scene, node = new HSVNode(); } else if(b_node.is_a(&RNA_ShaderNodeRGBToBW)) { - node = new ConvertNode(SHADER_SOCKET_COLOR, SHADER_SOCKET_FLOAT); + node = new ConvertNode(SocketType::COLOR, SocketType::FLOAT); } else if(b_node.is_a(&RNA_ShaderNodeMath)) { BL::ShaderNodeMath b_math_node(b_node); @@ -1020,7 +1018,7 @@ static void add_nodes(Scene *scene, BL::Node::internal_links_iterator b_link; for(b_node->internal_links.begin(b_link); b_link != b_node->internal_links.end(); ++b_link) { BL::NodeSocket to_socket(b_link->to_socket()); - ShaderSocketType to_socket_type = convert_socket_type(to_socket); + SocketType::Type to_socket_type = convert_socket_type(to_socket); ConvertNode *proxy = new ConvertNode(to_socket_type, to_socket_type, true); input_map[b_link->from_socket().ptr.data] = proxy->inputs[0]; @@ -1043,7 +1041,7 @@ static void add_nodes(Scene *scene, * so that links have something to connect to and assert won't fail. */ for(b_node->inputs.begin(b_input); b_input != b_node->inputs.end(); ++b_input) { - ShaderSocketType input_type = convert_socket_type(*b_input); + SocketType::Type input_type = convert_socket_type(*b_input); ConvertNode *proxy = new ConvertNode(input_type, input_type, true); graph->add(proxy); @@ -1055,7 +1053,7 @@ static void add_nodes(Scene *scene, set_default_value(proxy->inputs[0], *b_input, b_data, b_ntree); } for(b_node->outputs.begin(b_output); b_output != b_node->outputs.end(); ++b_output) { - ShaderSocketType output_type = convert_socket_type(*b_output); + SocketType::Type output_type = convert_socket_type(*b_output); ConvertNode *proxy = new ConvertNode(output_type, output_type, true); graph->add(proxy); @@ -1227,7 +1225,7 @@ void BlenderSync::sync_materials(bool update_all) ShaderNode *closure, *out; closure = graph->add(new DiffuseBsdfNode()); - closure->input("Color")->value = get_float3(b_mat->diffuse_color()); + closure->input("Color")->value() = get_float3(b_mat->diffuse_color()); out = graph->output(); graph->connect(closure->output("BSDF"), out->input("Surface")); @@ -1276,7 +1274,7 @@ void BlenderSync::sync_world(bool update_all) ShaderNode *closure, *out; closure = graph->add(new BackgroundNode()); - closure->input("Color")->value = get_float3(b_world.horizon_color()); + closure->input("Color")->value() = get_float3(b_world.horizon_color()); out = graph->output(); graph->connect(closure->output("Background"), out->input("Surface")); @@ -1369,8 +1367,8 @@ void BlenderSync::sync_lamps(bool update_all) } closure = graph->add(new EmissionNode()); - closure->input("Color")->value = get_float3(b_lamp->color()); - closure->input("Strength")->value.x = strength; + closure->input("Color")->value() = get_float3(b_lamp->color()); + closure->input("Strength")->value_float() = strength; out = graph->output(); graph->connect(closure->output("Emission"), out->input("Surface")); diff --git a/intern/cycles/render/graph.cpp b/intern/cycles/render/graph.cpp index 24e4c9f33d5..62998b0166f 100644 --- a/intern/cycles/render/graph.cpp +++ b/intern/cycles/render/graph.cpp @@ -66,7 +66,7 @@ bool check_node_inputs_equals(const ShaderNode *node_a, *input_b = node_b->inputs[i]; if(input_a->link == NULL && input_b->link == NULL) { /* Unconnected inputs are expected to have the same value. */ - if(input_a->value != input_b->value) { + if(input_a->value() != input_b->value()) { return false; } } @@ -90,23 +90,22 @@ bool check_node_inputs_equals(const ShaderNode *node_a, /* Input and Output */ -ShaderInput::ShaderInput(ShaderNode *parent_, const char *name_, ShaderSocketType type_) +ShaderInput::ShaderInput(ShaderNode *parent_, const char *name, SocketType::Type type) { parent = parent_; - name = name_; - type = type_; + name_ = name; + type_ = type; link = NULL; - value = make_float3(0.0f, 0.0f, 0.0f); + value_ = make_float3(0.0f, 0.0f, 0.0f); stack_offset = SVM_STACK_INVALID; - default_value = NONE; - usage = USE_ALL; + flags_ = 0; } -ShaderOutput::ShaderOutput(ShaderNode *parent_, const char *name_, ShaderSocketType type_) +ShaderOutput::ShaderOutput(ShaderNode *parent_, const char *name, SocketType::Type type) { parent = parent_; - name = name_; - type = type_; + name_ = name; + type_ = type; stack_offset = SVM_STACK_INVALID; } @@ -132,7 +131,7 @@ ShaderNode::~ShaderNode() ShaderInput *ShaderNode::input(const char *name) { foreach(ShaderInput *socket, inputs) { - if(strcmp(socket->name, name) == 0) + if(socket->name() == name) return socket; } @@ -142,39 +141,50 @@ ShaderInput *ShaderNode::input(const char *name) ShaderOutput *ShaderNode::output(const char *name) { foreach(ShaderOutput *socket, outputs) - if(strcmp(socket->name, name) == 0) + if(socket->name() == name) return socket; return NULL; } -ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, float value, int usage) +ShaderInput *ShaderNode::input(ustring name) { - ShaderInput *input = new ShaderInput(this, name, type); - input->value.x = value; - input->usage = usage; - inputs.push_back(input); - return input; + foreach(ShaderInput *socket, inputs) { + if(socket->name() == name) + return socket; + } + + return NULL; } -ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, float3 value, int usage) +ShaderOutput *ShaderNode::output(ustring name) +{ + foreach(ShaderOutput *socket, outputs) + if(socket->name() == name) + return socket; + + return NULL; +} + +ShaderInput *ShaderNode::add_input(const char *name, SocketType::Type type, float value, int flags) { ShaderInput *input = new ShaderInput(this, name, type); - input->value = value; - input->usage = usage; + input->value_.x = value; + input->flags_ = flags; inputs.push_back(input); return input; } -ShaderInput *ShaderNode::add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage) +ShaderInput *ShaderNode::add_input(const char *name, SocketType::Type type, float3 value, int flags) { - ShaderInput *input = add_input(name, type); - input->default_value = value; - input->usage = usage; + ShaderInput *input = new ShaderInput(this, name, type); + input->value_ = value; + input->flags_ = flags; + inputs.push_back(input); return input; } -ShaderOutput *ShaderNode::add_output(const char *name, ShaderSocketType type) +ShaderOutput *ShaderNode::add_output(const char *name, SocketType::Type type) { ShaderOutput *output = new ShaderOutput(this, name, type); outputs.push_back(output); @@ -185,13 +195,13 @@ void ShaderNode::attributes(Shader *shader, AttributeRequestSet *attributes) { foreach(ShaderInput *input, inputs) { if(!input->link) { - if(input->default_value == ShaderInput::TEXTURE_GENERATED) { + if(input->flags() & SocketType::LINK_TEXTURE_GENERATED) { if(shader->has_surface) attributes->add(ATTR_STD_GENERATED); if(shader->has_volume) attributes->add(ATTR_STD_GENERATED_TRANSFORM); } - else if(input->default_value == ShaderInput::TEXTURE_UV) { + else if(input->flags() & SocketType::LINK_TEXTURE_UV) { if(shader->has_surface) attributes->add(ATTR_STD_UV); } @@ -256,18 +266,18 @@ void ShaderGraph::connect(ShaderOutput *from, ShaderInput *to) return; } - if(from->type != to->type) { + if(from->type() != to->type()) { /* for closures we can't do automatic conversion */ - if(from->type == SHADER_SOCKET_CLOSURE || to->type == SHADER_SOCKET_CLOSURE) { + if(from->type() == SocketType::CLOSURE || to->type() == SocketType::CLOSURE) { fprintf(stderr, "Cycles shader graph connect: can only connect closure to closure " "(%s.%s to %s.%s).\n", - from->parent->name.c_str(), from->name, - to->parent->name.c_str(), to->name); + from->parent->name.c_str(), from->name().c_str(), + to->parent->name.c_str(), to->name().c_str()); return; } /* add automatic conversion node in case of type mismatch */ - ShaderNode *convert = add(new ConvertNode(from->type, to->type, true)); + ShaderNode *convert = add(new ConvertNode(from->type(), to->type(), true)); connect(from, convert->inputs[0]); connect(convert->outputs[0], to); @@ -401,8 +411,8 @@ void ShaderGraph::copy_nodes(ShaderNodeSet& nodes, ShaderNodeMap& nnodemap) /* find new input and output */ ShaderNode *nfrom = nnodemap[input->link->parent]; ShaderNode *nto = nnodemap[input->parent]; - ShaderOutput *noutput = nfrom->output(input->link->name); - ShaderInput *ninput = nto->input(input->name); + ShaderOutput *noutput = nfrom->output(input->link->name()); + ShaderInput *ninput = nto->input(input->name()); /* connect */ connect(noutput, ninput); @@ -447,10 +457,10 @@ void ShaderGraph::remove_proxy_nodes() vector<ShaderInput*> links = tonode->outputs[0]->links; foreach(ShaderInput *autoin, links) { - if(autoin->default_value == ShaderInput::NONE) - all_links_removed = false; - else + if(autoin->flags() & SocketType::DEFAULT_LINK_MASK) disconnect(autoin); + else + all_links_removed = false; } if(all_links_removed) @@ -460,8 +470,8 @@ void ShaderGraph::remove_proxy_nodes() disconnect(to); /* transfer the default input value to the target socket */ - to->set(input->value); - to->set(input->value_string); + to->value() = input->value(); + to->value_string() = input->value_string(); } } @@ -533,7 +543,7 @@ void ShaderGraph::constant_fold() vector<ShaderInput*> links(output->links); foreach(ShaderInput *input, links) { /* Assign value and disconnect the optimizedinput. */ - input->value = optimized_value; + input->value() = optimized_value; disconnect(input); } } @@ -706,38 +716,38 @@ void ShaderGraph::default_inputs(bool do_osl) foreach(ShaderNode *node, nodes) { foreach(ShaderInput *input, node->inputs) { - if(!input->link && ((input->usage & ShaderInput::USE_SVM) || do_osl)) { - if(input->default_value == ShaderInput::TEXTURE_GENERATED) { + if(!input->link && (!(input->flags() & SocketType::OSL_INTERNAL) || do_osl)) { + if(input->flags() & SocketType::LINK_TEXTURE_GENERATED) { if(!texco) texco = new TextureCoordinateNode(); connect(texco->output("Generated"), input); } - else if(input->default_value == ShaderInput::TEXTURE_UV) { + else if(input->flags() & SocketType::LINK_TEXTURE_UV) { if(!texco) texco = new TextureCoordinateNode(); connect(texco->output("UV"), input); } - else if(input->default_value == ShaderInput::INCOMING) { + else if(input->flags() & SocketType::LINK_INCOMING) { if(!geom) geom = new GeometryNode(); connect(geom->output("Incoming"), input); } - else if(input->default_value == ShaderInput::NORMAL) { + else if(input->flags() & SocketType::LINK_NORMAL) { if(!geom) geom = new GeometryNode(); connect(geom->output("Normal"), input); } - else if(input->default_value == ShaderInput::POSITION) { + else if(input->flags() & SocketType::LINK_POSITION) { if(!geom) geom = new GeometryNode(); connect(geom->output("Position"), input); } - else if(input->default_value == ShaderInput::TANGENT) { + else if(input->flags() & SocketType::LINK_TANGENT) { if(!geom) geom = new GeometryNode(); @@ -785,8 +795,8 @@ void ShaderGraph::refine_bump_nodes() pair.second->bump = SHADER_BUMP_DY; ShaderOutput *out = bump_input->link; - ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name); - ShaderOutput *out_dy = nodes_dy[out->parent]->output(out->name); + ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name()); + ShaderOutput *out_dy = nodes_dy[out->parent]->output(out->name()); connect(out_dx, node->input("SampleX")); connect(out_dy, node->input("SampleY")); @@ -860,9 +870,9 @@ void ShaderGraph::bump_from_displacement() ShaderNode *bump = add(new BumpNode()); ShaderOutput *out = displacement_in->link; - ShaderOutput *out_center = nodes_center[out->parent]->output(out->name); - ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name); - ShaderOutput *out_dy = nodes_dy[out->parent]->output(out->name); + ShaderOutput *out_center = nodes_center[out->parent]->output(out->name()); + ShaderOutput *out_dx = nodes_dx[out->parent]->output(out->name()); + ShaderOutput *out_dy = nodes_dy[out->parent]->output(out->name()); connect(out_center, bump->input("SampleCenter")); connect(out_dx, bump->input("SampleX")); @@ -882,7 +892,7 @@ void ShaderGraph::bump_from_displacement() continue; } foreach(ShaderInput *input, node->inputs) { - if(!input->link && input->default_value == ShaderInput::NORMAL) + if(!input->link && (input->flags() & SocketType::LINK_NORMAL)) connect(set_normal->output("Normal"), input); } } @@ -925,7 +935,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight if(fin->link) connect(fin->link, fac_in); else - fac_in->value = fin->value; + fac_in->value_float() = fin->value_float(); if(weight_out) connect(weight_out, weight_in); @@ -952,7 +962,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight return; /* already has a weight connected to it? add weights */ - if(weight_in->link || weight_in->value.x != 0.0f) { + if(weight_in->link || weight_in->value_float() != 0.0f) { ShaderNode *math_node = add(new MathNode()); ShaderInput *value1_in = math_node->input("Value1"); ShaderInput *value2_in = math_node->input("Value2"); @@ -960,12 +970,12 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight if(weight_in->link) connect(weight_in->link, value1_in); else - value1_in->value = weight_in->value; + value1_in->value() = weight_in->value(); if(weight_out) connect(weight_out, value2_in); else - value2_in->value.x = 1.0f; + value2_in->value_float() = 1.0f; weight_out = math_node->output("Value"); if(weight_in->link) @@ -976,7 +986,7 @@ void ShaderGraph::transform_multi_closure(ShaderNode *node, ShaderOutput *weight if(weight_out) connect(weight_out, weight_in); else - weight_in->value.x += 1.0f; + weight_in->value_float() += 1.0f; } } @@ -1024,7 +1034,7 @@ void ShaderGraph::dump_graph(const char *filename) if(socket != node->inputs[0]) { fprintf(fd, "|"); } - fprintf(fd, "<IN_%p>%s", socket, socket->name); + fprintf(fd, "<IN_%p>%s", socket, socket->name().c_str()); } fprintf(fd, "}|"); } @@ -1044,7 +1054,7 @@ void ShaderGraph::dump_graph(const char *filename) if(socket != node->outputs[0]) { fprintf(fd, "|"); } - fprintf(fd, "<OUT_%p>%s", socket, socket->name); + fprintf(fd, "<OUT_%p>%s", socket, socket->name().c_str()); } fprintf(fd, "}"); } @@ -1058,7 +1068,7 @@ void ShaderGraph::dump_graph(const char *filename) "// CONNECTION: OUT_%p->IN_%p (%s:%s)\n", output, input, - output->name, input->name); + output->name().c_str(), input->name().c_str()); fprintf(fd, "\"%p\":\"OUT_%p\":e -> \"%p\":\"IN_%p\":w [label=\"\"]\n", output->parent, diff --git a/intern/cycles/render/graph.h b/intern/cycles/render/graph.h index bd3f5ca689a..760b19f447a 100644 --- a/intern/cycles/render/graph.h +++ b/intern/cycles/render/graph.h @@ -17,6 +17,8 @@ #ifndef __GRAPH_H__ #define __GRAPH_H__ +#include "node.h" + #include "kernel_types.h" #include "util_list.h" @@ -39,23 +41,6 @@ class SVMCompiler; class OSLCompiler; class OutputNode; -/* Socket Type - * - * Data type for inputs and outputs */ - -enum ShaderSocketType { - SHADER_SOCKET_UNDEFINED, - - SHADER_SOCKET_FLOAT, - SHADER_SOCKET_INT, - SHADER_SOCKET_COLOR, - SHADER_SOCKET_VECTOR, - SHADER_SOCKET_POINT, - SHADER_SOCKET_NORMAL, - SHADER_SOCKET_CLOSURE, - SHADER_SOCKET_STRING -}; - /* Bump * * For bump mapping, a node may be evaluated multiple times, using different @@ -86,30 +71,6 @@ enum ShaderNodeSpecialType { SHADER_SPECIAL_TYPE_BUMP, }; -/* Enum - * - * Utility class for enum values. */ - -class ShaderEnum { -public: - bool empty() const { return left.empty(); } - void insert(const char *x, int y) { - left[ustring(x)] = y; - right[y] = ustring(x); - } - - bool exists(ustring x) { return left.find(x) != left.end(); } - bool exists(int y) { return right.find(y) != right.end(); } - - int operator[](const char *x) { return left[ustring(x)]; } - int operator[](ustring x) { return left[x]; } - ustring operator[](int y) { return right[y]; } - -protected: - map<ustring, int> left; - map<int, ustring> right; -}; - /* Input * * Input socket for a shader node. May be linked to an output or not. If not @@ -118,39 +79,27 @@ protected: class ShaderInput { public: - enum DefaultValue { - TEXTURE_GENERATED, - TEXTURE_UV, - INCOMING, - NORMAL, - POSITION, - TANGENT, - NONE - }; - - enum Usage { - USE_SVM = 1, - USE_OSL = 2, - USE_ALL = USE_SVM|USE_OSL - }; - - ShaderInput(ShaderNode *parent, const char *name, ShaderSocketType type); - void set(const float3& v) { value = v; } - void set(float f) { value = make_float3(f, 0, 0); } - void set(const ustring v) { value_string = v; } - - const char *name; - ShaderSocketType type; + ShaderInput(ShaderNode *parent, const char *name, SocketType::Type type); + + ustring name() { return name_; } + int flags() { return flags_; } + SocketType::Type type() { return type_; } + + float3& value() { return value_; } + float& value_float() { return value_.x; } + ustring& value_string() { return value_string_; } + + ustring name_; + SocketType::Type type_; ShaderNode *parent; ShaderOutput *link; - DefaultValue default_value; - float3 value; - ustring value_string; + float3 value_; + ustring value_string_; int stack_offset; /* for SVM compiler */ - int usage; + int flags_; }; /* Output @@ -159,12 +108,15 @@ public: class ShaderOutput { public: - ShaderOutput(ShaderNode *parent, const char *name, ShaderSocketType type); + ShaderOutput(ShaderNode *parent, const char *name, SocketType::Type type); - const char *name; - ShaderNode *parent; - ShaderSocketType type; + ustring name() { return name_; } + SocketType::Type type() { return type_; } + ustring name_; + SocketType::Type type_; + + ShaderNode *parent; vector<ShaderInput*> links; int stack_offset; /* for SVM compiler */ @@ -182,11 +134,12 @@ public: ShaderInput *input(const char *name); ShaderOutput *output(const char *name); + ShaderInput *input(ustring name); + ShaderOutput *output(ustring name); - ShaderInput *add_input(const char *name, ShaderSocketType type, float value=0.0f, int usage=ShaderInput::USE_ALL); - ShaderInput *add_input(const char *name, ShaderSocketType type, float3 value, int usage=ShaderInput::USE_ALL); - ShaderInput *add_input(const char *name, ShaderSocketType type, ShaderInput::DefaultValue value, int usage=ShaderInput::USE_ALL); - ShaderOutput *add_output(const char *name, ShaderSocketType type); + ShaderInput *add_input(const char *name, SocketType::Type type, float value=0.0f, int flags=0); + ShaderInput *add_input(const char *name, SocketType::Type type, float3 value, int flags=0); + ShaderOutput *add_output(const char *name, SocketType::Type type); virtual ShaderNode *clone() const = 0; virtual void attributes(Shader *shader, AttributeRequestSet *attributes); diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 998d9cf31dd..7f1fcd81c73 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -30,9 +30,9 @@ CCL_NAMESPACE_BEGIN /* Texture Mapping */ -static ShaderEnum texture_mapping_type_init() +static NodeEnum texture_mapping_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Point", TextureMapping::POINT); enm.insert("Texture", TextureMapping::TEXTURE); @@ -42,9 +42,9 @@ static ShaderEnum texture_mapping_type_init() return enm; } -static ShaderEnum texture_mapping_mapping_init() +static NodeEnum texture_mapping_mapping_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("None", TextureMapping::NONE); enm.insert("X", TextureMapping::X); @@ -54,9 +54,9 @@ static ShaderEnum texture_mapping_mapping_init() return enm; } -static ShaderEnum texture_mapping_projection_init() +static NodeEnum texture_mapping_projection_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Flat", TextureMapping::FLAT); enm.insert("Cube", TextureMapping::CUBE); @@ -66,9 +66,9 @@ static ShaderEnum texture_mapping_projection_init() return enm; } -ShaderEnum TextureMapping::type_enum = texture_mapping_type_init(); -ShaderEnum TextureMapping::mapping_enum = texture_mapping_mapping_init(); -ShaderEnum TextureMapping::projection_enum = texture_mapping_projection_init(); +NodeEnum TextureMapping::type_enum = texture_mapping_type_init(); +NodeEnum TextureMapping::mapping_enum = texture_mapping_mapping_init(); +NodeEnum TextureMapping::projection_enum = texture_mapping_projection_init(); TextureMapping::TextureMapping() { @@ -193,7 +193,7 @@ int TextureMapping::compile_begin(SVMCompiler& compiler, ShaderInput *vector_in) { if(!skip()) { int offset_in = compiler.stack_assign(vector_in); - int offset_out = compiler.stack_find_offset(SHADER_SOCKET_VECTOR); + int offset_out = compiler.stack_find_offset(SocketType::VECTOR); compile(compiler, offset_in, offset_out); @@ -206,7 +206,7 @@ int TextureMapping::compile_begin(SVMCompiler& compiler, ShaderInput *vector_in) void TextureMapping::compile_end(SVMCompiler& compiler, ShaderInput *vector_in, int vector_offset) { if(!skip()) { - compiler.stack_clear_offset(vector_in->type, vector_offset); + compiler.stack_clear_offset(vector_in->type(), vector_offset); } } @@ -222,9 +222,9 @@ void TextureMapping::compile(OSLCompiler &compiler) /* Image Texture */ -static ShaderEnum color_space_init() +static NodeEnum color_space_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("None", 0); enm.insert("Color", 1); @@ -232,9 +232,9 @@ static ShaderEnum color_space_init() return enm; } -static ShaderEnum image_projection_init() +static NodeEnum image_projection_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Flat", NODE_IMAGE_PROJ_FLAT); enm.insert("Box", NODE_IMAGE_PROJ_BOX); @@ -259,8 +259,8 @@ static const char* get_osl_interpolation_parameter(InterpolationType interpolati } } -ShaderEnum ImageTextureNode::color_space_enum = color_space_init(); -ShaderEnum ImageTextureNode::projection_enum = image_projection_init(); +NodeEnum ImageTextureNode::color_space_enum = color_space_init(); +NodeEnum ImageTextureNode::projection_enum = image_projection_init(); ImageTextureNode::ImageTextureNode() : ImageSlotTextureNode("image_texture") @@ -279,9 +279,9 @@ ImageTextureNode::ImageTextureNode() projection_blend = 0.0f; animated = false; - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_UV); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Alpha", SHADER_SOCKET_FLOAT); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_UV); + add_output("Color", SocketType::COLOR); + add_output("Alpha", SocketType::FLOAT); } ImageTextureNode::~ImageTextureNode() @@ -449,9 +449,9 @@ void ImageTextureNode::compile(OSLCompiler& compiler) /* Environment Texture */ -static ShaderEnum env_projection_init() +static NodeEnum env_projection_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Equirectangular", 0); enm.insert("Mirror Ball", 1); @@ -459,8 +459,8 @@ static ShaderEnum env_projection_init() return enm; } -ShaderEnum EnvironmentTextureNode::color_space_enum = color_space_init(); -ShaderEnum EnvironmentTextureNode::projection_enum = env_projection_init(); +NodeEnum EnvironmentTextureNode::color_space_enum = color_space_init(); +NodeEnum EnvironmentTextureNode::projection_enum = env_projection_init(); EnvironmentTextureNode::EnvironmentTextureNode() : ImageSlotTextureNode("environment_texture") @@ -477,9 +477,9 @@ EnvironmentTextureNode::EnvironmentTextureNode() projection = ustring("Equirectangular"); animated = false; - add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Alpha", SHADER_SOCKET_FLOAT); + add_input("Vector", SocketType::VECTOR, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_POSITION); + add_output("Color", SocketType::COLOR); + add_output("Alpha", SocketType::FLOAT); } EnvironmentTextureNode::~EnvironmentTextureNode() @@ -738,9 +738,9 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi arhosekskymodelstate_free(sky_state); } -static ShaderEnum sky_type_init() +static NodeEnum sky_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Preetham", NODE_SKY_OLD); enm.insert("Hosek / Wilkie", NODE_SKY_NEW); @@ -748,7 +748,7 @@ static ShaderEnum sky_type_init() return enm; } -ShaderEnum SkyTextureNode::type_enum = sky_type_init(); +NodeEnum SkyTextureNode::type_enum = sky_type_init(); SkyTextureNode::SkyTextureNode() : TextureNode("sky_texture") @@ -759,8 +759,8 @@ SkyTextureNode::SkyTextureNode() turbidity = 2.2f; ground_albedo = 0.3f; - add_input("Vector", SHADER_SOCKET_VECTOR, ShaderInput::POSITION); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Vector", SocketType::VECTOR, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_POSITION); + add_output("Color", SocketType::COLOR); } void SkyTextureNode::compile(SVMCompiler& compiler) @@ -818,9 +818,9 @@ void SkyTextureNode::compile(OSLCompiler& compiler) /* Gradient Texture */ -static ShaderEnum gradient_type_init() +static NodeEnum gradient_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Linear", NODE_BLEND_LINEAR); enm.insert("Quadratic", NODE_BLEND_QUADRATIC); @@ -833,16 +833,16 @@ static ShaderEnum gradient_type_init() return enm; } -ShaderEnum GradientTextureNode::type_enum = gradient_type_init(); +NodeEnum GradientTextureNode::type_enum = gradient_type_init(); GradientTextureNode::GradientTextureNode() : TextureNode("gradient_texture") { type = ustring("Linear"); - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void GradientTextureNode::compile(SVMCompiler& compiler) @@ -876,13 +876,13 @@ void GradientTextureNode::compile(OSLCompiler& compiler) NoiseTextureNode::NoiseTextureNode() : TextureNode("noise_texture") { - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f); - add_input("Distortion", SHADER_SOCKET_FLOAT, 0.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_input("Scale", SocketType::FLOAT, 1.0f); + add_input("Detail", SocketType::FLOAT, 2.0f); + add_input("Distortion", SocketType::FLOAT, 0.0f); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void NoiseTextureNode::compile(SVMCompiler& compiler) @@ -906,9 +906,9 @@ void NoiseTextureNode::compile(SVMCompiler& compiler) compiler.stack_assign_if_linked(color_out), compiler.stack_assign_if_linked(fac_out))); compiler.add_node( - __float_as_int(scale_in->value.x), - __float_as_int(detail_in->value.x), - __float_as_int(distortion_in->value.x)); + __float_as_int(scale_in->value_float()), + __float_as_int(detail_in->value_float()), + __float_as_int(distortion_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -922,9 +922,9 @@ void NoiseTextureNode::compile(OSLCompiler& compiler) /* Voronoi Texture */ -static ShaderEnum voronoi_coloring_init() +static NodeEnum voronoi_coloring_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Intensity", NODE_VORONOI_INTENSITY); enm.insert("Cells", NODE_VORONOI_CELLS); @@ -932,18 +932,18 @@ static ShaderEnum voronoi_coloring_init() return enm; } -ShaderEnum VoronoiTextureNode::coloring_enum = voronoi_coloring_init(); +NodeEnum VoronoiTextureNode::coloring_enum = voronoi_coloring_init(); VoronoiTextureNode::VoronoiTextureNode() : TextureNode("voronoi_texture") { coloring = ustring("Intensity"); - add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); + add_input("Scale", SocketType::FLOAT, 1.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void VoronoiTextureNode::compile(SVMCompiler& compiler) @@ -962,7 +962,7 @@ void VoronoiTextureNode::compile(SVMCompiler& compiler) vector_offset, compiler.stack_assign(fac_out), compiler.stack_assign(color_out)), - __float_as_int(scale_in->value.x)); + __float_as_int(scale_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -977,9 +977,9 @@ void VoronoiTextureNode::compile(OSLCompiler& compiler) /* Musgrave Texture */ -static ShaderEnum musgrave_type_init() +static NodeEnum musgrave_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Multifractal", NODE_MUSGRAVE_MULTIFRACTAL); enm.insert("fBM", NODE_MUSGRAVE_FBM); @@ -990,23 +990,23 @@ static ShaderEnum musgrave_type_init() return enm; } -ShaderEnum MusgraveTextureNode::type_enum = musgrave_type_init(); +NodeEnum MusgraveTextureNode::type_enum = musgrave_type_init(); MusgraveTextureNode::MusgraveTextureNode() : TextureNode("musgrave_texture") { type = ustring("fBM"); - add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f); - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_input("Dimension", SHADER_SOCKET_FLOAT, 2.0f); - add_input("Lacunarity", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Offset", SHADER_SOCKET_FLOAT, 0.0f); - add_input("Gain", SHADER_SOCKET_FLOAT, 1.0f); + add_input("Scale", SocketType::FLOAT, 1.0f); + add_input("Detail", SocketType::FLOAT, 2.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_input("Dimension", SocketType::FLOAT, 2.0f); + add_input("Lacunarity", SocketType::FLOAT, 1.0f); + add_input("Offset", SocketType::FLOAT, 0.0f); + add_input("Gain", SocketType::FLOAT, 1.0f); - add_output("Fac", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); + add_output("Fac", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); } void MusgraveTextureNode::compile(SVMCompiler& compiler) @@ -1037,12 +1037,12 @@ void MusgraveTextureNode::compile(SVMCompiler& compiler) compiler.encode_uchar4( compiler.stack_assign_if_linked(gain_in), compiler.stack_assign_if_linked(scale_in))); - compiler.add_node(__float_as_int(dimension_in->value.x), - __float_as_int(lacunarity_in->value.x), - __float_as_int(detail_in->value.x), - __float_as_int(offset_in->value.x)); - compiler.add_node(__float_as_int(gain_in->value.x), - __float_as_int(scale_in->value.x)); + compiler.add_node(__float_as_int(dimension_in->value_float()), + __float_as_int(lacunarity_in->value_float()), + __float_as_int(detail_in->value_float()), + __float_as_int(offset_in->value_float())); + compiler.add_node(__float_as_int(gain_in->value_float()), + __float_as_int(scale_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -1058,9 +1058,9 @@ void MusgraveTextureNode::compile(OSLCompiler& compiler) /* Wave Texture */ -static ShaderEnum wave_type_init() +static NodeEnum wave_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Bands", NODE_WAVE_BANDS); enm.insert("Rings", NODE_WAVE_RINGS); @@ -1068,9 +1068,9 @@ static ShaderEnum wave_type_init() return enm; } -static ShaderEnum wave_profile_init() +static NodeEnum wave_profile_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Sine", NODE_WAVE_PROFILE_SIN); enm.insert("Saw", NODE_WAVE_PROFILE_SAW); @@ -1078,8 +1078,8 @@ static ShaderEnum wave_profile_init() return enm; } -ShaderEnum WaveTextureNode::type_enum = wave_type_init(); -ShaderEnum WaveTextureNode::profile_enum = wave_profile_init(); +NodeEnum WaveTextureNode::type_enum = wave_type_init(); +NodeEnum WaveTextureNode::profile_enum = wave_profile_init(); WaveTextureNode::WaveTextureNode() : TextureNode("wave_texture") @@ -1087,14 +1087,14 @@ WaveTextureNode::WaveTextureNode() type = ustring("Bands"); profile = ustring("Sine"); - add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Distortion", SHADER_SOCKET_FLOAT, 0.0f); - add_input("Detail", SHADER_SOCKET_FLOAT, 2.0f); - add_input("Detail Scale", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); + add_input("Scale", SocketType::FLOAT, 1.0f); + add_input("Distortion", SocketType::FLOAT, 0.0f); + add_input("Detail", SocketType::FLOAT, 2.0f); + add_input("Detail Scale", SocketType::FLOAT, 1.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void WaveTextureNode::compile(SVMCompiler& compiler) @@ -1123,10 +1123,10 @@ void WaveTextureNode::compile(SVMCompiler& compiler) profile_enum[profile]); compiler.add_node( - __float_as_int(scale_in->value.x), - __float_as_int(detail_in->value.x), - __float_as_int(distortion_in->value.x), - __float_as_int(dscale_in->value.x)); + __float_as_int(scale_in->value_float()), + __float_as_int(detail_in->value_float()), + __float_as_int(distortion_in->value_float()), + __float_as_int(dscale_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -1148,12 +1148,12 @@ MagicTextureNode::MagicTextureNode() { depth = 2; - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_input("Scale", SHADER_SOCKET_FLOAT, 5.0f); - add_input("Distortion", SHADER_SOCKET_FLOAT, 1.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_input("Scale", SocketType::FLOAT, 5.0f); + add_input("Distortion", SocketType::FLOAT, 1.0f); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void MagicTextureNode::compile(SVMCompiler& compiler) @@ -1176,8 +1176,8 @@ void MagicTextureNode::compile(SVMCompiler& compiler) compiler.stack_assign_if_linked(scale_in), compiler.stack_assign_if_linked(distortion_in))); compiler.add_node( - __float_as_int(scale_in->value.x), - __float_as_int(distortion_in->value.x)); + __float_as_int(scale_in->value_float()), + __float_as_int(distortion_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -1195,13 +1195,13 @@ void MagicTextureNode::compile(OSLCompiler& compiler) CheckerTextureNode::CheckerTextureNode() : TextureNode("checker_texture") { - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_input("Color1", SHADER_SOCKET_COLOR); - add_input("Color2", SHADER_SOCKET_COLOR); - add_input("Scale", SHADER_SOCKET_FLOAT, 1.0f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_input("Color1", SocketType::COLOR); + add_input("Color2", SocketType::COLOR); + add_input("Scale", SocketType::FLOAT, 1.0f); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void CheckerTextureNode::compile(SVMCompiler& compiler) @@ -1225,7 +1225,7 @@ void CheckerTextureNode::compile(SVMCompiler& compiler) compiler.encode_uchar4( compiler.stack_assign_if_linked(color_out), compiler.stack_assign_if_linked(fac_out)), - __float_as_int(scale_in->value.x)); + __float_as_int(scale_in->value_float())); tex_mapping.compile_end(compiler, vector_in, vector_offset); } @@ -1247,18 +1247,18 @@ BrickTextureNode::BrickTextureNode() squash = 1.0f; squash_frequency = 2; - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::TEXTURE_GENERATED); - add_input("Color1", SHADER_SOCKET_COLOR); - add_input("Color2", SHADER_SOCKET_COLOR); - add_input("Mortar", SHADER_SOCKET_COLOR); - add_input("Scale", SHADER_SOCKET_FLOAT, 5.0f); - add_input("Mortar Size", SHADER_SOCKET_FLOAT, 0.02f); - add_input("Bias", SHADER_SOCKET_FLOAT, 0.0f); - add_input("Brick Width", SHADER_SOCKET_FLOAT, 0.5f); - add_input("Row Height", SHADER_SOCKET_FLOAT, 0.25f); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); + add_input("Color1", SocketType::COLOR); + add_input("Color2", SocketType::COLOR); + add_input("Mortar", SocketType::COLOR); + add_input("Scale", SocketType::FLOAT, 5.0f); + add_input("Mortar Size", SocketType::FLOAT, 0.02f); + add_input("Bias", SocketType::FLOAT, 0.0f); + add_input("Brick Width", SocketType::FLOAT, 0.5f); + add_input("Row Height", SocketType::FLOAT, 0.25f); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Fac", SocketType::FLOAT); } void BrickTextureNode::compile(SVMCompiler& compiler) @@ -1295,12 +1295,12 @@ void BrickTextureNode::compile(SVMCompiler& compiler) compiler.stack_assign_if_linked(fac_out))); compiler.add_node(compiler.encode_uchar4(offset_frequency, squash_frequency), - __float_as_int(scale_in->value.x), - __float_as_int(mortar_size_in->value.x), - __float_as_int(bias_in->value.x)); + __float_as_int(scale_in->value_float()), + __float_as_int(mortar_size_in->value_float()), + __float_as_int(bias_in->value_float())); - compiler.add_node(__float_as_int(brick_width_in->value.x), - __float_as_int(row_height_in->value.x), + compiler.add_node(__float_as_int(brick_width_in->value_float()), + __float_as_int(row_height_in->value_float()), __float_as_int(offset), __float_as_int(squash)); @@ -1320,9 +1320,9 @@ void BrickTextureNode::compile(OSLCompiler& compiler) /* Point Density Texture */ -static ShaderEnum point_density_space_init() +static NodeEnum point_density_space_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Object", NODE_TEX_VOXEL_SPACE_OBJECT); enm.insert("World", NODE_TEX_VOXEL_SPACE_WORLD); @@ -1330,7 +1330,7 @@ static ShaderEnum point_density_space_init() return enm; } -ShaderEnum PointDensityTextureNode::space_enum = point_density_space_init(); +NodeEnum PointDensityTextureNode::space_enum = point_density_space_init(); PointDensityTextureNode::PointDensityTextureNode() : ShaderNode("point_density") @@ -1344,9 +1344,9 @@ PointDensityTextureNode::PointDensityTextureNode() tfm = transform_identity(); - add_input("Vector", SHADER_SOCKET_POINT, ShaderInput::POSITION); - add_output("Density", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Vector", SocketType::POINT, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_POSITION); + add_output("Density", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); } PointDensityTextureNode::~PointDensityTextureNode() @@ -1481,9 +1481,9 @@ NormalNode::NormalNode() { direction = make_float3(0.0f, 0.0f, 1.0f); - add_input("Normal", SHADER_SOCKET_NORMAL); - add_output("Normal", SHADER_SOCKET_NORMAL); - add_output("Dot", SHADER_SOCKET_FLOAT); + add_input("Normal", SocketType::NORMAL); + add_output("Normal", SocketType::NORMAL); + add_output("Dot", SocketType::FLOAT); } void NormalNode::compile(SVMCompiler& compiler) @@ -1513,8 +1513,8 @@ void NormalNode::compile(OSLCompiler& compiler) MappingNode::MappingNode() : ShaderNode("mapping") { - add_input("Vector", SHADER_SOCKET_POINT); - add_output("Vector", SHADER_SOCKET_POINT); + add_input("Vector", SocketType::POINT); + add_output("Vector", SocketType::POINT); } void MappingNode::compile(SVMCompiler& compiler) @@ -1538,7 +1538,7 @@ void MappingNode::compile(OSLCompiler& compiler) /* Convert */ -ConvertNode::ConvertNode(ShaderSocketType from_, ShaderSocketType to_, bool autoconvert) +ConvertNode::ConvertNode(SocketType::Type from_, SocketType::Type to_, bool autoconvert) : ShaderNode("convert") { from = from_; @@ -1551,41 +1551,41 @@ ConvertNode::ConvertNode(ShaderSocketType from_, ShaderSocketType to_, bool auto special_type = SHADER_SPECIAL_TYPE_AUTOCONVERT; } - if(from == SHADER_SOCKET_FLOAT) - add_input("Val", SHADER_SOCKET_FLOAT); - else if(from == SHADER_SOCKET_INT) - add_input("ValInt", SHADER_SOCKET_INT); - else if(from == SHADER_SOCKET_COLOR) - add_input("Color", SHADER_SOCKET_COLOR); - else if(from == SHADER_SOCKET_VECTOR) - add_input("Vector", SHADER_SOCKET_VECTOR); - else if(from == SHADER_SOCKET_POINT) - add_input("Point", SHADER_SOCKET_POINT); - else if(from == SHADER_SOCKET_NORMAL) - add_input("Normal", SHADER_SOCKET_NORMAL); - else if(from == SHADER_SOCKET_STRING) - add_input("String", SHADER_SOCKET_STRING); - else if(from == SHADER_SOCKET_CLOSURE) - add_input("Closure", SHADER_SOCKET_CLOSURE); + if(from == SocketType::FLOAT) + add_input("Val", SocketType::FLOAT); + else if(from == SocketType::INT) + add_input("ValInt", SocketType::INT); + else if(from == SocketType::COLOR) + add_input("Color", SocketType::COLOR); + else if(from == SocketType::VECTOR) + add_input("Vector", SocketType::VECTOR); + else if(from == SocketType::POINT) + add_input("Point", SocketType::POINT); + else if(from == SocketType::NORMAL) + add_input("Normal", SocketType::NORMAL); + else if(from == SocketType::STRING) + add_input("String", SocketType::STRING); + else if(from == SocketType::CLOSURE) + add_input("Closure", SocketType::CLOSURE); else assert(0); - if(to == SHADER_SOCKET_FLOAT) - add_output("Val", SHADER_SOCKET_FLOAT); - else if(to == SHADER_SOCKET_INT) - add_output("ValInt", SHADER_SOCKET_INT); - else if(to == SHADER_SOCKET_COLOR) - add_output("Color", SHADER_SOCKET_COLOR); - else if(to == SHADER_SOCKET_VECTOR) - add_output("Vector", SHADER_SOCKET_VECTOR); - else if(to == SHADER_SOCKET_POINT) - add_output("Point", SHADER_SOCKET_POINT); - else if(to == SHADER_SOCKET_NORMAL) - add_output("Normal", SHADER_SOCKET_NORMAL); - else if(to == SHADER_SOCKET_STRING) - add_output("String", SHADER_SOCKET_STRING); - else if(to == SHADER_SOCKET_CLOSURE) - add_output("Closure", SHADER_SOCKET_CLOSURE); + if(to == SocketType::FLOAT) + add_output("Val", SocketType::FLOAT); + else if(to == SocketType::INT) + add_output("ValInt", SocketType::INT); + else if(to == SocketType::COLOR) + add_output("Color", SocketType::COLOR); + else if(to == SocketType::VECTOR) + add_output("Vector", SocketType::VECTOR); + else if(to == SocketType::POINT) + add_output("Point", SocketType::POINT); + else if(to == SocketType::NORMAL) + add_output("Normal", SocketType::NORMAL); + else if(to == SocketType::STRING) + add_output("String", SocketType::STRING); + else if(to == SocketType::CLOSURE) + add_output("Closure", SocketType::CLOSURE); else assert(0); } @@ -1595,37 +1595,37 @@ bool ConvertNode::constant_fold(ShaderGraph * /*graph*/, float3 *optimized_value) { ShaderInput *in = inputs[0]; - float3 value = in->value; + float3 value = in->value(); /* TODO(DingTo): conversion from/to int is not supported yet, don't fold in that case */ if(in->link == NULL) { - if(from == SHADER_SOCKET_FLOAT) { - if(to == SHADER_SOCKET_INT) + if(from == SocketType::FLOAT) { + if(to == SocketType::INT) /* float to int */ return false; else /* float to float3 */ *optimized_value = make_float3(value.x, value.x, value.x); } - else if(from == SHADER_SOCKET_INT) { - if(to == SHADER_SOCKET_FLOAT) + else if(from == SocketType::INT) { + if(to == SocketType::FLOAT) /* int to float */ return false; else /* int to vector/point/normal */ return false; } - else if(to == SHADER_SOCKET_FLOAT) { - if(from == SHADER_SOCKET_COLOR) + else if(to == SocketType::FLOAT) { + if(from == SocketType::COLOR) /* color to float */ optimized_value->x = linear_rgb_to_gray(value); else /* vector/point/normal to float */ optimized_value->x = average(value); } - else if(to == SHADER_SOCKET_INT) { - if(from == SHADER_SOCKET_COLOR) + else if(to == SocketType::INT) { + if(from == SocketType::COLOR) /* color to int */ return false; else @@ -1650,32 +1650,32 @@ void ConvertNode::compile(SVMCompiler& compiler) ShaderInput *in = inputs[0]; ShaderOutput *out = outputs[0]; - if(from == SHADER_SOCKET_FLOAT) { - if(to == SHADER_SOCKET_INT) + if(from == SocketType::FLOAT) { + if(to == SocketType::INT) /* float to int */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_FI, compiler.stack_assign(in), compiler.stack_assign(out)); else /* float to float3 */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_FV, compiler.stack_assign(in), compiler.stack_assign(out)); } - else if(from == SHADER_SOCKET_INT) { - if(to == SHADER_SOCKET_FLOAT) + else if(from == SocketType::INT) { + if(to == SocketType::FLOAT) /* int to float */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_IF, compiler.stack_assign(in), compiler.stack_assign(out)); else /* int to vector/point/normal */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_IV, compiler.stack_assign(in), compiler.stack_assign(out)); } - else if(to == SHADER_SOCKET_FLOAT) { - if(from == SHADER_SOCKET_COLOR) + else if(to == SocketType::FLOAT) { + if(from == SocketType::COLOR) /* color to float */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_CF, compiler.stack_assign(in), compiler.stack_assign(out)); else /* vector/point/normal to float */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_VF, compiler.stack_assign(in), compiler.stack_assign(out)); } - else if(to == SHADER_SOCKET_INT) { - if(from == SHADER_SOCKET_COLOR) + else if(to == SocketType::INT) { + if(from == SocketType::COLOR) /* color to int */ compiler.add_node(NODE_CONVERT, NODE_CONVERT_CI, compiler.stack_assign(in), compiler.stack_assign(out)); else @@ -1691,7 +1691,7 @@ void ConvertNode::compile(SVMCompiler& compiler) else { /* set 0,0,0 value */ compiler.add_node(NODE_VALUE_V, compiler.stack_assign(out)); - compiler.add_node(NODE_VALUE_V, in->value); + compiler.add_node(NODE_VALUE_V, in->value()); } } } @@ -1701,17 +1701,17 @@ void ConvertNode::compile(OSLCompiler& compiler) /* constant folding should eliminate proxy nodes */ assert(from != to); - if(from == SHADER_SOCKET_FLOAT) + if(from == SocketType::FLOAT) compiler.add(this, "node_convert_from_float"); - else if(from == SHADER_SOCKET_INT) + else if(from == SocketType::INT) compiler.add(this, "node_convert_from_int"); - else if(from == SHADER_SOCKET_COLOR) + else if(from == SocketType::COLOR) compiler.add(this, "node_convert_from_color"); - else if(from == SHADER_SOCKET_VECTOR) + else if(from == SocketType::VECTOR) compiler.add(this, "node_convert_from_vector"); - else if(from == SHADER_SOCKET_POINT) + else if(from == SocketType::POINT) compiler.add(this, "node_convert_from_point"); - else if(from == SHADER_SOCKET_NORMAL) + else if(from == SocketType::NORMAL) compiler.add(this, "node_convert_from_normal"); else assert(0); @@ -1724,17 +1724,17 @@ BsdfNode::BsdfNode(bool scattering_) { special_type = SHADER_SPECIAL_TYPE_CLOSURE; - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); - add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL); - add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("Color", SocketType::COLOR, make_float3(0.8f, 0.8f, 0.8f)); + add_input("Normal", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL); + add_input("SurfaceMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); if(scattering) { closure = CLOSURE_BSSRDF_CUBIC_ID; - add_output("BSSRDF", SHADER_SOCKET_CLOSURE); + add_output("BSSRDF", SocketType::CLOSURE); } else { closure = CLOSURE_BSDF_DIFFUSE_ID; - add_output("BSDF", SHADER_SOCKET_CLOSURE); + add_output("BSDF", SocketType::CLOSURE); } } @@ -1747,7 +1747,7 @@ void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput * if(color_in->link) compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in)); else - compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value); + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value()); int normal_offset = compiler.stack_assign_if_linked(normal_in); int tangent_offset = (tangent_in) ? compiler.stack_assign_if_linked(tangent_in) : SVM_STACK_INVALID; @@ -1759,8 +1759,8 @@ void BsdfNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput * (param1)? compiler.stack_assign(param1): SVM_STACK_INVALID, (param2)? compiler.stack_assign(param2): SVM_STACK_INVALID, compiler.closure_mix_weight_offset()), - __float_as_int((param1)? param1->value.x: 0.0f), - __float_as_int((param2)? param2->value.x: 0.0f)); + __float_as_int((param1)? param1->value_float(): 0.0f), + __float_as_int((param2)? param2->value_float(): 0.0f)); compiler.add_node(normal_offset, tangent_offset, param3_offset, param4_offset); } @@ -1777,9 +1777,9 @@ void BsdfNode::compile(OSLCompiler& /*compiler*/) /* Anisotropic BSDF Closure */ -static ShaderEnum aniso_distribution_init() +static NodeEnum aniso_distribution_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID); enm.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID); @@ -1788,18 +1788,18 @@ static ShaderEnum aniso_distribution_init() return enm; } -ShaderEnum AnisotropicBsdfNode::distribution_enum = aniso_distribution_init(); +NodeEnum AnisotropicBsdfNode::distribution_enum = aniso_distribution_init(); AnisotropicBsdfNode::AnisotropicBsdfNode() { closure = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID; distribution = ustring("GGX"); - add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT); + add_input("Tangent", SocketType::VECTOR, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TANGENT); - add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f); - add_input("Anisotropy", SHADER_SOCKET_FLOAT, 0.5f); - add_input("Rotation", SHADER_SOCKET_FLOAT, 0.0f); + add_input("Roughness", SocketType::FLOAT, 0.2f); + add_input("Anisotropy", SocketType::FLOAT, 0.5f); + add_input("Rotation", SocketType::FLOAT, 0.0f); } void AnisotropicBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -1829,9 +1829,9 @@ void AnisotropicBsdfNode::compile(OSLCompiler& compiler) /* Glossy BSDF Closure */ -static ShaderEnum glossy_distribution_init() +static NodeEnum glossy_distribution_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Sharp", CLOSURE_BSDF_REFLECTION_ID); enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_ID); @@ -1841,7 +1841,7 @@ static ShaderEnum glossy_distribution_init() return enm; } -ShaderEnum GlossyBsdfNode::distribution_enum = glossy_distribution_init(); +NodeEnum GlossyBsdfNode::distribution_enum = glossy_distribution_init(); GlossyBsdfNode::GlossyBsdfNode() { @@ -1849,7 +1849,7 @@ GlossyBsdfNode::GlossyBsdfNode() distribution = ustring("GGX"); distribution_orig = ustring(""); - add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f); + add_input("Roughness", SocketType::FLOAT, 0.2f); } void GlossyBsdfNode::simplify_settings(Scene *scene) @@ -1863,7 +1863,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ ShaderInput *roughness_input = input("Roughness"); - if(!roughness_input->link && roughness_input->value.x <= 1e-4f) { + if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) { distribution = ustring("Sharp"); } } @@ -1877,7 +1877,7 @@ void GlossyBsdfNode::simplify_settings(Scene *scene) bool GlossyBsdfNode::has_integrator_dependency() { ShaderInput *roughness_input = input("Roughness"); - return !roughness_input->link && roughness_input->value.x <= 1e-4f; + return !roughness_input->link && roughness_input->value_float() <= 1e-4f; } void GlossyBsdfNode::compile(SVMCompiler& compiler) @@ -1898,9 +1898,9 @@ void GlossyBsdfNode::compile(OSLCompiler& compiler) /* Glass BSDF Closure */ -static ShaderEnum glass_distribution_init() +static NodeEnum glass_distribution_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Sharp", CLOSURE_BSDF_SHARP_GLASS_ID); enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_GLASS_ID); @@ -1909,7 +1909,7 @@ static ShaderEnum glass_distribution_init() return enm; } -ShaderEnum GlassBsdfNode::distribution_enum = glass_distribution_init(); +NodeEnum GlassBsdfNode::distribution_enum = glass_distribution_init(); GlassBsdfNode::GlassBsdfNode() { @@ -1917,8 +1917,8 @@ GlassBsdfNode::GlassBsdfNode() distribution = ustring("Sharp"); distribution_orig = ustring(""); - add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f); - add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f); + add_input("Roughness", SocketType::FLOAT, 0.0f); + add_input("IOR", SocketType::FLOAT, 0.3f); } void GlassBsdfNode::simplify_settings(Scene *scene) @@ -1932,7 +1932,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ ShaderInput *roughness_input = input("Roughness"); - if(!roughness_input->link && roughness_input->value.x <= 1e-4f) { + if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) { distribution = ustring("Sharp"); } } @@ -1946,7 +1946,7 @@ void GlassBsdfNode::simplify_settings(Scene *scene) bool GlassBsdfNode::has_integrator_dependency() { ShaderInput *roughness_input = input("Roughness"); - return !roughness_input->link && roughness_input->value.x <= 1e-4f; + return !roughness_input->link && roughness_input->value_float() <= 1e-4f; } void GlassBsdfNode::compile(SVMCompiler& compiler) @@ -1967,9 +1967,9 @@ void GlassBsdfNode::compile(OSLCompiler& compiler) /* Refraction BSDF Closure */ -static ShaderEnum refraction_distribution_init() +static NodeEnum refraction_distribution_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Sharp", CLOSURE_BSDF_REFRACTION_ID); enm.insert("Beckmann", CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID); @@ -1978,7 +1978,7 @@ static ShaderEnum refraction_distribution_init() return enm; } -ShaderEnum RefractionBsdfNode::distribution_enum = refraction_distribution_init(); +NodeEnum RefractionBsdfNode::distribution_enum = refraction_distribution_init(); RefractionBsdfNode::RefractionBsdfNode() { @@ -1986,8 +1986,8 @@ RefractionBsdfNode::RefractionBsdfNode() distribution = ustring("Sharp"); distribution_orig = ustring(""); - add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f); - add_input("IOR", SHADER_SOCKET_FLOAT, 0.3f); + add_input("Roughness", SocketType::FLOAT, 0.0f); + add_input("IOR", SocketType::FLOAT, 0.3f); } void RefractionBsdfNode::simplify_settings(Scene *scene) @@ -2001,7 +2001,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene) * Note: Keep the epsilon in sync with kernel! */ ShaderInput *roughness_input = input("Roughness"); - if(!roughness_input->link && roughness_input->value.x <= 1e-4f) { + if(!roughness_input->link && roughness_input->value_float() <= 1e-4f) { distribution = ustring("Sharp"); } } @@ -2015,7 +2015,7 @@ void RefractionBsdfNode::simplify_settings(Scene *scene) bool RefractionBsdfNode::has_integrator_dependency() { ShaderInput *roughness_input = input("Roughness"); - return !roughness_input->link && roughness_input->value.x <= 1e-4f; + return !roughness_input->link && roughness_input->value_float() <= 1e-4f; } void RefractionBsdfNode::compile(SVMCompiler& compiler) @@ -2036,9 +2036,9 @@ void RefractionBsdfNode::compile(OSLCompiler& compiler) /* Toon BSDF Closure */ -static ShaderEnum toon_component_init() +static NodeEnum toon_component_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Diffuse", CLOSURE_BSDF_DIFFUSE_TOON_ID); enm.insert("Glossy", CLOSURE_BSDF_GLOSSY_TOON_ID); @@ -2046,15 +2046,15 @@ static ShaderEnum toon_component_init() return enm; } -ShaderEnum ToonBsdfNode::component_enum = toon_component_init(); +NodeEnum ToonBsdfNode::component_enum = toon_component_init(); ToonBsdfNode::ToonBsdfNode() { closure = CLOSURE_BSDF_DIFFUSE_TOON_ID; component = ustring("Diffuse"); - add_input("Size", SHADER_SOCKET_FLOAT, 0.5f); - add_input("Smooth", SHADER_SOCKET_FLOAT, 0.0f); + add_input("Size", SocketType::FLOAT, 0.5f); + add_input("Smooth", SocketType::FLOAT, 0.0f); } void ToonBsdfNode::compile(SVMCompiler& compiler) @@ -2076,7 +2076,7 @@ VelvetBsdfNode::VelvetBsdfNode() { closure = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID; - add_input("Sigma", SHADER_SOCKET_FLOAT, 1.0f); + add_input("Sigma", SocketType::FLOAT, 1.0f); } void VelvetBsdfNode::compile(SVMCompiler& compiler) @@ -2094,7 +2094,7 @@ void VelvetBsdfNode::compile(OSLCompiler& compiler) DiffuseBsdfNode::DiffuseBsdfNode() { closure = CLOSURE_BSDF_DIFFUSE_ID; - add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f); + add_input("Roughness", SocketType::FLOAT, 0.0f); } void DiffuseBsdfNode::compile(SVMCompiler& compiler) @@ -2144,9 +2144,9 @@ void TransparentBsdfNode::compile(OSLCompiler& compiler) /* Subsurface Scattering Closure */ -static ShaderEnum subsurface_falloff_init() +static NodeEnum subsurface_falloff_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Cubic", CLOSURE_BSSRDF_CUBIC_ID); enm.insert("Gaussian", CLOSURE_BSSRDF_GAUSSIAN_ID); @@ -2155,7 +2155,7 @@ static ShaderEnum subsurface_falloff_init() return enm; } -ShaderEnum SubsurfaceScatteringNode::falloff_enum = subsurface_falloff_init(); +NodeEnum SubsurfaceScatteringNode::falloff_enum = subsurface_falloff_init(); SubsurfaceScatteringNode::SubsurfaceScatteringNode() : BsdfNode(true) @@ -2163,10 +2163,10 @@ SubsurfaceScatteringNode::SubsurfaceScatteringNode() name = "subsurface_scattering"; closure = CLOSURE_BSSRDF_CUBIC_ID; - add_input("Scale", SHADER_SOCKET_FLOAT, 0.01f); - add_input("Radius", SHADER_SOCKET_VECTOR, make_float3(0.1f, 0.1f, 0.1f)); - add_input("Sharpness", SHADER_SOCKET_FLOAT, 0.0f); - add_input("Texture Blur", SHADER_SOCKET_FLOAT, 1.0f); + add_input("Scale", SocketType::FLOAT, 0.01f); + add_input("Radius", SocketType::VECTOR, make_float3(0.1f, 0.1f, 0.1f)); + add_input("Sharpness", SocketType::FLOAT, 0.0f); + add_input("Texture Blur", SocketType::FLOAT, 1.0f); } void SubsurfaceScatteringNode::compile(SVMCompiler& compiler) @@ -2192,11 +2192,11 @@ bool SubsurfaceScatteringNode::has_bssrdf_bump() EmissionNode::EmissionNode() : ShaderNode("emission") { - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); - add_input("Strength", SHADER_SOCKET_FLOAT, 10.0f); - add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("Color", SocketType::COLOR, make_float3(0.8f, 0.8f, 0.8f)); + add_input("Strength", SocketType::FLOAT, 10.0f); + add_input("SurfaceMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); - add_output("Emission", SHADER_SOCKET_CLOSURE); + add_output("Emission", SocketType::CLOSURE); } void EmissionNode::compile(SVMCompiler& compiler) @@ -2210,7 +2210,7 @@ void EmissionNode::compile(SVMCompiler& compiler) compiler.stack_assign(strength_in)); } else - compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value * strength_in->value.x); + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value() * strength_in->value_float()); compiler.add_node(NODE_CLOSURE_EMISSION, compiler.closure_mix_weight_offset()); } @@ -2225,8 +2225,8 @@ bool EmissionNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*socke ShaderInput *color_in = input("Color"); ShaderInput *strength_in = input("Strength"); - return ((!color_in->link && color_in->value == make_float3(0.0f, 0.0f, 0.0f)) || - (!strength_in->link && strength_in->value.x == 0.0f)); + return ((!color_in->link && color_in->value() == make_float3(0.0f, 0.0f, 0.0f)) || + (!strength_in->link && strength_in->value_float() == 0.0f)); } /* Background Closure */ @@ -2234,11 +2234,11 @@ bool EmissionNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*socke BackgroundNode::BackgroundNode() : ShaderNode("background") { - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); - add_input("Strength", SHADER_SOCKET_FLOAT, 1.0f); - add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("Color", SocketType::COLOR, make_float3(0.8f, 0.8f, 0.8f)); + add_input("Strength", SocketType::FLOAT, 1.0f); + add_input("SurfaceMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); - add_output("Background", SHADER_SOCKET_CLOSURE); + add_output("Background", SocketType::CLOSURE); } void BackgroundNode::compile(SVMCompiler& compiler) @@ -2252,7 +2252,7 @@ void BackgroundNode::compile(SVMCompiler& compiler) compiler.stack_assign(strength_in)); } else - compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value*strength_in->value.x); + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value()*strength_in->value_float()); compiler.add_node(NODE_CLOSURE_BACKGROUND, compiler.closure_mix_weight_offset()); } @@ -2267,8 +2267,8 @@ bool BackgroundNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*soc ShaderInput *color_in = input("Color"); ShaderInput *strength_in = input("Strength"); - return ((!color_in->link && color_in->value == make_float3(0.0f, 0.0f, 0.0f)) || - (!strength_in->link && strength_in->value.x == 0.0f)); + return ((!color_in->link && color_in->value() == make_float3(0.0f, 0.0f, 0.0f)) || + (!strength_in->link && strength_in->value_float() == 0.0f)); } /* Holdout Closure */ @@ -2276,10 +2276,10 @@ bool BackgroundNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*soc HoldoutNode::HoldoutNode() : ShaderNode("holdout") { - add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); - add_input("VolumeMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("SurfaceMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); + add_input("VolumeMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); - add_output("Holdout", SHADER_SOCKET_CLOSURE); + add_output("Holdout", SocketType::CLOSURE); } void HoldoutNode::compile(SVMCompiler& compiler) @@ -2300,11 +2300,11 @@ void HoldoutNode::compile(OSLCompiler& compiler) AmbientOcclusionNode::AmbientOcclusionNode() : ShaderNode("ambient_occlusion") { - add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); - add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_input("Color", SocketType::COLOR, make_float3(0.8f, 0.8f, 0.8f)); + add_input("SurfaceMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); - add_output("AO", SHADER_SOCKET_CLOSURE); + add_output("AO", SocketType::CLOSURE); } void AmbientOcclusionNode::compile(SVMCompiler& compiler) @@ -2314,7 +2314,7 @@ void AmbientOcclusionNode::compile(SVMCompiler& compiler) if(color_in->link) compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in)); else - compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value); + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value()); compiler.add_node(NODE_CLOSURE_AMBIENT_OCCLUSION, compiler.closure_mix_weight_offset()); } @@ -2331,11 +2331,11 @@ VolumeNode::VolumeNode() { closure = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID; - add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); - add_input("Density", SHADER_SOCKET_FLOAT, 1.0f); - add_input("VolumeMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); + add_input("Color", SocketType::COLOR, make_float3(0.8f, 0.8f, 0.8f)); + add_input("Density", SocketType::FLOAT, 1.0f); + add_input("VolumeMixWeight", SocketType::FLOAT, 0.0f, SocketType::SVM_INTERNAL); - add_output("Volume", SHADER_SOCKET_CLOSURE); + add_output("Volume", SocketType::CLOSURE); } void VolumeNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput *param2) @@ -2345,15 +2345,15 @@ void VolumeNode::compile(SVMCompiler& compiler, ShaderInput *param1, ShaderInput if(color_in->link) compiler.add_node(NODE_CLOSURE_WEIGHT, compiler.stack_assign(color_in)); else - compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value); + compiler.add_node(NODE_CLOSURE_SET_WEIGHT, color_in->value()); compiler.add_node(NODE_CLOSURE_VOLUME, compiler.encode_uchar4(closure, (param1)? compiler.stack_assign(param1): SVM_STACK_INVALID, (param2)? compiler.stack_assign(param2): SVM_STACK_INVALID, compiler.closure_mix_weight_offset()), - __float_as_int((param1)? param1->value.x: 0.0f), - __float_as_int((param2)? param2->value.x: 0.0f)); + __float_as_int((param1)? param1->value_float(): 0.0f), + __float_as_int((param2)? param2->value_float(): 0.0f)); } void VolumeNode::compile(SVMCompiler& compiler) @@ -2389,7 +2389,7 @@ ScatterVolumeNode::ScatterVolumeNode() { closure = CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID; - add_input("Anisotropy", SHADER_SOCKET_FLOAT, 0.0f); + add_input("Anisotropy", SocketType::FLOAT, 0.0f); } void ScatterVolumeNode::compile(SVMCompiler& compiler) @@ -2404,9 +2404,9 @@ void ScatterVolumeNode::compile(OSLCompiler& compiler) /* Hair BSDF Closure */ -static ShaderEnum hair_component_init() +static NodeEnum hair_component_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Reflection", CLOSURE_BSDF_HAIR_REFLECTION_ID); enm.insert("Transmission", CLOSURE_BSDF_HAIR_TRANSMISSION_ID); @@ -2414,17 +2414,17 @@ static ShaderEnum hair_component_init() return enm; } -ShaderEnum HairBsdfNode::component_enum = hair_component_init(); +NodeEnum HairBsdfNode::component_enum = hair_component_init(); HairBsdfNode::HairBsdfNode() { closure = CLOSURE_BSDF_HAIR_REFLECTION_ID; component = ustring("Reflection"); - add_input("Offset", SHADER_SOCKET_FLOAT); - add_input("RoughnessU", SHADER_SOCKET_FLOAT); - add_input("RoughnessV", SHADER_SOCKET_FLOAT); - add_input("Tangent", SHADER_SOCKET_VECTOR); + add_input("Offset", SocketType::FLOAT); + add_input("RoughnessU", SocketType::FLOAT); + add_input("RoughnessV", SocketType::FLOAT); + add_input("Tangent", SocketType::VECTOR); } void HairBsdfNode::compile(SVMCompiler& compiler) @@ -2448,15 +2448,15 @@ GeometryNode::GeometryNode() { special_type = SHADER_SPECIAL_TYPE_GEOMETRY; - add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_output("Position", SHADER_SOCKET_POINT); - add_output("Normal", SHADER_SOCKET_NORMAL); - add_output("Tangent", SHADER_SOCKET_NORMAL); - add_output("True Normal", SHADER_SOCKET_NORMAL); - add_output("Incoming", SHADER_SOCKET_VECTOR); - add_output("Parametric", SHADER_SOCKET_POINT); - add_output("Backfacing", SHADER_SOCKET_FLOAT); - add_output("Pointiness", SHADER_SOCKET_FLOAT); + add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_output("Position", SocketType::POINT); + add_output("Normal", SocketType::NORMAL); + add_output("Tangent", SocketType::NORMAL); + add_output("True Normal", SocketType::NORMAL); + add_output("Incoming", SocketType::VECTOR); + add_output("Parametric", SocketType::POINT); + add_output("Backfacing", SocketType::FLOAT); + add_output("Pointiness", SocketType::FLOAT); } void GeometryNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -2554,14 +2554,14 @@ void GeometryNode::compile(OSLCompiler& compiler) TextureCoordinateNode::TextureCoordinateNode() : ShaderNode("texture_coordinate") { - add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_output("Generated", SHADER_SOCKET_POINT); - add_output("Normal", SHADER_SOCKET_NORMAL); - add_output("UV", SHADER_SOCKET_POINT); - add_output("Object", SHADER_SOCKET_POINT); - add_output("Camera", SHADER_SOCKET_POINT); - add_output("Window", SHADER_SOCKET_POINT); - add_output("Reflection", SHADER_SOCKET_NORMAL); + add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_output("Generated", SocketType::POINT); + add_output("Normal", SocketType::NORMAL); + add_output("UV", SocketType::POINT); + add_output("Object", SocketType::POINT); + add_output("Camera", SocketType::POINT); + add_output("Window", SocketType::POINT); + add_output("Reflection", SocketType::NORMAL); from_dupli = false; use_transform = false; @@ -2704,7 +2704,7 @@ UVMapNode::UVMapNode() attribute = ""; from_dupli = false; - add_output("UV", SHADER_SOCKET_POINT); + add_output("UV", SocketType::POINT); } void UVMapNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -2773,18 +2773,18 @@ void UVMapNode::compile(OSLCompiler& compiler) LightPathNode::LightPathNode() : ShaderNode("light_path") { - add_output("Is Camera Ray", SHADER_SOCKET_FLOAT); - add_output("Is Shadow Ray", SHADER_SOCKET_FLOAT); - add_output("Is Diffuse Ray", SHADER_SOCKET_FLOAT); - add_output("Is Glossy Ray", SHADER_SOCKET_FLOAT); - add_output("Is Singular Ray", SHADER_SOCKET_FLOAT); - add_output("Is Reflection Ray", SHADER_SOCKET_FLOAT); - add_output("Is Transmission Ray", SHADER_SOCKET_FLOAT); - add_output("Is Volume Scatter Ray", SHADER_SOCKET_FLOAT); - add_output("Ray Length", SHADER_SOCKET_FLOAT); - add_output("Ray Depth", SHADER_SOCKET_FLOAT); - add_output("Transparent Depth", SHADER_SOCKET_FLOAT); - add_output("Transmission Depth", SHADER_SOCKET_FLOAT); + add_output("Is Camera Ray", SocketType::FLOAT); + add_output("Is Shadow Ray", SocketType::FLOAT); + add_output("Is Diffuse Ray", SocketType::FLOAT); + add_output("Is Glossy Ray", SocketType::FLOAT); + add_output("Is Singular Ray", SocketType::FLOAT); + add_output("Is Reflection Ray", SocketType::FLOAT); + add_output("Is Transmission Ray", SocketType::FLOAT); + add_output("Is Volume Scatter Ray", SocketType::FLOAT); + add_output("Ray Length", SocketType::FLOAT); + add_output("Ray Depth", SocketType::FLOAT); + add_output("Transparent Depth", SocketType::FLOAT); + add_output("Transmission Depth", SocketType::FLOAT); } void LightPathNode::compile(SVMCompiler& compiler) @@ -2863,11 +2863,11 @@ void LightPathNode::compile(OSLCompiler& compiler) LightFalloffNode::LightFalloffNode() : ShaderNode("light_fallof") { - add_input("Strength", SHADER_SOCKET_FLOAT, 100.0f); - add_input("Smooth", SHADER_SOCKET_FLOAT, 0.0f); - add_output("Quadratic", SHADER_SOCKET_FLOAT); - add_output("Linear", SHADER_SOCKET_FLOAT); - add_output("Constant", SHADER_SOCKET_FLOAT); + add_input("Strength", SocketType::FLOAT, 100.0f); + add_input("Smooth", SocketType::FLOAT, 0.0f); + add_output("Quadratic", SocketType::FLOAT); + add_output("Linear", SocketType::FLOAT); + add_output("Constant", SocketType::FLOAT); } void LightFalloffNode::compile(SVMCompiler& compiler) @@ -2913,10 +2913,10 @@ void LightFalloffNode::compile(OSLCompiler& compiler) ObjectInfoNode::ObjectInfoNode() : ShaderNode("object_info") { - add_output("Location", SHADER_SOCKET_VECTOR); - add_output("Object Index", SHADER_SOCKET_FLOAT); - add_output("Material Index", SHADER_SOCKET_FLOAT); - add_output("Random", SHADER_SOCKET_FLOAT); + add_output("Location", SocketType::VECTOR); + add_output("Object Index", SocketType::FLOAT); + add_output("Material Index", SocketType::FLOAT); + add_output("Random", SocketType::FLOAT); } void ObjectInfoNode::compile(SVMCompiler& compiler) @@ -2952,16 +2952,16 @@ void ObjectInfoNode::compile(OSLCompiler& compiler) ParticleInfoNode::ParticleInfoNode() : ShaderNode("particle_info") { - add_output("Index", SHADER_SOCKET_FLOAT); - add_output("Age", SHADER_SOCKET_FLOAT); - add_output("Lifetime", SHADER_SOCKET_FLOAT); - add_output("Location", SHADER_SOCKET_POINT); + add_output("Index", SocketType::FLOAT); + add_output("Age", SocketType::FLOAT); + add_output("Lifetime", SocketType::FLOAT); + add_output("Location", SocketType::POINT); #if 0 /* not yet supported */ add_output("Rotation", SHADER_SOCKET_QUATERNION); #endif - add_output("Size", SHADER_SOCKET_FLOAT); - add_output("Velocity", SHADER_SOCKET_VECTOR); - add_output("Angular Velocity", SHADER_SOCKET_VECTOR); + add_output("Size", SocketType::FLOAT); + add_output("Velocity", SocketType::VECTOR); + add_output("Angular Velocity", SocketType::VECTOR); } void ParticleInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -3046,12 +3046,12 @@ void ParticleInfoNode::compile(OSLCompiler& compiler) HairInfoNode::HairInfoNode() : ShaderNode("hair_info") { - add_output("Is Strand", SHADER_SOCKET_FLOAT); - add_output("Intercept", SHADER_SOCKET_FLOAT); - add_output("Thickness", SHADER_SOCKET_FLOAT); - add_output("Tangent Normal", SHADER_SOCKET_NORMAL); + add_output("Is Strand", SocketType::FLOAT); + add_output("Intercept", SocketType::FLOAT); + add_output("Thickness", SocketType::FLOAT); + add_output("Tangent Normal", SocketType::NORMAL); /*output for minimum hair width transparency - deactivated*/ - /*add_output("Fade", SHADER_SOCKET_FLOAT);*/ + /*add_output("Fade", SocketType::FLOAT);*/ } void HairInfoNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -3110,7 +3110,7 @@ ValueNode::ValueNode() { value = 0.0f; - add_output("Value", SHADER_SOCKET_FLOAT); + add_output("Value", SocketType::FLOAT); } bool ValueNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*socket*/, @@ -3140,7 +3140,7 @@ ColorNode::ColorNode() { value = make_float3(0.0f, 0.0f, 0.0f); - add_output("Color", SHADER_SOCKET_COLOR); + add_output("Color", SocketType::COLOR); } bool ColorNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput * /*socket*/, @@ -3174,9 +3174,9 @@ AddClosureNode::AddClosureNode() { 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); + add_input("Closure1", SocketType::CLOSURE); + add_input("Closure2", SocketType::CLOSURE); + add_output("Closure", SocketType::CLOSURE); } void AddClosureNode::compile(SVMCompiler& /*compiler*/) @@ -3196,10 +3196,10 @@ MixClosureNode::MixClosureNode() { 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); - add_output("Closure", SHADER_SOCKET_CLOSURE); + add_input("Fac", SocketType::FLOAT, 0.5f); + add_input("Closure1", SocketType::CLOSURE); + add_input("Closure2", SocketType::CLOSURE); + add_output("Closure", SocketType::CLOSURE); } void MixClosureNode::compile(SVMCompiler& /*compiler*/) @@ -3229,12 +3229,12 @@ bool MixClosureNode::constant_fold(ShaderGraph *graph, ShaderOutput * /*socket*/ /* check for closure links and make sure factor link is disconnected */ if(closure1_in->link && closure2_in->link && !fac_in->link) { /* factor 0.0 */ - if(fac_in->value.x == 0.0f) { + if(fac_in->value_float() == 0.0f) { graph->relink(this, closure_out, closure1_in->link); return true; } /* factor 1.0 */ - else if(fac_in->value.x == 1.0f) { + else if(fac_in->value_float() == 1.0f) { graph->relink(this, closure_out, closure2_in->link); return true; } @@ -3248,10 +3248,10 @@ bool MixClosureNode::constant_fold(ShaderGraph *graph, ShaderOutput * /*socket*/ MixClosureWeightNode::MixClosureWeightNode() : ShaderNode("mix_closure_weight") { - add_input("Weight", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Fac", SHADER_SOCKET_FLOAT, 1.0f); - add_output("Weight1", SHADER_SOCKET_FLOAT); - add_output("Weight2", SHADER_SOCKET_FLOAT); + add_input("Weight", SocketType::FLOAT, 1.0f); + add_input("Fac", SocketType::FLOAT, 1.0f); + add_output("Weight1", SocketType::FLOAT); + add_output("Weight2", SocketType::FLOAT); } void MixClosureWeightNode::compile(SVMCompiler& compiler) @@ -3279,9 +3279,9 @@ void MixClosureWeightNode::compile(OSLCompiler& /*compiler*/) InvertNode::InvertNode() : ShaderNode("invert") { - add_input("Fac", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Color", SHADER_SOCKET_COLOR); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Fac", SocketType::FLOAT, 1.0f); + add_input("Color", SocketType::COLOR); + add_output("Color", SocketType::COLOR); } void InvertNode::compile(SVMCompiler& compiler) @@ -3310,15 +3310,15 @@ MixNode::MixNode() use_clamp = false; - add_input("Fac", SHADER_SOCKET_FLOAT, 0.5f); - add_input("Color1", SHADER_SOCKET_COLOR); - add_input("Color2", SHADER_SOCKET_COLOR); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Fac", SocketType::FLOAT, 0.5f); + add_input("Color1", SocketType::COLOR); + add_input("Color2", SocketType::COLOR); + add_output("Color", SocketType::COLOR); } -static ShaderEnum mix_type_init() +static NodeEnum mix_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Mix", NODE_MIX_BLEND); enm.insert("Add", NODE_MIX_ADD); @@ -3342,7 +3342,7 @@ static ShaderEnum mix_type_init() return enm; } -ShaderEnum MixNode::type_enum = mix_type_init(); +NodeEnum MixNode::type_enum = mix_type_init(); void MixNode::compile(SVMCompiler& compiler) { @@ -3390,19 +3390,19 @@ bool MixNode::constant_fold(ShaderGraph *graph, ShaderOutput * /*socket*/, float /* remove unused mix color input when factor is 0.0 or 1.0 */ if(!fac_in->link) { /* factor 0.0 */ - if(fac_in->value.x == 0.0f) { + if(fac_in->value_float() == 0.0f) { if(color1_in->link) graph->relink(this, color_out, color1_in->link); else - *optimized_value = color1_in->value; + *optimized_value = color1_in->value(); return true; } /* factor 1.0 */ - else if(fac_in->value.x == 1.0f) { + else if(fac_in->value_float() == 1.0f) { if(color2_in->link) graph->relink(this, color_out, color2_in->link); else - *optimized_value = color2_in->value; + *optimized_value = color2_in->value(); return true; } } @@ -3414,10 +3414,10 @@ bool MixNode::constant_fold(ShaderGraph *graph, ShaderOutput * /*socket*/, float CombineRGBNode::CombineRGBNode() : ShaderNode("combine_rgb") { - add_input("R", SHADER_SOCKET_FLOAT); - add_input("G", SHADER_SOCKET_FLOAT); - add_input("B", SHADER_SOCKET_FLOAT); - add_output("Image", SHADER_SOCKET_COLOR); + add_input("R", SocketType::FLOAT); + add_input("G", SocketType::FLOAT); + add_input("B", SocketType::FLOAT); + add_output("Image", SocketType::COLOR); } void CombineRGBNode::compile(SVMCompiler& compiler) @@ -3449,10 +3449,10 @@ void CombineRGBNode::compile(OSLCompiler& compiler) CombineXYZNode::CombineXYZNode() : ShaderNode("combine_xyz") { - add_input("X", SHADER_SOCKET_FLOAT); - add_input("Y", SHADER_SOCKET_FLOAT); - add_input("Z", SHADER_SOCKET_FLOAT); - add_output("Vector", SHADER_SOCKET_VECTOR); + add_input("X", SocketType::FLOAT); + add_input("Y", SocketType::FLOAT); + add_input("Z", SocketType::FLOAT); + add_output("Vector", SocketType::VECTOR); } void CombineXYZNode::compile(SVMCompiler& compiler) @@ -3484,10 +3484,10 @@ void CombineXYZNode::compile(OSLCompiler& compiler) CombineHSVNode::CombineHSVNode() : ShaderNode("combine_hsv") { - add_input("H", SHADER_SOCKET_FLOAT); - add_input("S", SHADER_SOCKET_FLOAT); - add_input("V", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("H", SocketType::FLOAT); + add_input("S", SocketType::FLOAT); + add_input("V", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); } void CombineHSVNode::compile(SVMCompiler& compiler) @@ -3514,9 +3514,9 @@ void CombineHSVNode::compile(OSLCompiler& compiler) GammaNode::GammaNode() : ShaderNode("gamma") { - add_input("Color", SHADER_SOCKET_COLOR); - add_input("Gamma", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Color", SocketType::COLOR); + add_input("Gamma", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); } bool GammaNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, float3 *optimized_value) @@ -3526,8 +3526,8 @@ bool GammaNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, flo if(socket == output("Color")) { if(color_in->link == NULL && gamma_in->link == NULL) { - *optimized_value = svm_math_gamma_color(color_in->value, - gamma_in->value.x); + *optimized_value = svm_math_gamma_color(color_in->value(), + gamma_in->value_float()); return true; } } @@ -3556,10 +3556,10 @@ void GammaNode::compile(OSLCompiler& compiler) BrightContrastNode::BrightContrastNode() : ShaderNode("brightness") { - add_input("Color", SHADER_SOCKET_COLOR); - add_input("Bright", SHADER_SOCKET_FLOAT); - add_input("Contrast", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Color", SocketType::COLOR); + add_input("Bright", SocketType::FLOAT); + add_input("Contrast", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); } void BrightContrastNode::compile(SVMCompiler& compiler) @@ -3586,10 +3586,10 @@ void BrightContrastNode::compile(OSLCompiler& compiler) SeparateRGBNode::SeparateRGBNode() : ShaderNode("separate_rgb") { - add_input("Image", SHADER_SOCKET_COLOR); - add_output("R", SHADER_SOCKET_FLOAT); - add_output("G", SHADER_SOCKET_FLOAT); - add_output("B", SHADER_SOCKET_FLOAT); + add_input("Image", SocketType::COLOR); + add_output("R", SocketType::FLOAT); + add_output("G", SocketType::FLOAT); + add_output("B", SocketType::FLOAT); } void SeparateRGBNode::compile(SVMCompiler& compiler) @@ -3621,10 +3621,10 @@ void SeparateRGBNode::compile(OSLCompiler& compiler) SeparateXYZNode::SeparateXYZNode() : ShaderNode("separate_xyz") { - add_input("Vector", SHADER_SOCKET_VECTOR); - add_output("X", SHADER_SOCKET_FLOAT); - add_output("Y", SHADER_SOCKET_FLOAT); - add_output("Z", SHADER_SOCKET_FLOAT); + add_input("Vector", SocketType::VECTOR); + add_output("X", SocketType::FLOAT); + add_output("Y", SocketType::FLOAT); + add_output("Z", SocketType::FLOAT); } void SeparateXYZNode::compile(SVMCompiler& compiler) @@ -3656,10 +3656,10 @@ void SeparateXYZNode::compile(OSLCompiler& compiler) SeparateHSVNode::SeparateHSVNode() : ShaderNode("separate_hsv") { - add_input("Color", SHADER_SOCKET_COLOR); - add_output("H", SHADER_SOCKET_FLOAT); - add_output("S", SHADER_SOCKET_FLOAT); - add_output("V", SHADER_SOCKET_FLOAT); + add_input("Color", SocketType::COLOR); + add_output("H", SocketType::FLOAT); + add_output("S", SocketType::FLOAT); + add_output("V", SocketType::FLOAT); } void SeparateHSVNode::compile(SVMCompiler& compiler) @@ -3686,12 +3686,12 @@ void SeparateHSVNode::compile(OSLCompiler& compiler) HSVNode::HSVNode() : ShaderNode("hsv") { - add_input("Hue", SHADER_SOCKET_FLOAT); - add_input("Saturation", SHADER_SOCKET_FLOAT); - add_input("Value", SHADER_SOCKET_FLOAT); - add_input("Fac", SHADER_SOCKET_FLOAT); - add_input("Color", SHADER_SOCKET_COLOR); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Hue", SocketType::FLOAT); + add_input("Saturation", SocketType::FLOAT); + add_input("Value", SocketType::FLOAT); + add_input("Fac", SocketType::FLOAT); + add_input("Color", SocketType::COLOR); + add_output("Color", SocketType::COLOR); } void HSVNode::compile(SVMCompiler& compiler) @@ -3726,9 +3726,9 @@ AttributeNode::AttributeNode() { attribute = ""; - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Vector", SHADER_SOCKET_VECTOR); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Vector", SocketType::VECTOR); + add_output("Fac", SocketType::FLOAT); } void AttributeNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -3807,9 +3807,9 @@ void AttributeNode::compile(OSLCompiler& compiler) CameraNode::CameraNode() : ShaderNode("camera") { - add_output("View Vector", SHADER_SOCKET_VECTOR); - add_output("View Z Depth", SHADER_SOCKET_FLOAT); - add_output("View Distance", SHADER_SOCKET_FLOAT); + add_output("View Vector", SocketType::VECTOR); + add_output("View Z Depth", SocketType::FLOAT); + add_output("View Distance", SocketType::FLOAT); } void CameraNode::compile(SVMCompiler& compiler) @@ -3834,9 +3834,9 @@ void CameraNode::compile(OSLCompiler& compiler) FresnelNode::FresnelNode() : ShaderNode("fresnel") { - add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_input("IOR", SHADER_SOCKET_FLOAT, 1.45f); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_input("Normal", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_input("IOR", SocketType::FLOAT, 1.45f); + add_output("Fac", SocketType::FLOAT); } void FresnelNode::compile(SVMCompiler& compiler) @@ -3847,7 +3847,7 @@ void FresnelNode::compile(SVMCompiler& compiler) compiler.add_node(NODE_FRESNEL, compiler.stack_assign(IOR_in), - __float_as_int(IOR_in->value.x), + __float_as_int(IOR_in->value_float()), compiler.encode_uchar4( compiler.stack_assign_if_linked(normal_in), compiler.stack_assign(fac_out))); @@ -3863,11 +3863,11 @@ void FresnelNode::compile(OSLCompiler& compiler) LayerWeightNode::LayerWeightNode() : ShaderNode("layer_weight") { - add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_input("Blend", SHADER_SOCKET_FLOAT, 0.5f); + add_input("Normal", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_input("Blend", SocketType::FLOAT, 0.5f); - add_output("Fresnel", SHADER_SOCKET_FLOAT); - add_output("Facing", SHADER_SOCKET_FLOAT); + add_output("Fresnel", SocketType::FLOAT); + add_output("Facing", SocketType::FLOAT); } void LayerWeightNode::compile(SVMCompiler& compiler) @@ -3880,7 +3880,7 @@ void LayerWeightNode::compile(SVMCompiler& compiler) if(!fresnel_out->links.empty()) { compiler.add_node(NODE_LAYER_WEIGHT, compiler.stack_assign_if_linked(blend_in), - __float_as_int(blend_in->value.x), + __float_as_int(blend_in->value_float()), compiler.encode_uchar4(NODE_LAYER_WEIGHT_FRESNEL, compiler.stack_assign_if_linked(normal_in), compiler.stack_assign(fresnel_out))); @@ -3889,7 +3889,7 @@ void LayerWeightNode::compile(SVMCompiler& compiler) if(!facing_out->links.empty()) { compiler.add_node(NODE_LAYER_WEIGHT, compiler.stack_assign_if_linked(blend_in), - __float_as_int(blend_in->value.x), + __float_as_int(blend_in->value_float()), compiler.encode_uchar4(NODE_LAYER_WEIGHT_FACING, compiler.stack_assign_if_linked(normal_in), compiler.stack_assign(facing_out))); @@ -3906,8 +3906,8 @@ void LayerWeightNode::compile(OSLCompiler& compiler) WireframeNode::WireframeNode() : ShaderNode("wireframe") { - add_input("Size", SHADER_SOCKET_FLOAT, 0.01f); - add_output("Fac", SHADER_SOCKET_FLOAT); + add_input("Size", SocketType::FLOAT, 0.01f); + add_output("Fac", SocketType::FLOAT); use_pixel_size = false; } @@ -3951,8 +3951,8 @@ void WireframeNode::compile(OSLCompiler& compiler) WavelengthNode::WavelengthNode() : ShaderNode("wavelength") { - add_input("Wavelength", SHADER_SOCKET_FLOAT, 500.0f); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Wavelength", SocketType::FLOAT, 500.0f); + add_output("Color", SocketType::COLOR); } void WavelengthNode::compile(SVMCompiler& compiler) @@ -3975,8 +3975,8 @@ void WavelengthNode::compile(OSLCompiler& compiler) BlackbodyNode::BlackbodyNode() : ShaderNode("blackbody") { - add_input("Temperature", SHADER_SOCKET_FLOAT, 1200.0f); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Temperature", SocketType::FLOAT, 1200.0f); + add_output("Color", SocketType::COLOR); } bool BlackbodyNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, float3 *optimized_value) @@ -3985,7 +3985,7 @@ bool BlackbodyNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, if(socket == output("Color")) { if(temperature_in->link == NULL) { - *optimized_value = svm_math_blackbody_color(temperature_in->value.x); + *optimized_value = svm_math_blackbody_color(temperature_in->value_float()); return true; } } @@ -4015,10 +4015,10 @@ OutputNode::OutputNode() { special_type = SHADER_SPECIAL_TYPE_OUTPUT; - add_input("Surface", SHADER_SOCKET_CLOSURE); - add_input("Volume", SHADER_SOCKET_CLOSURE); - add_input("Displacement", SHADER_SOCKET_FLOAT); - add_input("Normal", SHADER_SOCKET_NORMAL); + add_input("Surface", SocketType::CLOSURE); + add_input("Volume", SocketType::CLOSURE); + add_input("Displacement", SocketType::FLOAT); + add_input("Normal", SocketType::NORMAL); } void OutputNode::compile(SVMCompiler& compiler) @@ -4051,14 +4051,14 @@ MathNode::MathNode() use_clamp = false; - add_input("Value1", SHADER_SOCKET_FLOAT); - add_input("Value2", SHADER_SOCKET_FLOAT); - add_output("Value", SHADER_SOCKET_FLOAT); + add_input("Value1", SocketType::FLOAT); + add_input("Value2", SocketType::FLOAT); + add_output("Value", SocketType::FLOAT); } -static ShaderEnum math_type_init() +static NodeEnum math_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Add", NODE_MATH_ADD); enm.insert("Subtract", NODE_MATH_SUBTRACT); @@ -4083,7 +4083,7 @@ static ShaderEnum math_type_init() return enm; } -ShaderEnum MathNode::type_enum = math_type_init(); +NodeEnum MathNode::type_enum = math_type_init(); bool MathNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, float3 *optimized_value) { @@ -4093,8 +4093,8 @@ bool MathNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, floa if(socket == output("Value")) { if(value1_in->link == NULL && value2_in->link == NULL) { optimized_value->x = svm_math((NodeMath)type_enum[type], - value1_in->value.x, - value2_in->value.x); + value1_in->value_float(), + value2_in->value_float()); if(use_clamp) { optimized_value->x = saturate(optimized_value->x); @@ -4139,15 +4139,15 @@ VectorMathNode::VectorMathNode() { type = ustring("Add"); - add_input("Vector1", SHADER_SOCKET_VECTOR); - add_input("Vector2", SHADER_SOCKET_VECTOR); - add_output("Value", SHADER_SOCKET_FLOAT); - add_output("Vector", SHADER_SOCKET_VECTOR); + add_input("Vector1", SocketType::VECTOR); + add_input("Vector2", SocketType::VECTOR); + add_output("Value", SocketType::FLOAT); + add_output("Vector", SocketType::VECTOR); } -static ShaderEnum vector_math_type_init() +static NodeEnum vector_math_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Add", NODE_VECTOR_MATH_ADD); enm.insert("Subtract", NODE_VECTOR_MATH_SUBTRACT); @@ -4159,7 +4159,7 @@ static ShaderEnum vector_math_type_init() return enm; } -ShaderEnum VectorMathNode::type_enum = vector_math_type_init(); +NodeEnum VectorMathNode::type_enum = vector_math_type_init(); bool VectorMathNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket, float3 *optimized_value) { @@ -4173,8 +4173,8 @@ bool VectorMathNode::constant_fold(ShaderGraph * /*graph*/, ShaderOutput *socket svm_vector_math(&value, &vector, (NodeVectorMath)type_enum[type], - vector1_in->value, - vector2_in->value); + vector1_in->value(), + vector2_in->value()); if(socket == output("Value")) { optimized_value->x = value; @@ -4220,13 +4220,13 @@ VectorTransformNode::VectorTransformNode() convert_from = ustring("world"); convert_to = ustring("object"); - add_input("Vector", SHADER_SOCKET_VECTOR); - add_output("Vector", SHADER_SOCKET_VECTOR); + add_input("Vector", SocketType::VECTOR); + add_output("Vector", SocketType::VECTOR); } -static ShaderEnum vector_transform_type_init() +static NodeEnum vector_transform_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Vector", NODE_VECTOR_TRANSFORM_TYPE_VECTOR); enm.insert("Point", NODE_VECTOR_TRANSFORM_TYPE_POINT); @@ -4235,9 +4235,9 @@ static ShaderEnum vector_transform_type_init() return enm; } -static ShaderEnum vector_transform_convert_space_init() +static NodeEnum vector_transform_convert_space_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("world", NODE_VECTOR_TRANSFORM_CONVERT_SPACE_WORLD); enm.insert("object", NODE_VECTOR_TRANSFORM_CONVERT_SPACE_OBJECT); @@ -4246,8 +4246,8 @@ static ShaderEnum vector_transform_convert_space_init() return enm; } -ShaderEnum VectorTransformNode::type_enum = vector_transform_type_init(); -ShaderEnum VectorTransformNode::convert_space_enum = vector_transform_convert_space_init(); +NodeEnum VectorTransformNode::type_enum = vector_transform_type_init(); +NodeEnum VectorTransformNode::convert_space_enum = vector_transform_convert_space_init(); void VectorTransformNode::compile(SVMCompiler& compiler) { @@ -4281,16 +4281,16 @@ BumpNode::BumpNode() /* this input is used by the user, but after graph transform it is no longer * used and moved to sampler center/x/y instead */ - add_input("Height", SHADER_SOCKET_FLOAT); + add_input("Height", SocketType::FLOAT); - add_input("SampleCenter", SHADER_SOCKET_FLOAT); - add_input("SampleX", SHADER_SOCKET_FLOAT); - add_input("SampleY", SHADER_SOCKET_FLOAT); - add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL); - add_input("Strength", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Distance", SHADER_SOCKET_FLOAT, 0.1f); + add_input("SampleCenter", SocketType::FLOAT); + add_input("SampleX", SocketType::FLOAT); + add_input("SampleY", SocketType::FLOAT); + add_input("Normal", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL); + add_input("Strength", SocketType::FLOAT, 1.0f); + add_input("Distance", SocketType::FLOAT, 0.1f); - add_output("Normal", SHADER_SOCKET_NORMAL); + add_output("Normal", SocketType::NORMAL); } void BumpNode::compile(SVMCompiler& compiler) @@ -4352,9 +4352,9 @@ bool BumpNode::constant_fold(ShaderGraph *graph, RGBCurvesNode::RGBCurvesNode() : ShaderNode("rgb_curves") { - add_input("Fac", SHADER_SOCKET_FLOAT); - add_input("Color", SHADER_SOCKET_COLOR); - add_output("Color", SHADER_SOCKET_COLOR); + add_input("Fac", SocketType::FLOAT); + add_input("Color", SocketType::COLOR); + add_output("Color", SocketType::COLOR); min_x = 0.0f; max_x = 1.0f; @@ -4397,9 +4397,9 @@ void RGBCurvesNode::compile(OSLCompiler& compiler) VectorCurvesNode::VectorCurvesNode() : ShaderNode("vector_curves") { - add_input("Fac", SHADER_SOCKET_FLOAT); - add_input("Vector", SHADER_SOCKET_VECTOR); - add_output("Vector", SHADER_SOCKET_VECTOR); + add_input("Fac", SocketType::FLOAT); + add_input("Vector", SocketType::VECTOR); + add_output("Vector", SocketType::VECTOR); min_x = 0.0f; max_x = 1.0f; @@ -4442,9 +4442,9 @@ void VectorCurvesNode::compile(OSLCompiler& compiler) RGBRampNode::RGBRampNode() : ShaderNode("rgb_ramp") { - add_input("Fac", SHADER_SOCKET_FLOAT); - add_output("Color", SHADER_SOCKET_COLOR); - add_output("Alpha", SHADER_SOCKET_FLOAT); + add_input("Fac", SocketType::FLOAT); + add_output("Color", SocketType::COLOR); + add_output("Alpha", SocketType::FLOAT); interpolate = true; } @@ -4487,8 +4487,8 @@ void RGBRampNode::compile(OSLCompiler& compiler) SetNormalNode::SetNormalNode() : ShaderNode("set_normal") { - add_input("Direction", SHADER_SOCKET_VECTOR); - add_output("Normal", SHADER_SOCKET_NORMAL); + add_input("Direction", SocketType::VECTOR); + add_output("Normal", SocketType::NORMAL); } void SetNormalNode::compile(SVMCompiler& compiler) @@ -4529,9 +4529,9 @@ void OSLScriptNode::compile(OSLCompiler& compiler) /* Normal Map */ -static ShaderEnum normal_map_space_init() +static NodeEnum normal_map_space_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Tangent", NODE_NORMAL_MAP_TANGENT); enm.insert("Object", NODE_NORMAL_MAP_OBJECT); @@ -4542,7 +4542,7 @@ static ShaderEnum normal_map_space_init() return enm; } -ShaderEnum NormalMapNode::space_enum = normal_map_space_init(); +NodeEnum NormalMapNode::space_enum = normal_map_space_init(); NormalMapNode::NormalMapNode() : ShaderNode("normal_map") @@ -4550,11 +4550,11 @@ NormalMapNode::NormalMapNode() space = ustring("Tangent"); attribute = ustring(""); - add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_input("Strength", SHADER_SOCKET_FLOAT, 1.0f); - add_input("Color", SHADER_SOCKET_COLOR); + add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_input("Strength", SocketType::FLOAT, 1.0f); + add_input("Color", SocketType::COLOR); - add_output("Normal", SHADER_SOCKET_NORMAL); + add_output("Normal", SocketType::NORMAL); } void NormalMapNode::attributes(Shader *shader, AttributeRequestSet *attributes) @@ -4622,9 +4622,9 @@ void NormalMapNode::compile(OSLCompiler& compiler) /* Tangent */ -static ShaderEnum tangent_direction_type_init() +static NodeEnum tangent_direction_type_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("Radial", NODE_TANGENT_RADIAL); enm.insert("UV Map", NODE_TANGENT_UVMAP); @@ -4632,9 +4632,9 @@ static ShaderEnum tangent_direction_type_init() return enm; } -static ShaderEnum tangent_axis_init() +static NodeEnum tangent_axis_init() { - ShaderEnum enm; + NodeEnum enm; enm.insert("X", NODE_TANGENT_AXIS_X); enm.insert("Y", NODE_TANGENT_AXIS_Y); @@ -4643,8 +4643,8 @@ static ShaderEnum tangent_axis_init() return enm; } -ShaderEnum TangentNode::direction_type_enum = tangent_direction_type_init(); -ShaderEnum TangentNode::axis_enum = tangent_axis_init(); +NodeEnum TangentNode::direction_type_enum = tangent_direction_type_init(); +NodeEnum TangentNode::axis_enum = tangent_axis_init(); TangentNode::TangentNode() : ShaderNode("tangent") @@ -4653,8 +4653,8 @@ TangentNode::TangentNode() axis = ustring("X"); attribute = ustring(""); - add_input("NormalIn", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL, ShaderInput::USE_OSL); - add_output("Tangent", SHADER_SOCKET_NORMAL); + add_input("NormalIn", SocketType::NORMAL, make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_NORMAL | SocketType::OSL_INTERNAL); + add_output("Tangent", SocketType::NORMAL); } void TangentNode::attributes(Shader *shader, AttributeRequestSet *attributes) diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index 5df34a84559..7c06efc8e06 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -49,15 +49,15 @@ public: enum Type { POINT = 0, TEXTURE = 1, VECTOR = 2, NORMAL = 3 }; Type type; - static ShaderEnum type_enum; + static NodeEnum type_enum; enum Mapping { NONE = 0, X = 1, Y = 2, Z = 3 }; Mapping x_mapping, y_mapping, z_mapping; - static ShaderEnum mapping_enum; + static NodeEnum mapping_enum; enum Projection { FLAT, CUBE, TUBE, SPHERE }; Projection projection; - static ShaderEnum projection_enum; + static NodeEnum projection_enum; bool equals(const TextureMapping& other) { return translation == other.translation && @@ -116,8 +116,8 @@ public: float projection_blend; bool animated; - static ShaderEnum color_space_enum; - static ShaderEnum projection_enum; + static NodeEnum color_space_enum; + static NodeEnum projection_enum; virtual bool equals(const ShaderNode *other) { const ImageTextureNode *image_node = (const ImageTextureNode*)other; @@ -153,8 +153,8 @@ public: InterpolationType interpolation; bool animated; - static ShaderEnum color_space_enum; - static ShaderEnum projection_enum; + static NodeEnum color_space_enum; + static NodeEnum projection_enum; virtual bool equals(const ShaderNode *other) { const EnvironmentTextureNode *env_node = (const EnvironmentTextureNode*)other; @@ -180,7 +180,7 @@ public: float ground_albedo; ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { const SkyTextureNode *sky_node = (const SkyTextureNode*)other; @@ -207,7 +207,7 @@ public: virtual int get_group() { return NODE_GROUP_LEVEL_2; } ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { const GradientTextureNode *gradient_node = (const GradientTextureNode*)other; @@ -229,7 +229,7 @@ public: ustring coloring; - static ShaderEnum coloring_enum; + static NodeEnum coloring_enum; virtual bool equals(const ShaderNode *other) { const VoronoiTextureNode *voronoi_node = (const VoronoiTextureNode*)other; @@ -246,7 +246,7 @@ public: ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { const MusgraveTextureNode *musgrave_node = (const MusgraveTextureNode*)other; @@ -263,8 +263,8 @@ public: ustring type; ustring profile; - static ShaderEnum type_enum; - static ShaderEnum profile_enum; + static NodeEnum type_enum; + static NodeEnum profile_enum; virtual bool equals(const ShaderNode *other) { const WaveTextureNode *wave_node = (const WaveTextureNode*)other; @@ -335,7 +335,7 @@ public: Transform tfm; - static ShaderEnum space_enum; + static NodeEnum space_enum; virtual bool equals(const ShaderNode *other) { const PointDensityTextureNode *point_dendity_node = (const PointDensityTextureNode*)other; @@ -364,12 +364,12 @@ public: class ConvertNode : public ShaderNode { public: - ConvertNode(ShaderSocketType from, ShaderSocketType to, bool autoconvert = false); + ConvertNode(SocketType::Type from, SocketType::Type to, bool autoconvert = false); SHADER_NODE_BASE_CLASS(ConvertNode) bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, float3 *optimized_value); - ShaderSocketType from, to; + SocketType::Type from, to; virtual bool equals(const ShaderNode *other) { @@ -404,7 +404,7 @@ public: SHADER_NODE_CLASS(AnisotropicBsdfNode) ustring distribution; - static ShaderEnum distribution_enum; + static NodeEnum distribution_enum; void attributes(Shader *shader, AttributeRequestSet *attributes); }; @@ -439,7 +439,7 @@ public: bool has_integrator_dependency(); ustring distribution, distribution_orig; - static ShaderEnum distribution_enum; + static NodeEnum distribution_enum; }; class GlassBsdfNode : public BsdfNode { @@ -450,7 +450,7 @@ public: bool has_integrator_dependency(); ustring distribution, distribution_orig; - static ShaderEnum distribution_enum; + static NodeEnum distribution_enum; }; class RefractionBsdfNode : public BsdfNode { @@ -461,7 +461,7 @@ public: bool has_integrator_dependency(); ustring distribution, distribution_orig; - static ShaderEnum distribution_enum; + static NodeEnum distribution_enum; }; class ToonBsdfNode : public BsdfNode { @@ -469,7 +469,7 @@ public: SHADER_NODE_CLASS(ToonBsdfNode) ustring component; - static ShaderEnum component_enum; + static NodeEnum component_enum; }; class SubsurfaceScatteringNode : public BsdfNode { @@ -478,7 +478,7 @@ public: bool has_surface_bssrdf() { return true; } bool has_bssrdf_bump(); - static ShaderEnum falloff_enum; + static NodeEnum falloff_enum; }; class EmissionNode : public ShaderNode { @@ -548,7 +548,7 @@ public: SHADER_NODE_CLASS(HairBsdfNode) ustring component; - static ShaderEnum component_enum; + static NodeEnum component_enum; }; @@ -698,7 +698,7 @@ public: bool use_clamp; ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { @@ -839,7 +839,7 @@ public: bool use_clamp; ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { @@ -872,7 +872,7 @@ public: bool constant_fold(ShaderGraph *graph, ShaderOutput *socket, float3 *optimized_value); ustring type; - static ShaderEnum type_enum; + static NodeEnum type_enum; virtual bool equals(const ShaderNode *other) { @@ -892,8 +892,8 @@ public: ustring convert_from; ustring convert_to; - static ShaderEnum type_enum; - static ShaderEnum convert_space_enum; + static NodeEnum type_enum; + static NodeEnum convert_space_enum; virtual bool equals(const ShaderNode *other) { const VectorTransformNode *vector_transform_node = (const VectorTransformNode*)other; @@ -980,7 +980,7 @@ public: virtual int get_group() { return NODE_GROUP_LEVEL_3; } ustring space; - static ShaderEnum space_enum; + static NodeEnum space_enum; ustring attribute; @@ -1001,10 +1001,10 @@ public: virtual int get_group() { return NODE_GROUP_LEVEL_3; } ustring direction_type; - static ShaderEnum direction_type_enum; + static NodeEnum direction_type_enum; ustring axis; - static ShaderEnum axis_enum; + static NodeEnum axis_enum; ustring attribute; diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp index 3d14965b4ca..c1112ce44f6 100644 --- a/intern/cycles/render/osl.cpp +++ b/intern/cycles/render/osl.cpp @@ -427,7 +427,7 @@ string OSLCompiler::id(ShaderNode *node) string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input) { - string sname(input->name); + string sname(input->name().string()); size_t i; /* strip whitespace */ @@ -436,7 +436,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input) /* if output exists with the same name, add "In" suffix */ foreach(ShaderOutput *output, node->outputs) { - if(strcmp(input->name, output->name)==0) { + if(input->name() == output->name()) { sname += "In"; break; } @@ -447,7 +447,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderInput *input) string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output) { - string sname(output->name); + string sname(output->name().string()); size_t i; /* strip whitespace */ @@ -456,7 +456,7 @@ string OSLCompiler::compatible_name(ShaderNode *node, ShaderOutput *output) /* if input exists with the same name, add "Out" suffix */ foreach(ShaderInput *input, node->inputs) { - if(strcmp(input->name, output->name)==0) { + if(input->name() == output->name()) { sname += "Out"; break; } @@ -470,21 +470,21 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input) /* exception for output node, only one input is actually used * depending on the current shader type */ - if(!(input->usage & ShaderInput::USE_OSL)) + if(input->flags() & SocketType::SVM_INTERNAL) return true; if(node->special_type == SHADER_SPECIAL_TYPE_OUTPUT) { - if(strcmp(input->name, "Surface") == 0 && current_type != SHADER_TYPE_SURFACE) + if(input->name() == "Surface" && current_type != SHADER_TYPE_SURFACE) return true; - if(strcmp(input->name, "Volume") == 0 && current_type != SHADER_TYPE_VOLUME) + if(input->name() == "Volume" && current_type != SHADER_TYPE_VOLUME) return true; - if(strcmp(input->name, "Displacement") == 0 && current_type != SHADER_TYPE_DISPLACEMENT) + if(input->name() == "Displacement" && current_type != SHADER_TYPE_DISPLACEMENT) return true; - if(strcmp(input->name, "Normal") == 0) + if(input->name() == "Normal") return true; } else if(node->special_type == SHADER_SPECIAL_TYPE_BUMP) { - if(strcmp(input->name, "Height") == 0) + if(input->name() == "Height") return true; } else if(current_type == SHADER_TYPE_DISPLACEMENT && input->link && input->link->parent->special_type == SHADER_SPECIAL_TYPE_BUMP) @@ -512,34 +512,35 @@ void OSLCompiler::add(ShaderNode *node, const char *name, bool isfilepath) if(node_skip_input(node, input)) continue; /* already has default value assigned */ - else if(input->default_value != ShaderInput::NONE) + else if(input->flags() & SocketType::DEFAULT_LINK_MASK) continue; string param_name = compatible_name(node, input); - switch(input->type) { - case SHADER_SOCKET_COLOR: - parameter_color(param_name.c_str(), input->value); + switch(input->type()) { + case SocketType::COLOR: + parameter_color(param_name.c_str(), input->value()); break; - case SHADER_SOCKET_POINT: - parameter_point(param_name.c_str(), input->value); + case SocketType::POINT: + parameter_point(param_name.c_str(), input->value()); break; - case SHADER_SOCKET_VECTOR: - parameter_vector(param_name.c_str(), input->value); + case SocketType::VECTOR: + parameter_vector(param_name.c_str(), input->value()); break; - case SHADER_SOCKET_NORMAL: - parameter_normal(param_name.c_str(), input->value); + case SocketType::NORMAL: + parameter_normal(param_name.c_str(), input->value()); break; - case SHADER_SOCKET_FLOAT: - parameter(param_name.c_str(), input->value.x); + case SocketType::FLOAT: + parameter(param_name.c_str(), input->value_float()); break; - case SHADER_SOCKET_INT: - parameter(param_name.c_str(), (int)input->value.x); + case SocketType::INT: + parameter(param_name.c_str(), (int)input->value_float()); break; - case SHADER_SOCKET_STRING: - parameter(param_name.c_str(), input->value_string); + case SocketType::STRING: + parameter(param_name.c_str(), input->value_string()); break; - case SHADER_SOCKET_CLOSURE: - case SHADER_SOCKET_UNDEFINED: + case SocketType::CLOSURE: + case SocketType::UNDEFINED: + default: break; } } diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp index 635024d7bdf..f03e8e54bcc 100644 --- a/intern/cycles/render/shader.cpp +++ b/intern/cycles/render/shader.cpp @@ -456,7 +456,7 @@ void ShaderManager::add_default(Scene *scene) ShaderGraph *graph = new ShaderGraph(); closure = graph->add(new DiffuseBsdfNode()); - closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f); + closure->input("Color")->value() = make_float3(0.8f, 0.8f, 0.8f); out = graph->output(); graph->connect(closure->output("BSDF"), out->input("Surface")); @@ -473,8 +473,8 @@ void ShaderManager::add_default(Scene *scene) ShaderGraph *graph = new ShaderGraph(); closure = graph->add(new EmissionNode()); - closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f); - closure->input("Strength")->value.x = 0.0f; + closure->input("Color")->value() = make_float3(0.8f, 0.8f, 0.8f); + closure->input("Strength")->value_float() = 0.0f; out = graph->output(); graph->connect(closure->output("Emission"), out->input("Surface")); diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp index 4c97a5ad792..d54afd1ba6f 100644 --- a/intern/cycles/render/svm.cpp +++ b/intern/cycles/render/svm.cpp @@ -120,22 +120,22 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_man compile_failed = false; } -int SVMCompiler::stack_size(ShaderSocketType type) +int SVMCompiler::stack_size(SocketType::Type type) { int size = 0; switch(type) { - case SHADER_SOCKET_FLOAT: - case SHADER_SOCKET_INT: + case SocketType::FLOAT: + case SocketType::INT: size = 1; break; - case SHADER_SOCKET_COLOR: - case SHADER_SOCKET_VECTOR: - case SHADER_SOCKET_NORMAL: - case SHADER_SOCKET_POINT: + case SocketType::COLOR: + case SocketType::VECTOR: + case SocketType::NORMAL: + case SocketType::POINT: size = 3; break; - case SHADER_SOCKET_CLOSURE: + case SocketType::CLOSURE: size = 0; break; default: @@ -146,7 +146,7 @@ int SVMCompiler::stack_size(ShaderSocketType type) return size; } -int SVMCompiler::stack_find_offset(ShaderSocketType type) +int SVMCompiler::stack_find_offset(SocketType::Type type) { int size = stack_size(type); int offset = -1; @@ -175,7 +175,7 @@ int SVMCompiler::stack_find_offset(ShaderSocketType type) return 0; } -void SVMCompiler::stack_clear_offset(ShaderSocketType type, int offset) +void SVMCompiler::stack_clear_offset(SocketType::Type type, int offset) { int size = stack_size(type); @@ -193,22 +193,22 @@ int SVMCompiler::stack_assign(ShaderInput *input) } else { /* not linked to output -> add nodes to load default value */ - input->stack_offset = stack_find_offset(input->type); + input->stack_offset = stack_find_offset(input->type()); - if(input->type == SHADER_SOCKET_FLOAT) { - add_node(NODE_VALUE_F, __float_as_int(input->value.x), input->stack_offset); + if(input->type() == SocketType::FLOAT) { + add_node(NODE_VALUE_F, __float_as_int(input->value_float()), input->stack_offset); } - else if(input->type == SHADER_SOCKET_INT) { - add_node(NODE_VALUE_F, (int)input->value.x, input->stack_offset); + else if(input->type() == SocketType::INT) { + add_node(NODE_VALUE_F, (int)input->value_float(), input->stack_offset); } - else if(input->type == SHADER_SOCKET_VECTOR || - input->type == SHADER_SOCKET_NORMAL || - input->type == SHADER_SOCKET_POINT || - input->type == SHADER_SOCKET_COLOR) + else if(input->type() == SocketType::VECTOR || + input->type() == SocketType::NORMAL || + input->type() == SocketType::POINT || + input->type() == SocketType::COLOR) { add_node(NODE_VALUE_V, input->stack_offset); - add_node(NODE_VALUE_V, input->value); + add_node(NODE_VALUE_V, input->value()); } else /* should not get called for closure */ assert(0); @@ -222,7 +222,7 @@ int SVMCompiler::stack_assign(ShaderOutput *output) { /* if no stack offset assigned yet, find one */ if(output->stack_offset == SVM_STACK_INVALID) - output->stack_offset = stack_find_offset(output->type); + output->stack_offset = stack_find_offset(output->type()); return output->stack_offset; } @@ -247,11 +247,11 @@ void SVMCompiler::stack_link(ShaderInput *input, ShaderOutput *output) { if(output->stack_offset == SVM_STACK_INVALID) { assert(input->link); - assert(stack_size(output->type) == stack_size(input->link->type)); + assert(stack_size(output->type()) == stack_size(input->link->type())); output->stack_offset = input->link->stack_offset; - int size = stack_size(output->type); + int size = stack_size(output->type()); for(int i = 0; i < size; i++) active_stack.users[output->stack_offset + i]++; @@ -279,7 +279,7 @@ void SVMCompiler::stack_clear_users(ShaderNode *node, ShaderNodeSet& done) all_done = false; if(all_done) { - stack_clear_offset(output->type, output->stack_offset); + stack_clear_offset(output->type(), output->stack_offset); output->stack_offset = SVM_STACK_INVALID; foreach(ShaderInput *in, output->links) @@ -293,7 +293,7 @@ void SVMCompiler::stack_clear_temporary(ShaderNode *node) { foreach(ShaderInput *input, node->inputs) { if(!input->link && input->stack_offset != SVM_STACK_INVALID) { - stack_clear_offset(input->type, input->stack_offset); + stack_clear_offset(input->type(), input->stack_offset); input->stack_offset = SVM_STACK_INVALID; } } @@ -446,7 +446,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.x != 1.0f)) + if(weight_in && (weight_in->link || weight_in->value_float() != 1.0f)) mix_weight_offset = stack_assign(weight_in); else mix_weight_offset = SVM_STACK_INVALID; @@ -479,7 +479,7 @@ void SVMCompiler::generated_shared_closure_nodes(ShaderNode *root_node, } else { foreach(ShaderInput *in, node->inputs) { - if(in->type == SHADER_SOCKET_CLOSURE && in->link) + if(in->type() == SocketType::CLOSURE && in->link) generated_shared_closure_nodes(root_node, in->link->parent, state, diff --git a/intern/cycles/render/svm.h b/intern/cycles/render/svm.h index dbf1b1de947..e14d57d7601 100644 --- a/intern/cycles/render/svm.h +++ b/intern/cycles/render/svm.h @@ -99,8 +99,8 @@ public: int stack_assign(ShaderInput *input); int stack_assign_if_linked(ShaderInput *input); int stack_assign_if_linked(ShaderOutput *output); - int stack_find_offset(ShaderSocketType type); - void stack_clear_offset(ShaderSocketType type, int offset); + int stack_find_offset(SocketType::Type type); + void stack_clear_offset(SocketType::Type type, int offset); void stack_link(ShaderInput *input, ShaderOutput *output); void add_node(ShaderNodeType type, int a = 0, int b = 0, int c = 0); @@ -172,7 +172,7 @@ protected: }; void stack_clear_temporary(ShaderNode *node); - int stack_size(ShaderSocketType type); + int stack_size(SocketType::Type type); void stack_clear_users(ShaderNode *node, ShaderNodeSet& done); bool node_skip_input(ShaderNode *node, ShaderInput *input); |