Why UVW coordinate instead of @P?

   1494   6   1
User Avatar
Member
24 posts
Joined: Aug. 2023
Offline
Please look at my screenshots,

The "@P" is not equal to "my_uv" calculated by xyzdist.

Why?Shouldn’t they be equal? Especially the lines have already put in space,



int my_primnum; vector my_uv;

xyzdist(2,@P,my_primnum,my_uv);
@P = primuv(1,'P',my_primnum,@P); //wrong code
@P = primuv(1,'P',my_primnum,my_uv); //right code

Attachments:
purpose_Snipaste_2024-09-02_17-05-53.png (688.7 KB)
LInes have already put in [1,1] space_Snipaste_2024-09-02_16-52-39.png (383.6 KB)
Wrong_Snipaste_2024-09-02_16-57-26.png (760.6 KB)
HIP_PetalDeform.zip (32.8 KB)

User Avatar
Member
2162 posts
Joined: Sept. 2015
Offline
xyzdist(<geometry>geometry, vector origin, int &prim, vector &uv)

Thats because xyz assigns &uv the uvcords of closest position in space of the primitive itself.

So naturally what you call the right cord, is indeed right because you are applying it 'as you should'.

However when you attempt to use @P in your 'wrong code', naturally you won't get what you expect because @P is 'mapped' in your case across a grid from 0-1.


To help visualize, take your hip file and merge your 'transform2' and 'P_equal_uv' nodes.

Then take any arbitrary point as reference on your straight lines - then consider what the uv is for that point of that entire 0-1 grid space like in your diagram above, vs. the uv space of just the primitive found from that reference point.

Understand how it's two different mappings?
Edited by BabaJ - Sept. 2, 2024 09:30:35
User Avatar
Member
24 posts
Joined: Aug. 2023
Offline
BabaJ
...

Thanks for your detailed explaination.

Following your words,I try to take one point to unstander the two different mappings,

but,

I find the difference is so so so huge between the P value and the my_UV which xyzdist() returnd...

why? How can I understand the &uv map result from xyzdist()?

screenshots:

Attachments:
map_Snipaste_2024-09-02_22-30-00.png (1.5 MB)
check my_uv value_Snipaste_2024-09-02_22-40-09.png (1.0 MB)

User Avatar
Member
9372 posts
Joined: July 2007
Offline
uvw returned from xyzdist() or used in primuv() function are parametric coordinates of the primitive and has nothing to do with any attribute on the geo depicting texture UV(W) coordinates

if you want to sample your leaf location using 'uv' attribute use uvsample() function, which in your case you can replace the whole code with:
@P = uvsample(1, "P", 'uv', @P); 
Edited by tamte - Sept. 2, 2024 12:05:02
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
2162 posts
Joined: Sept. 2015
Offline
why? How can I understand the &uv map result from xyzdist()?

Probably one way is to not think of the 4th argument set by xyzdist as uvw....you could easily think of it as lmn.

But regardless of the way and for a polygon face, just consider uv.

And with xyzdist no matter what polygon is found it will always map out full values from 0 to 1 for both u and v.

However, since polygons can always come in a variety of shapes, each one(polygon) has to be calculated(mapped) differently in order to always be able to have(establish) 0-1 values for each u and v.

It's not like any polygon is put in a box of a 0-1, 0-1, 0-1 domain and clamps values that lie outside the polygon.

That's not what xyzdist is doing.

You can see the results of xyzdist by looking at the geometry spreadsheet with the 'UV' labelled node in this hip.

Adjust the number of sides of the subnet parameter to get different shapes, and also adjust the parameters of a selected point to move it around to different positions for the shape.

Then you should see how '&uv' always keeps values between 0 and 1. And how they change differently for each differently shaped polygon.

The only time you will find a one to one correspondence(other than being scaled differently/rotated differently) between '&uv' output and a grid layout like you have in your example - is if the polygons themselves are square too.

But even then...the way you have your setup and your expectation doesn't pan out because the polygons with their '&uv' values are like a subdomain within a larger domain(your 1 x 1 grid). xyzdist is only returning the domain of the polygon itself, there is no reference/relationship to anything outside of the polygon - only your starting position of 'origin'.

The 'uv' you used to move your points of your geo is not the same '&uv' set by xyzdist.

The ones(uv) you used, like Tamte pointed out, are texture uvs - They were not derived/created from the polygons. They were layed out over the polygons.
Edited by BabaJ - Sept. 2, 2024 17:20:43

Attachments:
uv_of_xyzdist.hiplc (255.3 KB)

User Avatar
Member
24 posts
Joined: Aug. 2023
Offline
tamte
@P = uvsample(1, "P", 'uv', @P); 
Thanks for your reply,

yes , I'll follow your words to use uvsample() instead of xyzdist() and primuv() if i wanna use @P.
User Avatar
Member
24 posts
Joined: Aug. 2023
Offline
BabaJ
each one(polygon) has to be calculated(mapped) differently in order to always be able to have(establish) 0-1 values for each u and v.


I appreciate so much for your paient reply,

I've opened your hip,

and I may understand what you say,

the ‘&uv’ returned from xyzdist() refers to each dividual polygon,

limited from 0 to 1, like the below gif I made.


and in the future, for this special calculate way, I'll conneted the xyzdist() and primuv() to use without any doubts ,hhh

and you are a great guy,

thanks for your so detailed response

Attachments:
houdini_pijeEF9l8Q.gif (2.0 MB)

  • Quick Links