Jump to content
Fyre

popForce boundingbox, soft falloff - how?

Recommended Posts

Fyre    3

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 by Fyre

Share this post


Link to post
Share on other sites
Fyre    3

Anyone know? Sorry if its a basic question but I've still not found a solution

Share this post


Link to post
Share on other sites
galagast    84

Hi,

Try out this sample file:
box_falloff.gif
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

Share this post


Link to post
Share on other sites
Fyre    3

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

Share this post


Link to post
Share on other sites
galagast    84

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? :D

Share this post


Link to post
Share on other sites
Fyre    3

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

Share this post


Link to post
Share on other sites
galagast    84

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). :D Be ready for quite a bit of reading.

  1. 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.
     
    1. Let's start from scratch.. a simple Box polygon:
      1_box.png
      Box
       
    2. Let's convert it to a Volume primitive using an IsoOffset SOP (or a VDB from Polygons):
      1_fog_volume.png
      Fog Volume
      Notice the default settings, it is of Output Type: Fog Volume.
       
    3. So from a Box which consisted of points and polygon primitives, we now have these:
      3_converted.png
       
    4. 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.
      4_voxels.png
      Volume Representation

      I'm guessing you know much of this already, but just bear with me for a bit :lol:
       
    5. 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:
      5_slice.png
      Volume Slice
      We will be left with just this simple 2D flat grid.
       
    6. We could now safely assume that this grid also has coordinate data, like a standard digital image, it has pixel x and y coordinates.
      6_coords.png
      X & Y Coordinates
       
    7. Going further to simplify things, let us isolate just the x coordinate for now:
      7_x_coords.png
      X Coordinates Only
       
    8. 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:
      8_seq.png
      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
       
    9. At this point, you might ask what can we do with these numbers?
      We can now use it for our Ramp Parameter.
      9_ramp.png
       
    10. 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:
      10_div.png
      The result thereof:
      10_div_result.png
      Now we have usable values for the Ramp!
       
    11. 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:
      11_ramp_shape.png
      And the resulting values of the remapping:
      11_ramp_result.png
       
    12. 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:
      12_vex_density.png
      In VOPs, you simply wire it out to the Density output:
      12_vops_density.png
      * Remember, since we're manipulating volumes.. we need to use the Volume VOPs variant in SOPs.

      The resulting volume now looks like this:
      12_final.png
      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. :D

      - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
      Now loaded with the information above, here is how you would apply it in VOPs:
      1. First, this shows the equivalent built-it variables that I used in VEX for Volumes:
        variable_equivalents.png
        Left: Wrangle | Right: Volume Vop
      2. 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.
        vops_2_grad.PNG
        Image showing just the x-axis setup.
      3. 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.
        vops_3_ramp_names.png
        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.
      4. Finally, on the last line. We just do a simple multiplication for all 3 values and write it out to density.
        vops_4_final.png

        And of course, here's the updated file:
        H16.0.557 Indie - box_falloff_vop.zip
         
  2. 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.
    volume_wrangle.png
    These names are arbitrary, I could have named the variables anything.. like potato:
    volume_wrangle_potato.png
    ..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. :)
     
  3. How do I get that inside the DOP to drive the force?
    I hope this graph would help you visualize the flow:
    sop_to_dop_graph.png
    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.
    pop_force_vex.png
    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!
  • Like 5

Share this post


Link to post
Share on other sites
bunker    105

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"));

  • Like 1

Share this post


Link to post
Share on other sites
Noobini    81

thanks very much for your time and effort Jeff !!!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×