Transfer Cd Texture to points

   948   3   2
User Avatar
Member
88 posts
Joined: Sept. 2021
Offline
Hello, I created a particle simulation to make a dancing character rise with particles coming from the floor - think of it as a reversed dissolve effect.

Now to blend the particles to the final mesh I need the particle to get the color of the closest position in the mesh's texture. I guess I can't just use Attribute Transfer here, as it only takes the values stored in the geometry and not the map itself. So want the particles to get interpolated UVs instead.

This is the network I have to reach that so far.



This is how I expected to get interpolated UVs:
int prim;
vector target=minpos(1,@P);

xyzdist(1,target,prim,@uv);

But for some reason xyzdist() doesn't work as I thaught. Instead it projects every single face of the mesh to a full UDIMM and uses these projections to calculate uv. Here I visualized the resulting uv:



Can you tell me what I got wrong here? And how do I receive correct uv?

Hope you can give me a hint, thanks a lot!
Edited by freewind - March 21, 2023 14:28:26

Attachments:
particles_uv.jpg (214.1 KB)
network_transfer_uv.jpg (17.1 KB)

=================
Intel core i7 6700K
AMD Radeon RX 580
User Avatar
Member
7803 posts
Joined: Sept. 2011
Offline
freewind
Can you tell me what I got wrong here? And how do I receive correct uv?

Hope you can give me a hint, thanks a lot!

after xyzdist, use primuv() to look up the attribute uv using the parametric uvw retrieved by xyzdist.

float d;
vector hitprimuv;
int hitprim;
d = xyzdist(geo, origin, hitprim, hitprimuv);
vector uv = primuv(geo, "uv", hitprim, hitprimuv);

edit:
you can also use the attribute interpolate sop to do the primuv() step.
Edited by jsmack - March 21, 2023 14:46:15
User Avatar
Member
8594 posts
Joined: July 2007
Online
Alternatively you can also use Ray SOP directly

Method: Minimum Distance
Transform Points: Off (if you don't want them to move)
Import Attributes From Hits: On
Point Attributes:
Vertex Attributes: uv
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
88 posts
Joined: Sept. 2021
Offline
Thank you very much! All ways work great here.
=================
Intel core i7 6700K
AMD Radeon RX 580
  • Quick Links