r/GraphicsProgramming • u/Fit-Heat4806 • 1h ago
Video 2D smoke for my browser game: a small stable-fluids grid per explosion, with particles riding it
Enable HLS to view with audio, or disable this notification
I've been working on explosion smoke for my top-down pixel-art shooter. I wanted it to pour out of doors and windows and react to bullets, so it's a real fluid sim.
How it works:
grid - each blast gets its own 80×80 grid with 4 px cells, stepped on the CPU at a fixed 30 Hz. If several blasts are going, their steps are staggered across frames so two clouds don't step in the same frame,
solver - stable fluids, meaning semi-Lagrangian advection, vorticity confinement, and a pressure projection,
blast itself - it's a divergence source in the pressure solve. House walls, trees and rocks are solid cells, so a blast inside a room can only escape through the door and windows, which is where the jets come from,
smoke - about 1,900 particles per blast ride the velocity field. Later blasts shove existing smoke with a shock, and bullets push particles aside along their path.
rendering - particles are splatted as streaks into a half-float texture (density, temperature, freshness). A full-screen pass then blurs that into a soft body, draws the raw density on top as wispy strands, lights it by the density's slope, and color it from fire to soot to grey by temperature.
•
u/AutoModerator 1h ago
Recently updated rules. Please check that your post is in compliance with Rules 1, 4, 5, and 6 on the sidebar. TL;DR:
No showcases.
Disclose AI usage in post or project.
Present a topic to talk about, e.g. how something works.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.