[Bf-cycles] Any sample on creating basic materials from scratch?

F Escobar materialesescobar at hotmail.es
Thu Feb 8 14:13:56 CET 2018


I tried with this:



ccl::Shader *shader = new ccl::Shader();

if (scene != NULL)
scene->shaders.push_back(shader);

shader->name=ccl::ustring(material->mName);
ccl::ShaderGraph *graph = new ccl::ShaderGraph();

const ccl::NodeType *node_type = ccl::NodeType::find(ccl::ustring("checker_texture"));
if (!node_type) {
fprintf(stderr, "Unknown shader node \n");
}
else if (node_type->type != ccl::NodeType::SHADER) {
fprintf(stderr, "Node type \"%s\" is not a shader node.\n", node_type->name.c_str());
}

ccl::ShaderNode* snode = (ccl::ShaderNode*)node_type->create(node_type);

ccl::SocketType color1;
color1.type = ccl::SocketType::COLOR;
color1.name = ccl::ustring("color1");
snode->set(color1, ccl::make_float3(1.0f, 0.0f, 0.0f));

ccl::SocketType color2;
color2.type = ccl::SocketType::COLOR;
color2.name = ccl::ustring("color2");
snode->set(color2, ccl::make_float3(0.0f, 0.0f, 1.0f));

ccl::SocketType scale;
scale.type = ccl::SocketType::FLOAT;
scale.name = ccl::ustring("scale");
snode->set(scale, 1.0f);

graph->add(snode);
shader->set_graph(graph);


But I had crashes creating color2 probably I'm doing it wrongly, is there any sample on this?


Thank you in advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20180208/9e59b7a1/attachment.html>


More information about the Bf-cycles mailing list