Showing posts with label xyzdist. Show all posts
Showing posts with label xyzdist. Show all posts

Thursday 27 October 2022

"shrinkwrap" push faces from one object towards another

More Julian scripting
Use case - an object lying on the floor is not quite touching the surface - so lets pull points of the floor toward the surface. The floor object would go into the first input and the object to "wrap" to goes into the 2nd input. Put this code into a point wrangle -

 i@prim;

v@uvw;

@dist = xyzdist(1, @P, @prim, @uvw);

@bias = fit(@dist, 0, .01, .79, 0);

@P = lerp(@P, primuv(1, "P", @prim, @uvw), @bias);


It might be necessary to play with the "fit" values & ensure the objects are kinda close to each other to begin with! This is good for bodge fixing stuff!


Friday 25 October 2019

blurring vdbs

float dist = xyzdist(1,@P);

float distremap = fit(dist,ch("near"),ch("far"),0,1);

f@density *= distremap;


This gives a vdb a falloff based on how close it is to the original object's surface.
Stick the VDB into a volume visualisation and then plug that into input 0
Put the original geo into input 2.

Now you can "blur"

Saturday 3 December 2016

Attribute Interpolating UVs & things other than scattered points.

Creating "sourceprim" and "sourceprimuv" attributes for things other than scattered points. In the Houdini docs for the scatter node, there is a guide on getting your scattered points to follow animated/deforming geometry. The scatter node can generate the source primitive and it's uv attributes for you at the tick of a box. You then stick that into an attribute interpolate node and away you go.

However, if you want to interpolate something else like say..a colour attribute or a UV attribute, or something like that - then you'll have to create your own sourceprim and sourceprimuv.
Freeze your geo using a timeshift. Then just lay down a pointVOP, connect it to your geo & then plug the source (ie in the case of the scatter example, it's the object you want to stick to) into the second input.
Within the VOP make an XYZdist node and wire up P to the position input and the second input into the "file" . Create two bind exports and change the output names to sourceprim and sourceprimuv, making sure the data types are correct.
Finally just play around with the search distance in the XYZdist node so you get correct values. Jump out of the VOP and plug the appropriate bits into the Attribute Interpolate node. Adjust the settings to whatever you need (Vertex,point etc...) and everything should be good! You might have to change the pointVop to a vertexVop... too haha.

Tuesday 27 September 2016

Snap surface points to another mesh, based on distance

Eg. When you have a simmed fluid not quite sitting on it's collision surface/ intersecting & you want it to be fixed/better.

Using a Point Vop. Plug in the surface and it's "collider".
Drop down a xyzdist plug that into a primitive normal. Hook up the appropriate inputs, don't for the the "file" input in the primitive normal. Set the max search distance to something sensible (probably a small value)

Plug the resultant "dist" from the xyzdist into a fit range node and promote the max value to the object level. In the destination value, set the min to 1 and the max to 0. Multiply this by the distance to avoid affecting the entire object (the max value will clamp a lot of values to 0 and nullify it)

Plug things into a displace along normal node. Promote the scale value. Finally connect the final P value.

It's worth having a group node with bounding points to check how well it's all worked.