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!