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.
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:
like 30k particles (Per Cloud)
Used janky collision detection to end the rain
No roof detection, so it just went everywhere.
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.
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.