/Tutorials Web demo All tutorials ← Site

How to animate rain over pixel art

Rain is the effect people hand-animate most often, and it is the one least worth hand-animating. Every drop is the same shape doing the same thing at a different offset. Here is how to get it from a single rule instead.

Phluxel · Windows · a free edition covers everything on this page

What you need

The steps

Step 1

Paint the scene once

Draw your background, characters and props as a single still image — or import a PNG you already have. There are no layers to set up: the picture you paint is the simulation state, which is why the effect can react to it.

Step 2

Add the rule

Open the Rule Editor and create a new rule, or pick Rain Streaks (behind objects, BASE) from the template list and skip the typing. This is the whole thing:

Rain Streaks (behind objects, BASE)Phlux
PARAM _rate = 6;
Y == 0 ? (RN < _rate ? [255, 90, 150, 255] : [BASE]) :
(N.B > 230 & N.R < 120 & BASE.G < 150 ? [255, 90, 150, 255] :
(B > 230 & R < 120 ? [BASE]))

_rate is the density: how likely each cell along the top edge is to spawn a drop on a given step. Raise it for a downpour, lower it for drizzle. You can also keyframe it on the timeline so the rain builds during the loop.

Step 3

Turn Global on

Toggle the globe icon on the rule so it applies to every cell rather than only the cells you painted it onto. Effects that sweep across a scene are almost always global.

Step 4

Press play

The grid starts stepping immediately. Adjust the live parameters below the script while it runs — you do not need to stop and restart to see a change.

Step 5

Export the loop

File ▸ Export ▸ Animation. Set the frame count to the length of one cycle and Phluxel writes a seamlessly looping GIF. The same dialog exports MP4 and APNG, and there is a separate sprite sheet export if you are taking this into a game engine.

Why it goes behind your artwork

Rain only enters a cell whose original colour has green below 150. That is what makes drops vanish behind bright objects instead of painting over them — the object absorbs them.

This is the part that usually surprises people coming from layer-based tools. There is no effect layer to composite. BASE is a token that always reads the original, untouched version of the cell, so a rule can paint over your scene one step and hand it back the next.

Do not paint saturated blue in the scene. The rule identifies a raindrop by its colour: blue above 230 with red below 120. Anything in your artwork matching that description will be treated as a drop and start falling. If your scene needs deep blue, shift it slightly (raise red past 120, or drop blue below 230) and everything behaves again.

Making it loop seamlessly

Set Max steps in the Playback panel to the number of frames you want, and the simulation returns to the start when it reaches that count. Export the same number of frames and the GIF has no visible seam. If the loop still jumps, the usual cause is a motion cycle that does not divide evenly into the frame count — a drop that needs 21 steps to cross a 20-frame loop will always stutter.

Tip. The timeline can ramp a parameter while the loop plays. Keyframe _rate from low to high and the weather builds over the animation instead of staying constant.

Try it without installing anything

Phluxel runs in the browser as a demo, and the free desktop edition has every feature with a watermark on exports.

Open the browser demo Download free (Windows) Wishlist on Steam

More Phluxel tutorials

How to animate falling snow in pixel artPaint it once, then one rule animates it. How to animate pixel art fire from a still drawingPaint it once, then one rule animates it. How to convert an image into pixel art with a locked paletteDownscale cleanly and snap the result to a Lospec palette.