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

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Nov 23 01:29:19 CET 2017


Hi,

With ATTR_STD_UV the UVs are created per face corner by default, I guess
you need them per vertex?

Something like this should work:

ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ustring("UVMap"),
ccl::TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX);
attr_vUV->std = ccl::ATTR_STD_UV;

Regards,
Brecht.

On Wed, Nov 22, 2017 at 11:00 PM, Gareth Morgan <garethmorgan1977 at gmail.com>
wrote:

> 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));
> img->input("Scale")->set(2.0f);
>
> I have added my UVs to the mesh like this (I have verified my UVs are
> correct):
>
> ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ATTR_STD_UV,
> ccl::ustring("UVMap"));
> 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");
> graph->add(uvm);
> 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?
>
>
> _______________________________________________
> Bf-cycles mailing list
> Bf-cycles at blender.org
> https://lists.blender.org/mailman/listinfo/bf-cycles
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20171123/0fe6b862/attachment.html>


More information about the Bf-cycles mailing list