Jump to content

Closest point along surface, not volume


maansrune

Recommended Posts

Hey guys, first time posting here. Hope you can help me, I'm a VEX noob, but I want to learn.

 

I'm have created planes from point scattered across a character. I now want these planes to neatly wrap to original mesh. For that I use the below VEX in a VEX point wrangle node. And it works.. but...

int prim;
vector primuv;

// Find distance to nearest point of geometry from input 2
vector dist = xyzdist(@OpInput2, @P, prim, primuv, 1000000000000);
vector adata = primuv(@OpInput2, "P", prim, primuv); 

vector diff = (@P - adata)*fit01(@leaf_splat_paint,3,1); // Subtract distance from original position
vector product = diff * ch("splatMult"); // Add multiplier to SPLAT effect
vector sum = product + adata; // Add the new point position to the product

@P = sum; // Make sum new position

My problem is that whenever the characters legs cross close to one another, the planes of one leg try to align with the opposite leg, creating a jittering stretching effect that is not desirable. This is also true if the arms comes close to the face or the torso.

 

My question is, what do I need to add to the VEX code to search for closest point along surface and not within volume of space?

 

Any help is appreciated.

 

This forum has been a god sent in the past for me, you guys have helped me out of more trouble than I care to admit :) Cheers

 

 

Link to comment
Share on other sites

Hi 

 

I would timefreeze a frame or if you have a bindpose (T-Pose), use that as your OpInput2, and then plug the animated character into OpInput3

to get the current P

 

 

so something like this

int prim;
vector primuv;

// Find distance to nearest point of geometry from input 2
vector dist = xyzdist(@OpInput2, @P, prim, primuv, 1000000000000); //You look up prim number and uv on static pose
vector adata = primuv(@OpInput3, "P", prim, primuv); // You fetch the P from the animated character

vector diff = (@P - adata)*fit01(@leaf_splat_paint,3,1); // Subtract distance from original position
vector product = diff * ch("splatMult"); // Add multiplier to SPLAT effect
vector sum = product + adata; // Add the new point position to the product

@P = sum; // Make sum new position

Good luck

Link to comment
Share on other sites

Hey Jens.

 

Thank you for your quick reply. The solution you proposed seemed solid, but it's not working.

 

This is the process of creating the planes (can't share images or the file sadly, so I'll have to describe as best as I can):

  1. Point are scattered on static mesh
  2. PRIMUV attribute is interpolated onto scattered points from static mesh
  3. Points get animation applied, interpolated onto them from animated mesh via PRIMUV and a FLOW attribute
  4. Planes are created from points.
  5. The planes inherent the animation, but stick out at angles matching the FLOW attribute
  6. To flatten down the planes, the Point Wrangle node from above is used.
  7. Animated planes (Opinput1) are matched to closest surface on animated mesh (Opinput2), which they closely match already.
  8. This approach however, generates the artefacts where planes are attracted to any surface that is nearest. Hand comes close to face and planes on face stretch toward hand instead of face.

So when I used the script above, I assume the XYZDIST function gets confused because the distance between animated model and the static model is too great (Static model is placed a 0,0,0, animated model is somewhere else in world space), and the planes are distributed somewhere between the two models.

 

Is there no way to force the XYZDIST to only look along a given connected surface and not a spherical field? Or some other function that will do something similar?

 

Hope this made any sense at all. Otherwise I guess I'll have to live with the artefacts for now.

Edited by maansrune
Link to comment
Share on other sites

as mentioned above, make the planes sample the geometry at rest frame, get primuv and primid, and then during animation get P from that location at animated mesh, you will be guaranteed that it will not snap to different location

Link to comment
Share on other sites

  • 2 weeks later...

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...