# rain **Repository Path**: liyu2015/rain ## Basic Information - **Project Name**: rain - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-11-30 - **Last Updated**: 2026-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Rain *A rainy night, seen through a fogged-up window.* Rain is a native macOS screen saver. Drops run down a misted window pane while the night behind it, a street, a river, a neon-soaked corner of Tokyo or a forest of skyscrapers, is a blur of headlights, lamps, windows and neon. It runs in real time in Metal. Nothing is pre-rendered and no video is looped, so it never shows the same thing twice. https://github.com/user-attachments/assets/1ae42c4f-cede-4613-9cfa-1e23ab27f5ca https://github.com/user-attachments/assets/eb79b99e-a0ff-4397-a4ec-4d112a5f673c ## Four nights to choose from Pick a scene in **Options…**. The glass, the drops, the condensation, the rain falling outside and the neon clock are the same in all of them. Only the world behind the pane changes. Scene names are translated into your language, apart from Tokyo, which is Tokyo everywhere. **Street.** A city street at night. Cars come and go, and their headlights and taillights are mirrored in the wet asphalt. A traffic light cycles and cars brake for the red. Apartment windows turn on and off through the night, and a neon sign stutters now and then. Each run builds a new street with its own layout, horizon, lighting mood (warm sodium, cool LED, neon district or a mix) and amount of traffic. You can also put your own photos behind the glass (see below). **River.** The view from a high window across a river. - The far shore has embankment lamps, a bridge with an arc of lights and a skyline of lit windows. - Lit boats glide slowly across the frame, with red and green navigation lights. - Every light is mirrored in the water as a broken, shimmering streak. - Rain hits the river: rings spread and fade on the surface, with tiny splashes that light up wherever they catch a reflection. - In front of the lights you can see the rain itself falling, as fine streaks between the window and the water. **Tokyo.** A narrow street packed with neon, seen from a first-floor window. The camera is turned towards one side of the street, left or right at random. - The signs come in every shape: framed boards, rings, arrows, waves, lettered banners, LED screens, vertical blade signs with columns of glyphs, lit shop fronts and a neon gate over the street with chasing bulbs. - Each sign has its own temperament. It may be steady, blinking, slowly pulsing, flickering in bursts or dead. - The wet road mirrors it all, while taxis and cars pass through and the traffic lights change. **Skyscrapers.** The view from a high floor into a dense forest of towers. - About a hundred towers rise out of hundreds of lower blocks. Nearby buildings fill the bottom of the frame and a solid wall of distant ones runs along the horizon. - The walls are almost black. Only some windows are lit: warm homes, cool offices, now and then a whole office floor. Each window has its own evening and switches on or off every few minutes. - Some towers wear a lit crown. - Red aviation lights blink on the tallest roofs, each to its own rhythm. - Distant buildings sink into a steel-grey haze under a cool night sky with slowly drifting clouds. ## What you'll see **Water that behaves like water.** Rain lands on the glass as tiny beads that grow and merge. Once a drop gets heavy enough it breaks loose and slides down in fits and starts, catching on the glass, drifting sideways and swallowing every drop in its path. Each drop is a tiny lens that shows an upside-down view of the night behind it. **Trails that heal.** A sliding drop wipes a clear path through the condensation and sheds a line of droplets behind it. The droplets slowly dry out and the path fogs over again at its own pace, until you can't tell a drop ever passed. **Condensation with character.** The mist is never even. It forms in patches, gets thicker near the bottom of the pane and is dotted with microscopic beads. Light from outside glows softly through it. **Real lens bokeh.** Everything behind the glass is out of focus, the way it would be through a real lens focused on the window. The discs are polygonal, with brighter rims and faint onion rings, have slight colour fringing and turn into cat's-eyes towards the edges of the frame. **A camera held by a calm hand.** The view drifts slowly and never repeats. The world outside, its lights and the glass are three depth planes, and each moves at its own speed. The far background barely moves, the bokeh and neon move a little more and the pane with its drops moves the most. The parallax gives the scene real depth. **An optional neon clock.** A cyan neon sign hangs just behind the glass in the top-right corner of every scene. It shows the time in your system's format, 12- or 24-hour, with your language's digits. Because it sits behind the pane, it fogs over, refracts upside-down in passing drops and drifts with the parallax like the rest of the scene. Every so often it stutters through a burst of quick dropouts, like a real tube with a tired transformer. On a 12-hour clock, AM and PM are stacked beside the digits. The current one is lit and the other is a switched-off tube that is barely visible. The clock is off by default. **Rain outside, too.** In every scene you can see the rain itself falling between the window and the lights, as fine streaks lit only by what is behind them. Turn on **Heavy rain** in Options for a downpour: a much denser curtain outside, about twice as many drops landing on the glass and twice as many rings on the river. It is off by default. **A different night every time.** Each run builds its scene anew: a different street, a different arrangement of boats and lights on the river, a different side of a Tokyo street, a different skyline. **Made for several displays.** Every display gets its own live screen saver. All displays started together share one randomly built scene, so a multi-monitor setup shows the same night on every display. The rain on each pane is its own, because identical drops side by side would look fake. ## Requirements - macOS 26 or later - A Mac with Metal (any Apple Silicon Mac is perfect) ## Building & installing 1. Open `rain.xcodeproj` in Xcode and build (⌘B). 2. **Product → Show Build Folder in Finder**, then double-click `Rain.saver`. 3. Choose **Rain** in **System Settings → Screen Saver**. 4. Optionally, click **Options…** to pick a **Scene** (Street, River, Tokyo or Skyscrapers) and turn on **Heavy rain** or **Show clock**. The options are translated into every language macOS supports. The top of the sheet shows the version and a link to this page. When reinstalling a new build, first remove the old one (right-click it in System Settings → Delete), quit System Settings, and quit the `legacyScreenSaver` process if it's still running. macOS aggressively caches screen savers. ## Your own street By default, the Street scene is generated procedurally. To use your own photo, drop one or more images named `background*.jpg`, `.heic` or `.png` into the `rain/` folder (for example `background-tokyo.jpg`, `background-2.heic`) and rebuild. Rain picks one at random each time it starts, the same one on every display, and procedural bokeh lights are layered on top. Dark, slightly blurred night shots work best. River, Tokyo and Skyscrapers are always procedural. ## How it works Every frame goes through these GPU passes: | Pass | What it does | | --- | --- | | Shapes | River, Tokyo and Skyscrapers: neon tubes, glowing panels, water streaks and building facades are drawn into their own layer, then blurred at three radii (sharp, soft and a wide haze). Facades are opaque and drawn far to near, so nearer buildings hide the ones behind; their windows are worked out in the shader | | Scene | The world behind the glass (photo or procedural), the blurred shape layers, a few hundred instanced bokeh discs and the neon clock, in HDR. Rain rings on the river are worked out on the water plane, so perspective flattens them on its own | | Blur | A heavy Gaussian blur of the scene, which is what you see through the fog | | Water | Every drop is drawn into one combined height map, so touching drops merge smoothly | | Condensation | A persistent fog and wetness map: water wipes it away, then it slowly re-forms | | Composite | Refraction through each drop, fogged glass, micro-beads, rain falling in front of the lights, filmic tone mapping, vignette and grain | Each layer is sampled with its own parallax offset, so a single camera drift moves the background, the lights and the glass by different amounts. The neon clock is rasterised with Core Text only when the displayed time changes. It is then blurred once into four glow layers, from the white-hot tube core to a wide haze, and the scene shader just adds them up. Drop physics (sticking, sliding, merging, shedding, evaporation), traffic, boats, sign behaviour, aviation lights and the neon flicker run on the CPU. Each scene is a small "world" that hands the renderer its lights and shapes every frame. | File | Contents | | --- | --- | | `RainView.swift` | Screen saver entry point, lifecycle, multi-display handling | | `RainRenderer.swift` | Metal pipeline | | `DropSimulation.swift` | Water on glass | | `SceneWorld.swift` | What every scene provides; shared light and shape emitter | | `BokehField.swift` | Street | | `RiverWorld.swift` | River | | `TokyoWorld.swift` | Tokyo | | `TowersWorld.swift` | Skyscrapers | | `NeonClock.swift` | The neon clock sign and its flicker | | `RainOptions.swift` | Settings, the Options sheet and its translations | | `Shaders.metal` | Everything you actually see | ## Known issues - **Generic thumbnail.** Since macOS 26, System Settings no longer shows custom thumbnails for third-party screen savers (FB21094920). Rain ships `thumbnail.png` and `thumbnail@2x.png` anyway, in case Apple fixes it. - **Taking a screenshot.** Any key press dismisses the screen saver. Run `sleep 10; screencapture ~/Desktop/rain.png` in Terminal and start the preview. Terminal needs the Screen Recording permission for this.