DepthOccluded Rain

I haven’t really seen anything on the forums/discord about this (At least from a simple search of “Rain”) so i’m posting this to give other people the ability to do the same. This is a rain/snow/dust? material that occludes based off of depth (IE: Snow can’t fall past a roof.

Here is the project link:
https://github.com/Xapher/FlaxOccludedRainSample

Eventually there will be a short video explaining how to use it, But here is a short demo of what it does.
https://www.youtube.com/watch?v=vJ6X4lkUE78&feature=youtu.be

Modify the texture, shader, etc how you want to make this better or how you want it, this was a quick “Setup” by me and others can make it better.

7 Likes

Thanks for sharing. I’ve just finished my rain system, but now I need to make it better based on this.

I’d love to see how yours turns out.

I’ve been a bit busy with other things and am afraid to return to my code. My game has lots of overpasses/overhangs and layers while being outdoors, so I struggled to get rain to fall in only the right areas. I had basically a grid of particle emitters using ray tracing from the player’s ground to any ceiling, and only let it rain in certain spots, as well as allow the ground to look wet in only those spots. It got a little convoluted, and I had to fudge it in areas where the player is under a roof, but you see rain way in the distance still. I could significantly simplify it with your second camera approach, which, for some reason, I never thought to do. I will post about it soonish if I am not totally embarrased by how it looks.

Haha nah, it’s not embarrassing, it’s all about learning. Shoulda seen my first implementation before i researched this. Woo… talk about janky and laggy (Not to mention looking like the apocalypse was about to start).

Before this, my rain was:

  1. like 30k particles (Per Cloud)
  2. Used janky collision detection to end the rain
  3. No roof detection, so it just went everywhere.
  4. Mix of Camera Depth Fading so it “Looked” like it was better than it actually was lol

Then, another implementation (The apocalypse):
Kind of the same mesh “Grid” with a panning UV texture. The grid was too dense and it was just near pitch black inside and far away, All my playtesters went “Uh… what is that…?” and then “Oh… gosh…” when they learnt is was rain.

It’s all about learning (Sometimes what NOT to do in my case) and optimizing lol.

1 Like

UPDATE:

I have removed the random rain texture, adding in one i created on my own (Along with a normal map if you want to experiment with it.) As well as i’ve added Snow!

All textures are created by me, and i give full permission to use in whatever scope you want.