<div dir="ltr"><div>Thanks for that definitely improves things, but still very broken (screenshot attached). Any other thoughts on what issue could be?</div><div><br></div><div>I assume the TypeDesc::TypePoint means the attribute data should be 2D? (I've tried both ways and it's still broken):</div><div><span style="white-space:pre">         </span>ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ustring("UVMap"), ccl::TypeDesc::TypePoint, ccl::ATTR_ELEMENT_VERTEX);</div><div><span style="white-space:pre">              </span>attr_vUV->std = ccl::ATTR_STD_UV;</div><div><span style="white-space:pre">          </span>float *fUV = attr_vUV->data_float();</div><div><br></div><div><span style="white-space:pre">              </span>for (int i = 0; i < verts_size; i++)</div><div><span style="white-space:pre">               </span>{</div><div><span style="white-space:pre">                     </span>fUV[i * 2 + 0] = UVs[i * 2 + 0];</div><div><span style="white-space:pre">                      </span>fUV[i * 2 + 1] = UVs[i * 2 + 1];</div><div><span style="white-space:pre">              </span>}</div><div class="gmail_extra"><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 23, 2017 at 6:00 AM,  <span dir="ltr"><<a href="mailto:bf-cycles-request@blender.org" target="_blank">bf-cycles-request@blender.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
Date: Thu, 23 Nov 2017 01:29:19 +0100<br>
From: Brecht Van Lommel <<a href="mailto:brechtvanlommel@pandora.be">brechtvanlommel@pandora.be</a>><br>
To: Discussion list to assist Cycles render engine developers<br>
        <<a href="mailto:bf-cycles@blender.org">bf-cycles@blender.org</a>><br>
Subject: Re: [Bf-cycles] Correct way to set-up UV channel for a<br>
        texture?<br>
Message-ID:<br>
        <<a href="mailto:CAKFUgC1XUvksWyE2ZCheJDJemhKCw8iok14a05TXE75ejrZzhw@mail.gmail.com">CAKFUgC1XUvksWyE2ZCheJDJemhKC<wbr>w8iok14a05TXE75ejrZzhw@mail.<wbr>gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Hi,<br>
<br>
With ATTR_STD_UV the UVs are created per face corner by default, I guess<br>
you need them per vertex?<br>
<br>
Something like this should work:<br>
<br>
ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::<wbr>ustring("UVMap"),<br>
ccl::TypeDesc::TypePoint, ATTR_ELEMENT_VERTEX);<br>
attr_vUV->std = ccl::ATTR_STD_UV;<br>
<br>
Regards,<br>
Brecht.<br>
<br>
On Wed, Nov 22, 2017 at 11:00 PM, Gareth Morgan <<a href="mailto:garethmorgan1977@gmail.com">garethmorgan1977@gmail.com</a>><br>
wrote:<br>
<br>
> So I am setting up a shader that reads from an ImageTextureNode in Cycles:<br>
> ccl::CheckerTextureNode *img = new ccl::CheckerTextureNode();<br>
> img->input("Color1")->set(ccl:<wbr>:make_float3(0.0, 0.8, 0.0));<br>
> img->input("Color2")->set(ccl:<wbr>:make_float3(0.0, 0.2, 1.0));<br>
> img->input("Scale")->set(2.0f)<wbr>;<br>
><br>
> I have added my UVs to the mesh like this (I have verified my UVs are<br>
> correct):<br>
><br>
> ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::<wbr>ATTR_STD_UV,<br>
> ccl::ustring("UVMap"));<br>
> ccl::float3 *fUV = attr_vUV->data_float3();<br>
> for (int i = 0; i < verts_size; i++)<br>
> {<br>
> fUV[i].x = UVs[i * 2 + 0];<br>
> fUV[i].y = UVs[i * 2 + 1];<br>
> fUV[i].z = 0.0f;<br>
> }<br>
><br>
><br>
> I then add UVMap node to the graph like this:<br>
> ccl::UVMapNode *uvm = new ccl::UVMapNode();<br>
> uvm->attribute = ccl::ustring("UVMap");<br>
> graph->add(uvm);<br>
> And connect it to the rest of the shader like this:<br>
> graph->connect(uvm->output("<wbr>UV"), img->input("Vector"));<br>
> graph->connect(img->output("<wbr>Color"), diffuseBrdfNode->input("Color"<wbr>));<br>
><br>
> I've tried various different variants of this (assuming 2D UVs, not<br>
> setting the UVMapNode attribute, etc) the result is always very broken<br>
> image (see simple rectangle example attached).<br>
><br>
> Is there a step I am missing to correctly setting up the UVs?<br>
><br>
><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>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://lists.blender.org/pipermail/bf-cycles/attachments/20171123/0fe6b862/attachment-0001.html" rel="noreferrer" target="_blank">http://lists.blender.org/<wbr>pipermail/bf-cycles/<wbr>attachments/20171123/0fe6b862/<wbr>attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<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>
<br>
------------------------------<br>
<br>
End of Bf-cycles Digest, Vol 89, Issue 1<br>
******************************<wbr>**********<br>
</blockquote></div><br></div></div>