Jump to content

How to get world coordinates from UVs?


magneto

Recommended Posts

Hi,

 

I have a model with UVs and I want to arbitrarily sample some UV coordinates within 0-1 space and then get the corresponding world position. I know UVs are not guaranteed to be unique but the UVs I have are.

 

Any ideas on how to do this?

 

 

Thanks :)

Link to comment
Share on other sites

if your object is a square grid, you can just multiply the UV coordinates with (1/bboxSize) in a certain direction. if your object spans the whole world.

if it doesn't span the whole world you would need to use the difference between max and min bboxes compared to the worldsize I guess

Link to comment
Share on other sites

Hi,

 

I have a model with UVs and I want to arbitrarily sample some UV coordinates within 0-1 space and then get the corresponding world position. I know UVs are not guaranteed to be unique but the UVs I have are.

 

Any ideas on how to do this?

 

 

Thanks :)

In the UV unwrapper, you can call uvunwrap().  See the uvlens shader for an example.

 

If this doesn't work, then it's a little trickier.  You might be able to do something with a point cloud (using "uv" instead of "P" for your search attribute).

Link to comment
Share on other sites

In the UV unwrapper, you can call uvunwrap().  See the uvlens shader for an example.

 

If this doesn't work, then it's a little trickier.  You might be able to do something with a point cloud (using "uv" instead of "P" for your search attribute).

 

No it's not a grid unfortunately :(

 

In the UV unwrapper, you can call uvunwrap().  See the uvlens shader for an example.

 

If this doesn't work, then it's a little trickier.  You might be able to do something with a point cloud (using "uv" instead of "P" for your search attribute).

 

That function is for SHOPs, no? I need to do this in SOPs.

Link to comment
Share on other sites

In my head this should work...

 

Move the geometry to "uv position" @P = @uv

Use the xyzdist function to get the primnum and paramtric uv at the uv coord.

Now use the primuv function on the original geometry to get world P.

 

I might be able to roll you a .hip later on... 

 

 

vector uvcoord = chv("uvCoord");


int hitid;
vector hituv;


xyzdist(1,uvcoord,hitid,hituv);


@P = primuv(2,"P",hitid,hituv);

Edit.

Something like this might work in a point wrangle if you put...

 

1. a point in input 0

2. The geometry in "uv position" into input 1

3 The original geometry in input 2

 

Cant create a .hip file now, but if you want one I can do that later on tonight...

Edited by mawi
  • Like 1
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...