![]() ![]() UVs are nice and simple and flat! So let’s just solve this in UV space, and then wrench it back into the space we want afterwards. Or, we could just solve the problem in an easier space. We could solve this particle simulation on a cylinder, and use sticky attributes or ray projection to figure out ways to wiggle the particles around and still keep them attached to the surface. We want the droplets to move down the surface of the can, maybe wiggling back and forth a tiny bit the way that droplets do due to surface tension. Note that the output attributes on the Scatter SOP need to be enabled for this to work. Then we’ll drop down a separate Object Merge (with Transform set to “Into This Object”) and a separate Wrangle, and connect them like so: On the Object Merge, we’ll set the Transform option to None, which means the transform will not be applied when we move the container later on. ![]() We’re just storing the primitive and parametric UVs to our point. Here’s the code for the original Wrangle now: We’ll also need to split up our Wrangle into two. With just a pig head being transformed at object level, we can use some options on our Object Merge to accomplish something similar. With deforming geometry, you could use Time Shift to pick your reference frame. You only want to do that computation once. You should see your dot stick to the nearest point on surface! If you transform the pig head, though, the rivet won’t stick to the right place, because it’s constantly recomputing the nearest primitive/parametric UV. We want to get the position to stick to, so let’s use this function to grab “P”. It will even interpolate attributes for you between points (such as point colors, or position). Given a geometry, a primitive number, and a parametric UV coordinate, primuv will tell you whatever the hell you want to know about the geometry at that point. Now what? It’s time for xyzdist‘s best friend forever, primuv. The pig head is plugged into the 2nd input, but arrays start at 0, so it’s input 1. Connect your point and your template geometry to a Point Wrangle, and start with this code:įloat dist = first parameter, of course, is the input index we’re getting this information from. Next, let’s figure out the nearest primitive and parametric UV on that pig head. The pig itself is being merged in from another network. To do this, we’ll make our template geometry, and then add a point in space using an Add SOP, then use our magic xyzdist function to get the information we need for the nearest point on the template geometry. We just want to stick a point onto an object, and have it follow the object around. The easiest example to start with is the rivet. So, what can we do with this? Click below to find out… Note that parametric UVs are not the same as regular UVs… this just means the normalized position relative to the individual primitive we found. ![]() So if we feed this function an integer and a vector, in addition to the distance to the surface, it will also give us the primitive number prim and the parametric UVs on that primitive uv. Those little “&” symbols mean that this function will write to those parameters, rather than just read from them. Note that this doesn’t mean the nearest actual point, but the interpolated surface in between those points. I’ll do a little example of each as a way of showing off what you can do with these clever little tools.įirst, let’s take a look at the VEX definition (the third overload here is the most frequently used):įloat xyzdist(string geometry, vector pt, int &prim, vector &uv, float maxdist)Īt its most basic, xyzdist will return the distance from the sample point pt to the nearest point on the surface geometry. These functions are at the core of a lot of really useful and cool tricks in Houdini, including rivets, the attributeInterpolate SOP, the old “droplets falling down a soda can” effect, and some really awesome stuff with volume shaders. I’m going to try to make a nice easy introduction to my two favorite functions in Houdini VEX (besides fit01 and chramp of course): xyzdist and primuv. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |