Jump to content

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
Link to comment
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

Link to comment
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
Link to comment
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

Link to comment
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
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...