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

Gareth Morgan garethmorgan1977 at gmail.com
Fri Nov 24 18:04:53 CET 2017


Thanks for that definitely improves things, but still very broken
(screenshot attached). Any other thoughts on what issue could be?

I assume the TypeDesc::TypePoint means the attribute data should be 2D?
(I've tried both ways and it's still broken):
ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ustring("UVMap"),
ccl::TypeDesc::TypePoint, ccl::ATTR_ELEMENT_VERTEX);
attr_vUV->std = ccl::ATTR_STD_UV;
float *fUV = attr_vUV->data_float();

for (int i = 0; i < verts_size; i++)
{
fUV[i * 2 + 0] = UVs[i * 2 + 0];
fUV[i * 2 + 1] = UVs[i * 2 + 1];
}


On Thu, Nov 23, 2017 at 6:00 AM, <bf-cycles-request at blender.org> wrote:

>
> Date: Thu, 23 Nov 2017 01:29:19 +0100
> From: Brecht Van Lommel <brechtvanlommel at pandora.be>
> To: Discussion list to assist Cycles render engine developers
>         <bf-cycles at blender.org>
> Subject: Re: [Bf-cycles] Correct way to set-up UV channel for a
>         texture?
> Message-ID:
>         <CAKFUgC1XUvksWyE2ZCheJDJemhKCw8iok14a05TXE75ejrZzhw at mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> 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-0001.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> Bf-cycles mailing list
> Bf-cycles at blender.org
> https://lists.blender.org/mailman/listinfo/bf-cycles
>
>
> ------------------------------
>
> End of Bf-cycles Digest, Vol 89, Issue 1
> ****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20171124/e2d233cd/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.png
Type: image/png
Size: 5343 bytes
Desc: not available
URL: <http://lists.blender.org/pipermail/bf-cycles/attachments/20171124/e2d233cd/attachment.png>


More information about the Bf-cycles mailing list