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

F Escobar materialesescobar at hotmail.es
Tue Feb 13 14:25:13 CET 2018

Thank you it worked like a charm!

I'm driving nuts with other issue now

I've created my UVs with

ccl::Attribute *attr_uv = mesh->attributes.add(ccl::ATTR_STD_UV, ccl::ustring("UV"));
ccl::float3 *attr_data_uv = attr_uv->data_float3();

Filled attr_data_uv and so, but I cannot see the checker only one plain color, same issue if I use a ImageTextureNode even if I set Tex->projection = ccl::NodeImageProjection::NODE_IMAGE_PROJ_BOX;

Any tip on this?
De: Bf-cycles <bf-cycles-bounces at blender.org> en nombre de Brecht Van Lommel <brechtvanlommel at pandora.be>
Enviado: jueves, 8 de febrero de 2018 15:34
Para: Discussion list to assist Cycles render engine developers
Asunto: Re: [Bf-cycles] Any sample on creating basic materials from scratch?


We don't have any example code for this specifically. It's easiest to create node with the corresponding class directly.

CheckerTextureNode *checker = new CheckerTextureNode();
checker->color1 = make_float3(1.0f, 0.0f, 0.0f);
checker->color2 = make_float3(0.0f, 0.0f, 1.0f);
checker->scale = 1.0f;

If you want to use the generic API, don't create your own SocketType, look it up in the node.

const SocketType *color1 = snode->find_input(ustring("color1"));
snode->set(*color1, make_float3(1.0f, 0.0f, 0.0f));


On Thu, Feb 8, 2018 at 2:13 PM, F Escobar <materialesescobar at hotmail.es<mailto:materialesescobar at hotmail.es>> wrote:
I tried with this:

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

if (scene != NULL)

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<http://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<http://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<http://scale.name> = ccl::ustring("scale");
snode->set(scale, 1.0f);


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

Thank you in advance.

Bf-cycles mailing list
Bf-cycles at blender.org<mailto:Bf-cycles at blender.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20180213/12fc3e7f/attachment.html>

More information about the Bf-cycles mailing list