r/godot • u/slvshbvck • 6h ago
projects How I made frost you can wipe off a train windscreen in Godot
I wanted the cab in Semaphore to feel like somewhere you could spend a whole night shift. So the windscreen frosts over, and you have to reach up and clear a patch by hand. If I was going to ask players to do that more than once, I wanted the wipe itself to feel good.
The frost shader combines two scales of noise on a chunky 88 × 64 grid. That gives me a thick, uneven crust around the edges and a thinner haze in the middle. The thicker the frost, the blurrier the view through it. That blur comes from sampling a lower mip level of the screen texture.
When you drag the mouse, GDScript paints into a separate 128 × 100 texture. Each texel stores when it was last wiped. The brush leaves slightly older timestamps around the rim of each stroke, so the center clears completely and the edges stay a little cloudy.
The shader compares those timestamps with the in-game clock. The crust and crystal clusters show up first, and the clearer areas fill in later. The cab heater gives you more time before you have to do it again.
My favorite bit is the little scrape as you wipe just enough glass to bring the rails and the red signal into focus.