Jump to content

Simple (I hope) Procedural UV question


Recommended Posts

So I have a circle I am sweeping along a curve, and I am assigning UVs to points with a simple attribWrangle with

f@u = float(@ptnum)/float(@numpt-1); 

 on the circle and

f@v = float(@ptnum)/float(@numpt-1)

on the curve and then a

v@uv.x = @u;
v@uv.y = @v;

and this works great except for the seam 1>0. Obviously I want to be using vertex attributes for UVs, and when I throw a UVProject on a tube I see that verts are indexed by prim # then vert #. How could I go about assigning UVs in a similarly simple matter but to vertices where for example my 0:0 vertex @uv.x = 1.0 and 7:1 @uv.x = 0.0, which are both point 0? Am I doing it wrong?

 

Thanks!

Edited by stevegh
Link to comment
Share on other sites

use "vtxnum" instead of "ptnum" (and iterate over vertices and not points in your attribWrangle).

 

edit: hmm... rethinking this.

 

edit again: okay, well, "vtxnum" and "numvtx" would work for a single primitive, but i dunno a good way if you have multiple prims using vex.

Edited by fathom
Link to comment
Share on other sites

Heh, yea I just ended up doing it in a python SOP in a very non pythonic way. Set xsec and ysec on the cross section and backbone of the sweep, attribTransfer the ysec over to the result and chuck this in a python SOP:

node = hou.pwd()
geo = node.geometry()

xsec = geo.attribValue("xsec")
ysec = geo.attribValue("ysec")

for y in range(ysec-1):
    for x in range(xsec):
        prim = x + (y*(xsec))
        xinc = 1.0 / (xsec)
        yinc = 1.0 / (ysec-1)
        geo.globPrims(str(prim))[0].vertices()[0].setAttribValue("uv", (x*xinc, y*yinc, 0))
        geo.globPrims(str(prim))[0].vertices()[1].setAttribValue("uv", ((x+1)*xinc, y*yinc, 0))
        geo.globPrims(str(prim))[0].vertices()[2].setAttribValue("uv", ((x+1)*xinc, (y+1)*yinc, 0))
        geo.globPrims(str(prim))[0].vertices()[3].setAttribValue("uv", (x*xinc, (y+1)*yinc, 0))

Not pretty but works for me. Thanks anyways!

Link to comment
Share on other sites

Another workaround you can do is

  1. Unroll the circle before sweeping using the ends node.
  2. Then after applying your uv's you can promote the uv point attribute to a uv vertex attribute using the attribute promote node
  3. then fuse the points together.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...