Jump to content

Creating Ripples At Particle Collisions


Vormav

Recommended Posts

Hey. Doing a simple rain system, and thought 'what better way to overdo it than procedurally creating ripples in anything I want to be considered puddle geometry in reaction to colliding particles?' ;) A decent challenge, however I've hit of a bit of a snag.

The way I'm doing it right now is to split off particles when they collide with the puddle geometry, and set the approximate lifetime on the newly split particles to about what I'd want the life of the ripple to be. I also set the hittime attribute in the collision pop.

Back up in the SOPs level, I have a simple point SOP that has spare parameters connected to a translation expression allowing me to define things like the frequency, amplitude, decay size/rate of the ripple, start and end frames for animating it, and position parameters for placing the center of the ripple (I would use the VEX Ripple, but it doesn't let you define the placement of the ripple, or set its start/ending frame points directly). Sloppy expression (and since it is a fairly long expression, I'm sure it would be better to put together something in VOPs...), but it works.

The idea, then, was to create a copy of the puddle geometry for each particle in my collision group, then copy stamp the hittime and position parameters into my ripple point SOP. Then I could pretty easily cycle over all of the different puddle objects and average out the different heights of the particles to get an effect of multiple ripples from collision points on the puddle.

Of course, that last step - multiple copies of the puddle geometry for each collision points - obviously means that this would be incredibly slow. It didn't work anyway; for some reason, I wasn't able to copy stamp the hittime attribute (I did make sure to import template attributes - and when I middle click on my copy node, I can see the hittime attribute. But it still wouldn't work... :unsure: ).

So, just looking for some new ideas. It'd probably be a lot easier, and run way faster, if instead of dealing with the geometry I was to send my collision group into cops, and instance some kind of 2d animated ripple at all of the collision points. This would be easy to conform into a single map that could be applied as either a displacement or bump map. But without any sort of copy cop node (at least I'm not aware of one - but I also haven't used cops much, so I very well could have missed it), I'm not too clear on how to do this.

Any tips? Suggestions? Hoping to find a way to do it without going for an all-out VOPs solution. ;)

(And just to get it out there, yes I am aware that it's not completely necessary to have ripples show up exactly at the collision points, because no sane person is going to run through an animation frame-by-frame to make sure that everything is lining up prefectly. But that's not the point! :) )

Link to comment
Share on other sites

If you don't find a way around VEX/VOPs, I found using a custom VEX displacment with point clouds to be a useful way of doing this. I ran a particle sim to the last frame and wrote out a single file that, for every particle during the entire simulation, noted its hittime and hitpos. Then as a displacement shader

displacement
_ripples2(
    string map = "";
    float frame = 1;
    float speed = 1;
    float amplitude = 0.01;
    float falloff   = 0.5;
    float width     = 0.1;
)
{
    vector Pw = wo_space( P );
    vector Nw = normalize( wo_nspace( N ) );
    int nfp = 1000;

    int handle = pcopen( map, "P", Pw, "N", Nw, 1e37, nfp );

    vector mapP;
    float  mapT;

    while( pciterate( handle ) )
    {
        pcimport( handle, "hitpos", mapP );
        pcimport( handle, "hittime", mapT );

        if( mapT != -1 )
        {
            float dP = length( mapP - Pw );
            float dT = ( frame - mapT ) * speed;

            float amp = amplitude;
            amp *= ( 1 - smooth( 0, falloff, dP ) );
            amp *= ( 1 - smooth( 0, width, abs( dT - dP ) ) );

            P = P + normalize( N ) * amp;
        }
    }

    N = computenormal( P );
}

Link to comment
Share on other sites

There's a 3d buzz vtm called "houdini water ripple." He uses a VOPs approach and it's decent. I'd give that video a try for ideas.

I think they might have taken it down? Don't see it on the list atm.

And a copy-stamping version as well. Let me know if anything doesn't make sense in it!

26063[/snapback]

Makes perfect sense! Very similar to how I did it, except with handling the positioning of the ripples differently. You used almost the exact same expression to stamp the hittime, too (a point() expression with $TPT). Think I'll dive back into my file and see how I screwed up that part...

Thanks. :)

EDIT: Argh... Forgot that hittime was in seconds, not frames. That's where my problem was. I'm trying out something similar to rjpieke's copy stamping method right now, using my point ripple node, along with a couple ray sops and point nodes afterwards to have each separate ripple affect a single grid mesh.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...