[Bf-cycles] Correct way to set-up UV channel for a texture?

Gareth Morgan garethmorgan1977 at gmail.com
Wed Nov 22 23:00:31 CET 2017

So I am setting up a shader that reads from an ImageTextureNode in Cycles:
ccl::CheckerTextureNode *img = new ccl::CheckerTextureNode();
img->input("Color1")->set(ccl::make_float3(0.0, 0.8, 0.0));
img->input("Color2")->set(ccl::make_float3(0.0, 0.2, 1.0));

I have added my UVs to the mesh like this (I have verified my UVs are

ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ATTR_STD_UV,
ccl::float3 *fUV = attr_vUV->data_float3();
for (int i = 0; i < verts_size; i++)
fUV[i].x = UVs[i * 2 + 0];
fUV[i].y = UVs[i * 2 + 1];
fUV[i].z = 0.0f;

I then add UVMap node to the graph like this:
ccl::UVMapNode *uvm = new ccl::UVMapNode();
uvm->attribute = ccl::ustring("UVMap");
And connect it to the rest of the shader like this:
graph->connect(uvm->output("UV"), img->input("Vector"));
graph->connect(img->output("Color"), diffuseBrdfNode->input("Color"));

I've tried various different variants of this (assuming 2D UVs, not setting
the UVMapNode attribute, etc) the result is always very broken image (see
simple rectangle example attached).

Is there a step I am missing to correctly setting up the UVs?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20171122/632aeee6/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 2753 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20171122/632aeee6/attachment.png>

More information about the Bf-cycles mailing list