Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/nodes.cpp
| Show First 20 Lines • Show All 907 Lines • ▼ Show 20 Lines | NODE_DEFINE(VoronoiTextureNode) | ||||
| TEXTURE_MAPPING_DEFINE(VoronoiTextureNode); | TEXTURE_MAPPING_DEFINE(VoronoiTextureNode); | ||||
| static NodeEnum coloring_enum; | static NodeEnum coloring_enum; | ||||
| coloring_enum.insert("intensity", NODE_VORONOI_INTENSITY); | coloring_enum.insert("intensity", NODE_VORONOI_INTENSITY); | ||||
| coloring_enum.insert("cells", NODE_VORONOI_CELLS); | coloring_enum.insert("cells", NODE_VORONOI_CELLS); | ||||
| SOCKET_ENUM(coloring, "Coloring", coloring_enum, NODE_VORONOI_INTENSITY); | SOCKET_ENUM(coloring, "Coloring", coloring_enum, NODE_VORONOI_INTENSITY); | ||||
| static NodeEnum metric; | |||||
| metric.insert("distance", NODE_VORONOI_DISTANCE); | |||||
| metric.insert("manhattan", NODE_VORONOI_MANHATTAN); | |||||
| metric.insert("chebychev", NODE_VORONOI_CHEBYCHEV); | |||||
| metric.insert("minkowski", NODE_VORONOI_MINKOWSKI); | |||||
| SOCKET_ENUM(metric, "Distance Metric", metric, NODE_VORONOI_INTENSITY); | |||||
| static NodeEnum feature_enum; | |||||
| feature_enum.insert("F1", NODE_VORONOI_F1); | |||||
| feature_enum.insert("F2", NODE_VORONOI_F2); | |||||
| feature_enum.insert("F3", NODE_VORONOI_F3); | |||||
| feature_enum.insert("F4", NODE_VORONOI_F4); | |||||
| feature_enum.insert("F2F1", NODE_VORONOI_F2F1); | |||||
| SOCKET_ENUM(feature, "Feature", feature_enum, NODE_VORONOI_INTENSITY); | |||||
| SOCKET_IN_FLOAT(scale, "Scale", 1.0f); | SOCKET_IN_FLOAT(scale, "Scale", 1.0f); | ||||
| SOCKET_IN_FLOAT(exponent, "Exponent", 0.5f); | |||||
| SOCKET_IN_POINT(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); | SOCKET_IN_POINT(vector, "Vector", make_float3(0.0f, 0.0f, 0.0f), SocketType::LINK_TEXTURE_GENERATED); | ||||
| SOCKET_OUT_COLOR(color, "Color"); | SOCKET_OUT_COLOR(color, "Color"); | ||||
| SOCKET_OUT_FLOAT(fac, "Fac"); | SOCKET_OUT_FLOAT(fac, "Fac"); | ||||
| return type; | return type; | ||||
| } | } | ||||
| VoronoiTextureNode::VoronoiTextureNode() | VoronoiTextureNode::VoronoiTextureNode() | ||||
| : TextureNode(node_type) | : TextureNode(node_type) | ||||
| { | { | ||||
| } | } | ||||
| void VoronoiTextureNode::compile(SVMCompiler& compiler) | void VoronoiTextureNode::compile(SVMCompiler& compiler) | ||||
| { | { | ||||
| ShaderInput *scale_in = input("Scale"); | ShaderInput *scale_in = input("Scale"); | ||||
| ShaderInput *vector_in = input("Vector"); | ShaderInput *vector_in = input("Vector"); | ||||
| ShaderInput *exponent_in = input("Exponent"); | |||||
| ShaderOutput *color_out = output("Color"); | ShaderOutput *color_out = output("Color"); | ||||
| ShaderOutput *fac_out = output("Fac"); | ShaderOutput *fac_out = output("Fac"); | ||||
| if (vector_in->link) compiler.stack_assign(vector_in); | |||||
| if (scale_in->link) compiler.stack_assign(scale_in); | |||||
| if (exponent_in->link) compiler.stack_assign(exponent_in); | |||||
| int vector_offset = tex_mapping.compile_begin(compiler, vector_in); | int vector_offset = tex_mapping.compile_begin(compiler, vector_in); | ||||
| compiler.add_node(NODE_TEX_VORONOI, | compiler.add_node(NODE_TEX_VORONOI, | ||||
| compiler.encode_uchar4( | |||||
| vector_offset, | |||||
| coloring, | coloring, | ||||
| metric, | |||||
| feature | |||||
| ), | |||||
| compiler.encode_uchar4( | compiler.encode_uchar4( | ||||
| compiler.stack_assign_if_linked(scale_in), | compiler.stack_assign_if_linked(scale_in), | ||||
| vector_offset, | compiler.stack_assign_if_linked(exponent_in), | ||||
| compiler.stack_assign(fac_out), | compiler.stack_assign(fac_out), | ||||
| compiler.stack_assign(color_out)), | compiler.stack_assign(color_out) | ||||
| __float_as_int(scale)); | )); | ||||
| compiler.add_node( | |||||
| __float_as_int(scale), | |||||
| __float_as_int(exponent)); | |||||
| tex_mapping.compile_end(compiler, vector_in, vector_offset); | tex_mapping.compile_end(compiler, vector_in, vector_offset); | ||||
| } | } | ||||
| void VoronoiTextureNode::compile(OSLCompiler& compiler) | void VoronoiTextureNode::compile(OSLCompiler& compiler) | ||||
| { | { | ||||
| tex_mapping.compile(compiler); | tex_mapping.compile(compiler); | ||||
| compiler.parameter(this, "coloring"); | compiler.parameter(this, "coloring"); | ||||
| compiler.parameter(this, "metric"); | |||||
| compiler.parameter(this, "feature"); | |||||
| compiler.add(this, "node_voronoi_texture"); | compiler.add(this, "node_voronoi_texture"); | ||||
| } | } | ||||
| /* IES Light */ | /* IES Light */ | ||||
| NODE_DEFINE(IESLightNode) | NODE_DEFINE(IESLightNode) | ||||
| { | { | ||||
| NodeType* type = NodeType::add("ies_light", create, NodeType::SHADER); | NodeType* type = NodeType::add("ies_light", create, NodeType::SHADER); | ||||
| ▲ Show 20 Lines • Show All 5,081 Lines • Show Last 20 Lines | |||||