Jump to content
CinnamonMetal

Fit detail attribute into 0-1

Recommended Posts

I'm promoting the vertex uv attribute to each their own detail attribute using an attribute promote; except now I want to fit the values from these two detail attributes. Therefore I'm running the following code in a detail wrangler; although I'm not getting the result which I want ?

vector newUV = fit(1,@min_u,@max_v,0.0,1.0);

 

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

maybe check your params

usually it's old_min, old_max, new_min,new_max

but your 1st 2 params are BOTH max AND they're different (ie. one is u and one is v), maybe the max_u should really be min_v

so min_v,max_v,0.0,1.0

Share this post


Link to post
Share on other sites

I corrected the parameters which I posted in my original post. Although the fit() function has five arguments; the first argument is what I don't know if what I'm entering is correct ? 

 

Share this post


Link to post
Share on other sites
18 minutes ago, CinnamonMetal said:

I corrected the parameters which I posted in my original post. Although the fit() function has five arguments; the first argument is what I don't know if what I'm entering is correct ? 

 

oh sorry for the confusion, when i said first 2 i meant your min_u and max_v.

Now that the actual 1st param is mentioned, i think that should be your "variable" (ie. the THING you are trying to remap)

So don't think it should be the literal 1 but should be your @myattrib...

 

float  fit(float value, float omin, float omax, float nmin, float nmax)

 

<vector> fit(<vector>value, <vector>omin, <vector>omax, <vector>nmin, <vector>nmax)

(note in your case, you need to feed it new vectors, not 0.0 and 1.0)

Edited by Noobini

Share this post


Link to post
Share on other sites

I don't have a vector variable for the first parameter; only two detail attributes which I split and promoted from the vertex attribute uv.  I tried the @P attribute but that won't have any effect on vertices; only attempted because it's a vector.

Share this post


Link to post
Share on other sites
5 hours ago, CinnamonMetal said:

I don't have a vector variable for the first parameter; only two detail attributes which I split and promoted from the vertex attribute uv.  I tried the @P attribute but that won't have any effect on vertices; only attempted because it's a vector.

here, take a grid, uv it normally so all vertices fit into 0-1 space, seen by the red circles. These vectors range from {0,0,0.5} to {1,1.0.5}

dunno why the last component is 0.5, not an expert.

then remap these vectors to say...double it

v@uv = fit(@uv,{0,0,0.5},{1,1,0.5},{0,0,0.5},{2,2,0.5});

as you can see with the templated white lines

fit_uv.thumb.jpg.34c80977e41c8e2e30dd5586a60d1bd4.jpg

Share this post


Link to post
Share on other sites

Hi Christopher,

you can maximize UV islands or the entire coordinate set by temporarily transferring the UV coordinates to world space where they can be fitted and transformed more easily.

uv_maximize.hipnc

Share this post


Link to post
Share on other sites

When promoting uv from vertex to point as P, my mesh becomes completely tangled after the vertex split; as your example @konstantin magnus ?

It would be because the UV are outside of the 0-1 ?

v@bbox_min = getbbox_min(0);
v@bbox_max = getbbox_max(0);
f@fituv = (float)fit(@uv,@bbox_min[0],@bbox_max[0],0,1);
f@fituv = (float)fit(@uv,@bbox_min[1],@bbox_max[1],0,1);
f@fituv = (float)fit(@uv,@bbox_min[2],@bbox_max[2],0,1);

The above is getting me the bounding box for all three values for the min/max but how can I set them so that the UV fit within the 0-1 range.  The above was what I had planned.

Edited by CinnamonMetal

Share this post


Link to post
Share on other sites

Is it not possible to have a UV layout sop after the file; then get the island attribute and use that in a forEach sop and then move each island to a different udim using a transform sop within the foreach sop ?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×