Live data from Hacker News

Show HN: WebGL Fire Simulation

ghostinthecode.net

1–10 of 25 posts

Re: Show HN: WebGL Fire Simulation

#2
do you have a shadertoy version of this for comparison?

i took this one by ozzy https://www.shadertoy.com/view/lsSGWw and tweaked a few things by hand for optimization. saved a few cycles on the code and increased the iterations to 13, which gives a better result.

like this:

#define ITERATIONS 13.0 #define SPEED 10.0 #define DISPLACEMENT 0.05 #define YOFFSET 0.1 #define YSCALE 0.25 #define FLAMETONE vec3(50.0, 5.0, 1.0)

        uniform lowp sampler2D source; // this item
        uniform lowp sampler2D chan0; // random map
        uniform lowp float qt_Opacity; // inherited opacity of this item
        varying highp vec2 qt_TexCoord0;
        uniform highp float    time;           // shader playback time (in seconds)

        float noise( in vec3 x ) // iq noise function
        {
	        vec3 p = floor(x);
            vec3 f = fract(x);
	        f = f*f*(3.0-2.0*f);
	        vec2 uv = (p.xy+vec2(37.0,17.0)*p.z) + f.xy;
	        vec2 rg = texture2D( chan0, (uv + 0.5)/256.0, -100.0 ).yx;
	        return mix( rg.x, rg.y, f.z ) * 2.0 - 1.0;
        }

        void main()
        {
	        vec2 uv = vec2(qt_TexCoord0.s, (1.0 - qt_TexCoord0.t));
	        float nx = 0.0;
	        float ny = 0.0;
            float i;

	        for (i=1.0; i

Re: Show HN: WebGL Fire Simulation

#3

do you have a shadertoy version of this for comparison? i took this one by ozzy https://www.shadertoy.com/view/lsSGWw and tweaked a few things by hand for optimization. saved a few cycles on the code and increased the iterations to 13, which gives a better result. like this: #define ITERATIONS 13.0 #define SPEED 10.0 #define DISPLACEMENT 0.05 #define YOFFSET 0.1 #define YSCALE 0.25 #define FLAMETONE vec3(50.0, 5.0, 1…

Maybe make a shadertoy and post a link?

Re: Show HN: WebGL Fire Simulation

#4

do you have a shadertoy version of this for comparison? i took this one by ozzy https://www.shadertoy.com/view/lsSGWw and tweaked a few things by hand for optimization. saved a few cycles on the code and increased the iterations to 13, which gives a better result. like this: #define ITERATIONS 13.0 #define SPEED 10.0 #define DISPLACEMENT 0.05 #define YOFFSET 0.1 #define YSCALE 0.25 #define FLAMETONE vec3(50.0, 5.0, 1…

I can't get your example code to work, but that is a completely different technique, ray marching a volume displaced by a noise function. This gives nice 3D-looking flames, but the movement tends to look like a scrolling noise function. And it's harder to use arbitrary burning shapes, my simulation supports drawing anything and it will burn.
Post reply on HN