Fyre Posted April 27, 2017 Share Posted April 27, 2017 (edited) Hey, Im trying to have a pop force act only inside a boundin box and with a soft fall off, is this possible? I've tried to make it with a uniform force and a mask from a sop scalar field, from a volume, but I can't seem to get it to have a smooth falloff? Cheers Edited April 27, 2017 by Fyre Quote Link to comment Share on other sites More sharing options...
Fyre Posted May 3, 2017 Author Share Posted May 3, 2017 Anyone know? Sorry if its a basic question but I've still not found a solution Quote Link to comment Share on other sites More sharing options...
galagast Posted May 4, 2017 Share Posted May 4, 2017 Hi, Try out this sample file: I used a box density volume, and wrangled it to create a falloff. This is then sampled by the a Pop Wrangle which creates an attribute used as a multiplier for any Force (via vexpressions). H16.0.557 Indie - box_falloff.zip 1 1 Quote Link to comment Share on other sites More sharing options...
Fyre Posted May 4, 2017 Author Share Posted May 4, 2017 Thats exactly what I was looking for, thanks very much! Although how would one set this up inside a vop, I can't seem to get it work from a vop. Thanks Quote Link to comment Share on other sites More sharing options...
galagast Posted May 4, 2017 Share Posted May 4, 2017 Are you referring to the wrangle that created the box falloff? I was initially gonna do it inside a vop If so, are you up for a bit of a challenge? Could you try and convert that to a VOP? Afterwards post your progress here so that I (or any other member) could maybe throw some pointers? Quote Link to comment Share on other sites More sharing options...
Fyre Posted May 4, 2017 Author Share Posted May 4, 2017 For sure yeah, I'll post my progress (don't expect much ) tomorrow. Quote Link to comment Share on other sites More sharing options...
Fyre Posted May 5, 2017 Author Share Posted May 5, 2017 So I've given it my best shot, havn't made it far despite working late last night. Theres frustratingly little information or documentation on how to do something as simple as finding and using volume gradient information - and I've not done much with them before. I've tried a few different things, and I roughly understand what is going on but I'm stuck. If you could take a look and clear up a few questions that would be great: 1. How do I get the gradient working in the vop 2. How do I visualize my gradient to check its working 3. How do I get that inside the DOP to drive the force Thanks volumeGradientFalloff.hipnc Quote Link to comment Share on other sites More sharing options...
Popular Post galagast Posted May 5, 2017 Popular Post Share Posted May 5, 2017 You have an awesome start man, no worries. I can see that you did try and do a lot of experimenting. I'll try and clear up some things for you (to the extent of my knowledge). Be ready for quite a bit of reading. How do I get the gradient working in the vop First off, to better understand how to manipulate volumes, you must first have a clearer idea what a volume really is in Houdini, especially what kind of data it holds. Because these data are the stuff that we going to be manipulating. Let's start from scratch.. a simple Box polygon:Box Let's convert it to a Volume primitive using an IsoOffset SOP (or a VDB from Polygons):Fog Volume Notice the default settings, it is of Output Type: Fog Volume. So from a Box which consisted of points and polygon primitives, we now have these: What happened to the data? Where are the Box's points and polygons info? Those are now gone, you now have to deal with voxels instead.Volume Representation I'm guessing you know much of this already, but just bear with me for a bit Now, I think this is where the interesting part comes in.. How are these voxels accessed in Houdini? You can think of it as manipulating images in Photoshop.. or more precisely, manipulating pixels, but in 3d. The simple description is that voxels are just 3d pixels. So let's keep things simple.. if for instance, we just take a "slice" from the 3d voxel grid like so:Volume Slice We will be left with just this simple 2D flat grid. We could now safely assume that this grid also has coordinate data, like a standard digital image, it has pixel x and y coordinates.X & Y Coordinates Going further to simplify things, let us isolate just the x coordinate for now:X Coordinates Only Notice that these are just rows of repeating sequence of numbers going from 0 to the max resolution of an axis --- in this case up to 9:Max Resolution in X is 9 To recap a bit, we now have a bunch of data to work with: * X Axis Coordinates = {0,1,2,3,4,5,6,7,9} * X Axis Resolution = 9 At this point, you might ask what can we do with these numbers? We can now use it for our Ramp Parameter. But an intermediate step is needed first. Something that is usually called normalization. We need to normalize it.. which basically means convert it to a range between 0 and 1. Mathematics and Computers just love em zeroes and ones! To go about doing that, the simplest way is to do division math. We divide each value in an X Coordinate by the X Resolution like so: The result thereof: Now we have usable values for the Ramp! We can now proceed to feed it to the Ramp and remap the values to build our custom falloff. Here is the manually adjust ramp to represent the falloff for the X Axis: And the resulting values of the remapping: Finally, almost done, we now have the falloff computation and what we need to do is to just pipe these values out as the Density. In VEX, you can see this happening as the last line of the code: In VOPs, you simply wire it out to the Density output:* Remember, since we're manipulating volumes.. we need to use the Volume VOPs variant in SOPs. The resulting volume now looks like this: As you may have noticed, this is just the X-Axis. The last and easiest thing to do is to simply repeat/duplicate the process for the remaining Y and Z axes then multiply them together to form the 3d falloff volume. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Now loaded with the information above, here is how you would apply it in VOPs: First, this shows the equivalent built-it variables that I used in VEX for Volumes:Left: Wrangle | Right: Volume Vop Next, following the 1st block of vex code, we do the conversion from "Integer" to "Float" so that we could divide the values with much more precision. Also, I subtract 1 from the resx, resy, and resz variables because the resolution value returns an amount that did not count from 0.Image showing just the x-axis setup. Apply the same nodes for the Y and Z axis. The 2nd block of code now deals with using the computed value (which is now in the range of 0-1) for the ramp. TIP: Use the same name for the Ramp Parameter for each of the axes to have just a single Ramp Parameter control up the UI. So even if we dropped 3 Ramp Parameter VOPs, with using just a single name "myRamp", there would only be one control to rule them all. Finally, on the last line. We just do a simple multiplication for all 3 values and write it out to density. And of course, here's the updated file: H16.0.557 Indie - box_falloff_vop.zip How do I visualize my gradient to check its working? You must be confusing the term/variable that I used in the Volume Wrangle whose names are "gradx", "grady", and "gradz" as the equivalent of the Volume Gradient VOP, which is actually not. These names are arbitrary, I could have named the variables anything.. like potato: ..And this will still work. So, for rebuilding the box volume falloff, you don't need the Volume Gradient VOP (I'll try and may do a separate explanation of this on a different post >_<) Maybe to rephrase your question: "How do I visualize my volume to check it's working?" And to answer that: For quick and simple visualization, I usually just use the Volume Slice SOP. Play around with it to see what it does. How do I get that inside the DOP to drive the force? I hope this graph would help you visualize the flow: On my example hip file above this post, if you check the Pop Wrangle node inside the particle sim DOP, you'll notice the Inputs tab. That is how the wrangle is reading the falloff volume we created from outside the DOP network. In the VEX code, by using the volumesample() function, we can then transfer the density volume data to our particles using any custom attribute. In this case, I simply created and named it "amt" for amount. (again it can be anything, like banana) Using our newly created variable "amt", it can then be used in inside vexpressions to do our calculations. Like multiplying it against the Force parameter to control the intensity. Note that this is just one method of getting data from outside Dops. You'll discover other ways as you venture out here in the forums I hope you did not fall asleep from this long post, and that my explanation at least made some sense haha Cheers! 14 1 Quote Link to comment Share on other sites More sharing options...
bunker Posted May 5, 2017 Share Posted May 5, 2017 you can also use a volume wrangle to create the volume mask with falloff: // fade volume near bounds float p = chf("padding"); vector b, B; getbbox(0,b,B); float m = fit(@P.x,b.x,b.x+p,0,1)*fit(@P.y,b.y,b.y+p,0,1)*fit(@P.z,b.z,b.z+p,0,1)*fit(@P.x,B.x,B.x-p,0,1)*fit(@P.y,B.y,B.y-p,0,1)*fit(@P.z,B.z,B.z-p,0,1); @density*=pow(m,chf("exp")); 3 1 Quote Link to comment Share on other sites More sharing options...
Noobini Posted May 5, 2017 Share Posted May 5, 2017 thanks very much for your time and effort Jeff !!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.