Rain goes splash

I’m trying to use the World Particle Collder to make some splashing rain drops by instantiating a texture where the particles collide on the ground using ContactPoint but I can’t get the Collision to trigger. I’ve turned on “Send Collision Message” on the particle but nothing happens.

I’ve tried both OnCollisionEnter and OnParticleCollision but neither one is working. Any hints for a poor scripting simpleton?

OnParticleCollision takes a Collider, not a Collision type parameter; my guess is that’s where your problem is. And a fundamental problem at that – a collider by itself doesn’t have enough data to tell you the point at which a particle collided with it. :frowning: (I tried to do the same thing…)

Create your own particle system and use the built-in particle system just to render, so you have all the information needed for that.

Well, i know you can take every single particle at the time and take it’s position, if you are intersecting with a plane, then will be easy to know where it hits the plane by:

if ( particle.position.y < plane.position.y )
{
   destroyParticle ();
   createRainSpotAt (particle.position);
}

Checking only the Y attribute if you make the particle system a child of the plane i think.

On my research, here is an scene with a rain effect, the object named Splash is the one positioned at the position of the particle colliding (or whom Y is less that the Y of the plane explicitly given on the editor). Some particles are ignored i don’t know why, maybe i should find the most lower particle but that would be more computationally expensive.

Anyway, i created a light to see where the particle collides with the plane, and named it Splash. Then I thought that positioning another particle system would be a better approach (debris) to the rain effect, but changing the transform.position of that particle system (that i named Splash2 to disable it) makes my unity to crash. Im about to send the bug report, can someone check it too ? you have to rename the light Splash to anything else and rename the particle system Splash2 to Splash.

Here is the scene

Omar Rojo

30903–1128–$rain_705.unitypackage (7.67 KB)

Thanks Omar, that’s a good way to fake this effect on a flat plane and it helped me to get a little closer with using OnParticleCollision. Unfortunately, ParticleEmitter.particles[index].position doesn’t always grab the particle at the position of the flat plane (if you look at you’re example from the side you’ll see the light move up/down in Y).

I tweaked your solution a little bit but using OnParticleCollision to get the position of the particle on sloped terrain…

var rainSplash : GameObject;

function OnParticleCollision () 
{
    var particles = particleEmitter.particles;
    Instantiate (rainSplash, particles[0].position, Quaternion.identity);
}

The only problem with this is that I can only have one particle at once shooting down really fast to gat a proper indexing of the particles[ ].position. I then have a second particle emitter that makes more rain drops. OTEE, would it be possible to get particle collision cantact info in the future?

Example of how this looks so far.

Looks great man!
AC

In my script you can change the mPlaneY value to suit your needs, well i don’t know, neither of the solutions will be as good as getting the particle that collides with the object, so OTEE… let’s work :smile:

Omar Rojo

The best rain effect I’ve seen outside a tech demo was the first level of Metal Gear Solid 2 on the PS2. They faked it:

They didn’t bother about the individual rain drops, because in real life, you can’t really connect each falling raindrop with a speciic splash.

Instead they placed small particle-like polygons on the upwards-facing parts of their meshes (yeah, also on skinned characters), and then used a vertex program to cycle UVs so only 20% were visible at a time. It looked totally random and gave the feeling of a diluge coming down from above.

In pseudocode:
go over all meshes in the scene
shoot a bunch of rays downwards against each of them
Where the rays intersect, add a quad to a custom mesh. This quad shold have a UV space that is, say, 1/8th of the full texture space on each axis (think of a tiled particle image from a particle system).

the trick to make it work completely is to extrude the splash particles in a vertex program. I’ll be happy to help with that.

On a side note, I noticed that ATI released a paper on the various parts that made up their fantastic rainy street demo. a lot of it is very hairy, but it might be worth skimming for inspiration…

Gears of War handled rain really well. I just fired it up again to check how they did it.

They don’t bother with rain interaction with the characters themselves when you are standing out in the open, and they also don’t do splashes on the ground. What they do is animate the UV coords of a spec/gloss map (possible refraction too, but I doubt it). (EDIT: They do this on the ground, trees, just about everything except the characters.)

When a character walks into a stream of water like you would get through a hole in a roof, or from a downspout, they instantiate a particle system at the point with what looks basically like cloud-like particles with a refraction shader. Looks really good, and because of the UV animation on the ground, you don’t notice that there aren’t any individual splashes.

Mind you, this was also at night, so I don’t know how it would look in the daylight.

And I can’t for the life of me find a screenshot!

(EDIT2: Splintercell 3: Chaos Theory did a similar effect with animated spec map UVs)

-Jeremy

Interesting ideas everyone. I’d especially like to see Nich’s solution as a Unity demo.

This is for a really cartoony world though so I do kinda want that one to one ratio of raindrop to splash instead of a deluge effect. Raycasts were my next idea, but I couldn’t resist first trying to do it with particles because it seemed like it would be simple… so much for that :wink:

[Edit] Nich, do you have a link to that ATI rain demo?

I think using Raycasts will work well enough for my purposes… here’s an example.

The paper is here: http://ati.amd.com/developer/techpapers.html (Artist-Directable Real-Time Rain Rendering in City Environments). The demo itself is ToyShop.

Hi guys (my first post in the forums :smile: )

I thought of another way of doing it with the ParticleCollider. I set the Collision Energy Loss to be a large negative value, so that when the particle collides, it ends up with an energy greater than anything it could have gotten from the emitter.

I then run a script, which replaces all high-energy particles with nice little explosions. (Oh yes, forgot to mention. I was not actually interested in rain right now)

Demo here
http://proglet.com/software/Unity/Particles/ParticleCollision.html

and javascript below

31211–1140–$findcollidedparticles_184.js (1.51 KB)

Very nice cblarsen, very very nice indeed, so you can catch up the high energy particles and even more than one in a strike.

Congratulations >D

Omar Rojo

Yeah, I think it would be ok for rain. The only thing you cannot do is have information about the particle and information about the object it collides with in the same script.

In my script you know where the particle collided, its velocity and so on.

In the OnParticleCollision function you know which object was hit, but nothing about the particle that did it.

However my main complaint about the particle system is that it is way too fun to play with.

Particle systems needs a mayor upgrade/redesign since they cover a lot of stuff on a game.

Hope in the next Unity version we’ll see a very powerful PS that allows us to do anything… and more

Omar Rojo

I finally bought this game for the sole purpose of checking out the rain you were talking about ($7 for MGS2 used, well worth it for just a study… I’ll never play through it because I find stealth games seriously annoying)). The rain on that first level is indeed impressive though.

Would you mind breaking down the process of getting such an effect in Unity? To me it looks like there are 3 things going on… a particle system right in front of the camera creating rain blowing in all directions, another particle system creating rain falling in a downward direction, and then the most important part of the splashes happening on all the upward facing geometry. It looks like a lot of polys are necessary to create the splash effect… you think it’s just cycling through a texture using offest? Damn I love this stuff… there’s a thousand and one solutions to every problem.

Wow I just reread that MGS Breakdown…Its just as cool reading it the third time round.

Has anyone got some more recent work they wouldnt mind sharing? I’ve spent a couple of days fiddling with OnParticleCollision() but havent really got anything to show for it. Im imagining a plane above the player that follows the player and emits particles…Which is dandy, but if anyone has an entry point for the raycasting approach- that would be great. I imagine you would raycast from vertex points? Or surface normals?

Thanks again
AC

LOL Heisenberg!!! Ha ha ha!

I spent some time with cblarsens script recently but it always instantiated the new particle systems quite some distance above the ground. Has anyone whos tried this found this and also the reason why?

I dont get the raycasting approach.

I wonder if the UT guys are looking at expanding the OnParticleCollision functionality? Basically the trouble starts when you try and match

function OnParticleCollision (other : GameObject) {}

with

function OnCollisionEnter(collision : Collision) {

Which kind of seem like 2 different dialects. First being collision, second being collider. The question is how do you match up parameters like collision and collider?

Hopefully some has some interesting insight…

Cheers
AC