Live data from Hacker News

Cigarette smoke effect using shaders

garden.bradwoods.io

21–27 of 27 posts

Re: Cigarette smoke effect using shaders

#21

i am so glad threejs is still seeing use, my personal favorite js lib

ThreeJS has never been more popular with +3M downloads / week just prior to the holiday break: https://www.npmjs.com/package/three

in a week of pretty bad news, this is my highlight

Re: Cigarette smoke effect using shaders

#22

In a game this is likely done as simply a prerendered animated texture (atlas). Perhaps in a modern AAA game you might try a GPU particle system with 10k+ particles.

Back in the days of the PS2, you’d just take a couple of long triangle strips, give them a twist or two, then UV-animate a static texture up through them.

Re: Cigarette smoke effect using shaders

#23
As a very young person using an acquired copy of Photoshop with very little knowledge of graphic design, the Filter > Render > Clouds was something that I would never have guessed at just how useful and how often I would actually end up using it after many many hours in the chair.

Re: Cigarette smoke effect using shaders

#24

A bit pedantic but that is a pipe smoke effect not a cigarette effect. Cigarette smoke tends to go horizontal for a ways before kinda going vertical. It works well in the image they use to demo it but the image shows a pipe where it actually looks right.

I'm not sure you can say one behaves one way and the other not, surely depends on lots of variables. As an anecdote, I'm literally sitting with a lit cigarette in my hand right now, and the little smoke that comes from the cigarette itself, goes straight up.

> I'm literally sitting with a lit cigarette in my hand right now

How does it feel to be living my dream rn...

Re: Cigarette smoke effect using shaders

#25

awww, cool effect but I was half hoping for fluid dynamics simulation of the smoke with a lorenz fractal. What I've done is render the "smoke" to a framebuffer then apply some velocity to create some small vorticities.

Interesting point about the fluid dynamics! I’ve always been fascinated by how we can use math and physics to create visuals that feel so alive. A couple years back, I tried to replicate smoke effects in a game and ended up getting lost in fluid simulations—it’s wild how a few equations can lead to such organic results. But I wonder if there's a way to combine both approaches? Like using smooth gradients for the base…

Vector textures is how you fake it like you’re talking about. Just render the fft/liquid to a 3D texture where the RGBf is the normalized vector. Use this texture when you render the smoke billboard to add those vortices in 3D space by multiplying the uv by the vector in the vertex shader and shading like you do with the noise in the pixel shader.

Ooooo… we have smoke like it’s a 1930s billiards bar.

Here’s a few examples that use some fluid dynamics to make “smoke”

https://play.huwroberts.dev/advection/

https://www.shadertoy.com/view/DsKyWm

https://ghostinthecode.net/2016/08/17/fire.html

For fire, the import part is the flame, not the spark. It’s the same methods as above. Everything eventually lands on a 2D texture where you blur or blend it with the scene.

For smoke ribbons this works really well in screen space. For big plumes like mushroom clouds or physical clouds not so much. For those, volumetric SDF is the way to go with rayleigh marching and some gradient of grey.

Anyway, happy coding and enjoy playing with the rules of reality!

Re: Cigarette smoke effect using shaders

#26
Attention aspiring landlords: please consider how expensive it is to remediate a property after years of indoor nicotine use (let alone the health effects to adjoining units, if any). Do whatever you want inside your own house, I don't care.

—Property manager, currently renovating a decades-smoked unit — just absolutely disgusting (and the de-tar chemicals are harsh, while still requiring mechanical dislodging) — I've already suggested that a non-refundible $3,000 deposit become required, if nicotine indoors isn't outright-banned (I don't care about weed indoors — it doesn't leave behind yellow tar everywhere).

So glad that even after decades of minimal drug abuse, cigarettes were never one of my vices.

Post reply on HN