Jump to content

[SOLVED]Drive UV Scale Parameter With An Attribute?

Recommended Posts

Hi All,


I realize this is a simple question but I just can't figure it out.


I have an attribute called "uv_xscale" that is being generated but a PointWrangle. This makes it a point based attribute.

Later down stream I have a UV Texture node that I want to drive with that value.


What do I type in the Scale (su) U parameter to link that field with the value in the attribute?


I have tried $ with capitial letters $UV_XSCALE but that does not work.

I have tried ch("uv_scale") but that does not work either.


What is the HScript code for referencing variables in a field? 

Edited by Atom
Link to comment
Share on other sites

I did come across a reference to the point function but I am having trouble configuring it for my object. I am attaching my scene. Basically I have attribVOP measuring the length of the line and that greyscale data is stored in $CR. I also have pointWrangle that is creating a new value based upon the contents of $CR. This new value is a scale value that I want to apply to the Transform UV node, further down the path. The net result is that the tube will have one UV scale on one half and another UV scale on the other. This is followed up by a displace that references those UV values.


The point function requires a point index to fetch the attribute from. All I have is $CR. How do I convert the $CR information into an index for the expression?



Edited by Atom
Link to comment
Share on other sites

If you have a Cd (or color attribute) defined at the point class level, then all you'd need to use is $CR, since that's evaluated at the point level (assuming of course that the SOP in question is working on points and not prims, depends on the SOP). You could bypass the point expression altogether. Otherwise just use the $PT variable as you point num that you feed into the point() expression. If $PT doesn't work then that suggests that the SOP isn't designed to work at the point level, and you might need to get a little more creative.

Link to comment
Share on other sites

The x scale in the UV texture node is a global scale. It stretches your UV's  from 0..1 to 0..xscale. It's a bit hard to imagine what this would look like on a per-point basis. If you want to shrink or stretch a segment somewhere in the middle of your curve the rest that comes after it has to somehow shrink/stretch with it.


Just a few remarks on your current setup, the ends node was added to "disconnect" the first and last point of the circle so that the UV's don't wrap to create the stretching that occurs with point UV's, it has nothing to do with the perimeter measurement. Second, the uvtexture nodes before the sweep were set up to automatically UV the skinned tube as a product of its profile and backbone, adding another uvtexture right after it renders that process useless. I'm not saying you can't put a uvtexture after your sweep but just realize that you might just as well remove the setup from before the sweep ;)

Link to comment
Share on other sites

I did try $PT, and I could not get it to work. For some reason the scope/context changes after the sweep and the $PT variable is not accepted by the point() function. And I think it is because I am supposed to be passing an integer index not a float between 0.0-1.0. So maybe some modulus function that returns an integer based upon $PT and $NPT is needed?


Here is the goal, however.

Imagine the displacement is just a checkerboard. We would get even tilable displacement along the length of the tube.

What I want to do is to chop the length into n segments and apply different UV scale values to each segment.


The visual appearance would show different scales at different segments of the curve.


I thought if I could scale the UVs based upon the length that the displacement would simply follow along?


Link to comment
Share on other sites

You can try to carve your curve into multiple segments and then loop through them to use the uvtexture node with a separate scale. If you give each piece of the curve the new scale attribute you can reference it using the prim() expression inside your loop. When local variables aren't supported it usually means the SOP doesn't operate on that context. After using wrangles and/or vops you tend to get spoiled and forget that not many nodes loop over all points by themselves to allow the use of $PT to get the current processed point.

Link to comment
Share on other sites

I think I see what you mean. The UV Texture simply can not be driven that way. But after an afternoon of noodling I did come up with a solution that matches my original intent.


I still use the UV Texture but set it's scale to 1.0 for all axis.

Then I follow that up with a FOREACH with a point wrangle inside.

The point wrangle scales the existing UVs by some constant values that are determined by a series of IF/THEN statements.

The IF/THEN statements are driven by the percentage along the path, which is stored in $CR.

I added a different color in each IF/THEN so I could see what sections were receiving what scale values.




Edited by Atom
Link to comment
Share on other sites

  • 1 month later...

instead of your multiple if statements why don't you use a float ramp for each of the uv.x and uv.y values ?

should do the same thing (but be more artistic driven, and more flexible than hard coded values) especially if the input is normalised...

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.

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...