<div dir="ltr">Hi,<div><br></div><div>With <span style="font-size:12.8px"><font face="monospace, monospace">ATTR_STD_UV</font> the UVs are created per face corner by default, I guess you need them per vertex?</span></div><div><br></div><div><span style="font-size:12.8px">Something like this should work:</span></div><div><br></div><div><div style="font-size:12.8px"><font face="monospace, monospace">ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::<wbr>ustring("UVMap"), ccl::TypeDesc::TypePoint, <wbr>ATTR_ELEMENT_VERTEX);</font></div></div><div style="font-size:12.8px"><font face="monospace, monospace">attr_vUV->std = <span style="font-size:12.8px">ccl::</span><span style="font-size:12.8px">ATTR_STD_UV;</span></font></div><div><br></div><div>Regards,</div><div>Brecht.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 22, 2017 at 11:00 PM, Gareth Morgan <span dir="ltr"><<a href="mailto:garethmorgan1977@gmail.com" target="_blank">garethmorgan1977@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>So I am setting up a shader that reads from an ImageTextureNode in Cycles:</div><div><span style="white-space:pre-wrap">             </span>ccl::CheckerTextureNode *img = new ccl::CheckerTextureNode();</div><div><span style="white-space:pre-wrap">            </span>img->input("Color1")->set(ccl:<wbr>:make_float3(0.0, 0.8, 0.0));</div><div><span style="white-space:pre-wrap">           </span>img->input("Color2")->set(ccl:<wbr>:make_float3(0.0, 0.2, 1.0));</div><div><span style="white-space:pre-wrap">           </span>img->input("Scale")->set(2.0f)<wbr>;</div><div><br></div><div>I have added my UVs to the mesh like this (I have verified my UVs are correct):</div><div><br></div><div><span style="white-space:pre-wrap">               </span>ccl::Attribute *attr_vUV = mesh->attributes.add(ccl::ATTR<wbr>_STD_UV, ccl::ustring("UVMap"));</div><div><span style="white-space:pre-wrap">                </span>ccl::float3 *fUV = attr_vUV->data_float3();</div><div><span style="white-space:pre-wrap">           </span>for (int i = 0; i < verts_size; i++)</div><div><span style="white-space:pre-wrap">          </span>{</div><div><span style="white-space:pre-wrap">                        </span>fUV[i].x = UVs[i * 2 + 0];</div><div><span style="white-space:pre-wrap">                       </span>fUV[i].y = UVs[i * 2 + 1];</div><div><span style="white-space:pre-wrap">                       </span>fUV[i].z = 0.0f;</div><div><span style="white-space:pre-wrap">         </span>}</div><div><br></div><div><br></div><div>I then add UVMap node to the graph like this:</div><div><span style="white-space:pre-wrap">          </span>ccl::UVMapNode *uvm = new ccl::UVMapNode();</div><div><span style="white-space:pre-wrap">              </span>uvm->attribute = ccl::ustring("UVMap");</div><div><span style="white-space:pre-wrap">             </span>graph->add(uvm);</div><div><span style="white-space:pre-wrap">              </span></div><div>And connect it to the rest of the shader like this:</div><div><span style="white-space:pre-wrap">               </span>graph->connect(uvm->output("UV<wbr>"), img->input("Vector"));</div><div><span style="white-space:pre-wrap">         </span>graph->connect(img->output("Co<wbr>lor"), diffuseBrdfNode->input("Color"<wbr>));</div><div><br></div><div>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).</div><div><br></div><div>Is there a step I am missing to correctly setting up the UVs?</div></div></div><div><br></div></div>
<br>______________________________<wbr>_________________<br>
Bf-cycles mailing list<br>
<a href="mailto:Bf-cycles@blender.org" target="_blank">Bf-cycles@blender.org</a><br>
<a href="https://lists.blender.org/mailman/listinfo/bf-cycles" rel="noreferrer" target="_blank">https://lists.blender.org/mail<wbr>man/listinfo/bf-cycles</a><br>
<br></blockquote></div><br></div></div>