<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Thank you it worked like a charm!</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
I'm driving nuts with other issue now <br>
<br>
I've created my UVs with<br>
<div><br>
</div>
<div><span style="white-space:pre"></span>ccl::Attribute *attr_uv = mesh->attributes.add(ccl::ATTR_STD_UV, ccl::ustring("UV"));</div>
<div><span style="white-space:pre"></span>ccl::float3 *attr_data_uv = attr_uv->data_float3();</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
Filled <span style="color: rgb(0, 0, 0); font-family: Calibri, Helvetica, sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400;">attr_data_uv</span> 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;</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgba(0, 0, 0, 0);">
Any tip on this?</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>De:</b> Bf-cycles <bf-cycles-bounces@blender.org> en nombre de Brecht Van Lommel <brechtvanlommel@pandora.be><br>
<b>Enviado:</b> jueves, 8 de febrero de 2018 15:34<br>
<b>Para:</b> Discussion list to assist Cycles render engine developers<br>
<b>Asunto:</b> Re: [Bf-cycles] Any sample on creating basic materials from scratch?</font>
<div> </div>
</div>
<div>
<div dir="ltr">Hi,
<div><br>
</div>
<div>We don't have any example code for this specifically. It's easiest to create node with the corresponding class directly.
<div><br>
</div>
<font face="monospace, monospace">CheckerTextureNode *checker = new CheckerTextureNode();<br>
checker->color1 = make_float3(1.0f, 0.0f, 0.0f);<br>
checker->color2 = make_float3(0.0f, 0.0f, 1.0f);<br>
checker->scale = 1.0f;<br>
graph->add(checker);<br>
shader->set_graph(graph);</font>
<div><br>
</div>
<div>If you want to use the generic API, don't create your own <font face="monospace, monospace">
SocketType</font>, look it up in the node.</div>
<div><br>
</div>
<div><font face="monospace, monospace">const SocketType *color1 = snode->find_input(ustring("color1"));</font></div>
<div><font face="monospace, monospace">snode->set(*color1, make_float3(1.0f, 0.0f, 0.0f));</font></div>
<div><br>
Regards,</div>
<div>Brecht.</div>
<div><br>
</div>
</div>
</div>
<div class="x_gmail_extra"><br>
<div class="x_gmail_quote">On Thu, Feb 8, 2018 at 2:13 PM, F Escobar <span dir="ltr">
<<a href="mailto:materialesescobar@hotmail.es" target="_blank">materialesescobar@hotmail.es</a>></span> wrote:<br>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
<div><span style="background-color:rgba(0,0,0,0)">I tried with this:</span><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>ccl::Shader *shader = new ccl::Shader();</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>if (scene != NULL)</div>
<div><span style="white-space:pre-wrap"></span>scene->shaders.push_back(<wbr>shader);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>shader->name=ccl::ustring(<wbr>material->mName);</div>
<div><span style="white-space:pre-wrap"></span>ccl::ShaderGraph *graph = new ccl::ShaderGraph();</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>const ccl::NodeType *node_type = ccl::NodeType::find(ccl::<wbr>ustring("checker_texture"));</div>
<div><span style="white-space:pre-wrap"></span>if (!node_type) {</div>
<div><span style="white-space:pre-wrap"></span>fprintf(stderr, "Unknown shader node \n");</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><span style="white-space:pre-wrap"></span>else if (node_type->type != ccl::NodeType::SHADER) {</div>
<div><span style="white-space:pre-wrap"></span>fprintf(stderr, "Node type \"%s\" is not a shader node.\n", node_type->name.c_str());</div>
<div><span style="white-space:pre-wrap"></span>}</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>ccl::ShaderNode* snode = (ccl::ShaderNode*)node_type-><wbr>create(node_type);</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>ccl::SocketType color1;</div>
<div><span style="white-space:pre-wrap"></span>color1.type = ccl::SocketType::COLOR;</div>
<div><span style="white-space:pre-wrap"></span><a href="http://color1.name" target="_blank">color1.name</a> = ccl::ustring("color1");</div>
<div><span style="white-space:pre-wrap"></span>snode->set(color1, ccl::make_float3(1.0f, 0.0f, 0.0f));</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>ccl::SocketType color2;</div>
<div><span style="white-space:pre-wrap"></span>color2.type = ccl::SocketType::COLOR;</div>
<div><span style="white-space:pre-wrap"></span><a href="http://color2.name" target="_blank">color2.name</a> = ccl::ustring("color2");</div>
<div><span style="white-space:pre-wrap"></span>snode->set(color2, ccl::make_float3(0.0f, 0.0f, 1.0f));</div>
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>ccl::SocketType scale;</div>
<div><span style="white-space:pre-wrap"></span>scale.type = ccl::SocketType::FLOAT;</div>
<div><span style="white-space:pre-wrap"></span><a href="http://scale.name" target="_blank">scale.name</a> = ccl::ustring("scale");</div>
<div><span style="white-space:pre-wrap"></span>snode->set(scale, 1.0f);
<div><br>
</div>
<div><span style="white-space:pre-wrap"></span>graph->add(snode);</div>
<div><span style="white-space:pre-wrap"></span>shader->set_graph(graph);</div>
</div>
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
But I had crashes creating color2 probably I'm doing it wrongly, is there any sample on this?</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0); background-color:rgba(0,0,0,0)">
Thank you in advance.</div>
</div>
<br>
______________________________<wbr>_________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/<wbr>mailman/listinfo/bf-cycles</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</body>
</html>