RainCast - Decently fast raycast rain!

RainCast - Decently fast raycast rain!

I have made this simple OOP module that makes rain with raycasts and updates in real time, its decently optimized.


Methods:

local RainCast

local rain = RainCast.new()

rain:init()

rain:stop()

rain.Range:Number -- Sets how far the rain extends out around the camera.
rain.DropsPerFrame:Number -- How much droplets spawn per frame
rain.Height:Number -- From how high the rain raycasts down
rain.FrameTime:Number -- How long a frame is
rain.LifeTime:Number -- How long a droplet stays
rain.RainTemplate:Part | Model -- Droplet model/part that gets duplicated around
rain.ActiveDrops -- Returns a table of every active drop.
rain.SoundSettings = {
	["Inside_Sound"]:Sound, -- The sound that gets played when the camera is inside
	["Outside_Sound"]:Sound; -- The sound that gets played when the camera is outside
	["FadeTime"] = 1, -- The fade time between the inside and outside sound
}

-- If you don't set these values then the module will resort to the default values.

Example

local RainCast = require(game.ReplicatedStorage.RainCast)

local rain = RainCast.new()
rain:init()

RainCast has to be run on the client!


Showcase place


Get RainCast


Credits

Iris - @Alyrianix
ObjectCache - @PysephDEV

Version History

v1

8 Likes

Here’s a video since otherwise no one cares. :cold_face:

External Media

As you can see, its decently optimized.

2 Likes

Hi,
looks nice. I see in some places, indoors the rain does not come in.. nice, but why on the rotating block, does rain hit on the ground?

  1. random puddle size variation , of total splash size might be good.. like big drops, med, small..
  2. I color range might add some pop… and or different random set shades… like white, cyan.. blue etc… and or a range where it hits and is white, then goes to blue…
  3. is this client side only?
  4. different puddle textures or flipbooks, random might be cool…
  5. add sound under the players camera.. could just be a loop , not per drop…
  6. random heavy rain to med to light, rain patterns…

cool it working on top of terrain
Uploading: image.png…

nice job on it, keep it going.

maybe have it ignore the player and accessories

sure it would normally hit them.. but my guess is not have drops up in the air might look cleaner

3 Likes

Answering your questions and suggestions:

Why does it hit the ground at the rotating part?
It’s because the rain particle stays there for a second even if something is above it, fixable by perhaps lowering the Lifetime Value.

  1. The particle effect is customisable and this effect is just a default I made. You can edit it yourself since I’m not that good with VFX.
  2. Same answer
  3. Yes
  4. Same answer as 1 and 2.
  5. Next update!
  6. Could consider that, yeah.

I’ll make it ignore the player too, that looks ridiculous :sob:

2 Likes

ooooooh, I like this, but can you possibly add sound to it?

Edit: Whoops, found out that sound DID exist but the speed of the rain is too slow.

4 Likes

does this run with parallel luau?

1 Like

RainCast 1.1

  • Added sounds for being inside and outside
  • Added a max per frame so it doesn’t use more then cached
  • Made rain not hit player

New Methods:

rain.ActiveDrops -- Returns a table of every active drop.
rain.SoundSettings = {
	["Inside_Sound"]:Sound, -- The sound that gets played when the camera is inside
	["Outside_Sound"]:Sound; -- The sound that gets played when the camera is outside
	["FadeTime"] = 1, -- The fade time between the inside and outside sound
}

Get RainCast

1 Like

I have updated the module to add sounds!

1 Like

No, not currently. But i can consider adding this next update.

Nice update!

I was checking out the sounds and it is cool.

I am wondering about tuning, if the sound should be from the players HRP, verse I think it is the camera position. .

Mainly because if you are in a room, such as your test room, and you are looking down camera angle, the rain is as loud as if you are outside..

example

if I pan down, while in the room, it is much softer rain sound

kinda a tricky sound tuning… because if you are in the room., but the camera is outside for sure , like below, you hear the rain hard.. which i guess is good.. but you are in the room… … or is the sound distance based from the camera like 10 studs away or something..? if so then on the top down inside the room , camera.. why do I hear loud rain… if the camera is inside the room, just below the roof? or that might be a sound

next update, 7.8 ) is sound relating to drop per frame… 1 -10 is light sounds id rain, 10 - 25 med, 25 > loud

then update 7.9 ) thunder

then update 8.2 ) lightning

then update 10.7 ) camera shake on thunder clap…

:slight_smile:
nice job on it all !

Thanks for the feedback and love! :happy1:

The bug that you hear the rain loud if you put the camera on the ceiling is because the algorithm to check if your inside is just a raycast going up from your camera (thats why if your character is inside but your camera isnt it sounds loud). This bug happens since the raycast is going trough the ceiling. This can be easily fixed but it isnt actually such a major bug.