Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question How to properly set up rain splashes

Discussion in 'Visual Effect Graph' started by Evgeno, Jul 9, 2023.

  1. Evgeno

    Evgeno

    Joined:
    Sep 8, 2014
    Posts:
    48
    I'm trying to create a rain effect in VFX Graph, and I want drops to splatter when they hit the surface. To do this, I use Collide with Depth Buffer, and Trigger Event On Die, so that new splash particles are created at the place where the old rain particles were destroyed, where there was contact with the collision, but the video shows that sometimes splashes are created a little higher than where they should be why and how to fix it? Or maybe there is a better way to do this?
     
  2. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Hello. First thing that I would do is to take a look at the Scene Depth to take a look at who is writing into it. You do this by going into Window -> Analysis-> Rendering Debugger -> Material Tab -> Gbuffer -> Depth
    By doing so, you should be able to visualize the depth to be sure that no unwanted Meshes or particles are writing to the Scene Depth.
    upload_2023-7-10_10-7-23.png
    • If everything is looking good, you can check for the lifetime of our particles. If your particles have lifetimes, it might not be long enough for them to hit the Surface. In this case they will die before hitting the surface and so If you're passing this position to their "child" particles the position won't be on the surface. In this case, try to increase the lifetime, see if it makes some differences.
      Unity_D59q5JyOkT.gif
      In this example, as some particles have a small lifetime of 1, they're dying before colliding with the Scene Depth.

    • This can also be caused by some precision issues. If the speed of your particles is very high, this can lead to this can of problem. What you can do to verify this is simply by drastically lowering the speed of your particles to see if the precision of your collision is coming from this factor.
      Speed_Issues.gif
      In this example, as the Gravity Force is increased, the precision issue start to occurs.

      Now, the solution to solve your issue will depend on what you're trying to achieve... Do you need your scene to be dynamic ? If you just need to collide on one mesh and or a terrain, there are alternatives to using the scene depth that would unlock other options. Signed Distance Field can be an interesting alternative that might give you better results. When dealing with this kind of precision issues, what I often like to do is to "reverse" the spawning. So when doing rain falling, or leafs etc...
      What you can do is spawn The Rain Drop from the Collision surface/terrain, basically where they will die. You store this "Initial Position" and offset it on the World-Y axis. This way you can still use collision and spawn new particles but instead of using the "collided" position which can be "imprecise" you use the "Initial Position" stored before. You can even skip the "collision pass" by simply "lerp/interpolate" over the particle's lifetime between the "Initial Position" and the "Y-offset position"
      upload_2023-7-10_10-34-29.png

      To Finish, I would even say that for this kind of effect if the Rain intensity is pretty high, you can even create two separate system without the need of the Trigger Events. You would not have a perfect correlation between the Droplet and the splash, but the eyes won't be able to notice....if there are a lot of high speed particles and that your camera isn't going to be doing extra close up, you can save performances by not using trigger events.

      Hope this will help you find why your particles are not properly positioned. After this will be time to try to find the best solution to resolve or mitigate this issue. Have a great deay
     
    OutDoorsScene and Evgeno like this.
  3. Evgeno

    Evgeno

    Joined:
    Sep 8, 2014
    Posts:
    48
    Thanks for the detailed answer, I'll look at some option. And another question, Trigger Event On Die greatly affects performance?
     
  4. OrsonFavrel

    OrsonFavrel

    Unity Technologies

    Joined:
    Jul 25, 2022
    Posts:
    128
    Even thought the Events are running on the GPU, they still have a cost. You can have some "congestion" issue if a lot of particles are dying at the same frame because that would mean a lot of Trigger events at the same frame.
    Also, GPU Event means that you can't have instancing of your VFX.

    In the end, it's always about faking or giving the illusion to the player/viewer. So in your case, if your camera isn't doing close-up shots and your rain is intense enough, no one will notice that the drop and Splash aren't in sync.
    That being said, Trigger events are perfectly fine to use :)
    Just need to be figured out if you really need this accuracy, if not save some performances and off course spend it elsewhere.
     
    Last edited: Jul 10, 2023
    Evgeno likes this.