TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: WebGL Fire Simulation

143 pointsby jharsmanalmost 9 years ago

12 comments

kbirkalmost 9 years ago
Nothing will ever impress me more than this WebGL fire &#x2F; explosion effect: <a href="http:&#x2F;&#x2F;glslsandbox.com&#x2F;e#33550.0" rel="nofollow">http:&#x2F;&#x2F;glslsandbox.com&#x2F;e#33550.0</a><p>Warning: may melt your GPU.
评论 #12315437 未加载
评论 #12314423 未加载
评论 #12320469 未加载
评论 #12313833 未加载
jstschalmost 9 years ago
Did something similar a few years ago... a port of the classic demo effect to JS&#x2F;Canvas :) <a href="https:&#x2F;&#x2F;jstsch.com&#x2F;post&#x2F;old-skool_fire_demo_effect_in_javascriptcanvas" rel="nofollow">https:&#x2F;&#x2F;jstsch.com&#x2F;post&#x2F;old-skool_fire_demo_effect_in_javasc...</a>
velcroalmost 9 years ago
Takes me back to the time of Netscape 2.0 where webpages were not complete without a fire.gif background :)<p>BTW did a pure CSS3 fire a while ago too: <a href="http:&#x2F;&#x2F;pag.es&#x2F;fire&#x2F;test.html" rel="nofollow">http:&#x2F;&#x2F;pag.es&#x2F;fire&#x2F;test.html</a>
s-mackealmost 9 years ago
If you want to see fire based on real fluid dynamics take a look at Ron Fedkiw&#x27;s site: <a href="http:&#x2F;&#x2F;physbam.stanford.edu&#x2F;~fedkiw&#x2F;" rel="nofollow">http:&#x2F;&#x2F;physbam.stanford.edu&#x2F;~fedkiw&#x2F;</a><p>For example the following video: <a href="http:&#x2F;&#x2F;physbam.stanford.edu&#x2F;~fedkiw&#x2F;animations&#x2F;fireball.avi" rel="nofollow">http:&#x2F;&#x2F;physbam.stanford.edu&#x2F;~fedkiw&#x2F;animations&#x2F;fireball.avi</a>
andypantsalmost 9 years ago
Parts of it look way too noisy, like TV static.
评论 #12314226 未加载
评论 #12318050 未加载
heywirealmost 9 years ago
I remember doing something similar in x86 assembly back in the 90&#x27;s. int 10h comes to mind.
评论 #12316435 未加载
kruhftalmost 9 years ago
Having fun playing with fire:<p><a href="https:&#x2F;&#x2F;twitter.com&#x2F;kruhft&#x2F;status&#x2F;766304583924592640" rel="nofollow">https:&#x2F;&#x2F;twitter.com&#x2F;kruhft&#x2F;status&#x2F;766304583924592640</a>
CommanderDataalmost 9 years ago
Looks like Runescape fire.
WhitneyLandalmost 9 years ago
Nice work. Effects like these are a great example of programmers combining theory, art, and creative optimizations.
steaminghackeralmost 9 years ago
do you have a shadertoy version of this for comparison?<p>i took this one by ozzy <a href="https:&#x2F;&#x2F;www.shadertoy.com&#x2F;view&#x2F;lsSGWw" rel="nofollow">https:&#x2F;&#x2F;www.shadertoy.com&#x2F;view&#x2F;lsSGWw</a> 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.<p>like this:<p>#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)<p><pre><code> uniform lowp sampler2D source; &#x2F;&#x2F; this item uniform lowp sampler2D chan0; &#x2F;&#x2F; random map uniform lowp float qt_Opacity; &#x2F;&#x2F; inherited opacity of this item varying highp vec2 qt_TexCoord0; uniform highp float time; &#x2F;&#x2F; shader playback time (in seconds) float noise( in vec3 x ) &#x2F;&#x2F; 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)&#x2F;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&lt;=ITERATIONS; i = i + 1.0) { float ifrac = i&#x2F;ITERATIONS; float d = (1.0-ifrac) * DISPLACEMENT; ifrac *= time; float ii = i*i; float y = uv.y*YSCALE*ii - ifrac * SPEED; float x = uv.x*ii; nx += noise( vec3(x-ifrac, y, 0.0)) * d * 2.0; ny += noise( vec3(x+ifrac, y, ifrac&#x2F;ii)) * d; } uv.x += nx; uv.y += ny; &#x2F;&#x2F; a blob shape to distort float flame = clamp( sin(uv.x*3.1416) - uv.y+YOFFSET, 0.0, 1.0 ); flame *= flame; &#x2F;&#x2F; f^2 float ft = flame*flame; &#x2F;&#x2F; f^4 flame *= ft*ft; &#x2F;&#x2F; f^10 &#x2F;&#x2F;lowp vec3 col = pow(flame, TIGHTNESS) * FLAMETONE; lowp vec3 col = flame * FLAMETONE; &#x2F;&#x2F; tonemapping col = col &#x2F; (1.0+col); &#x2F;&#x2F; ~sqrt &#x2F;&#x2F;col = pow(col, vec3(1.0&#x2F;2.2)); col = sqrt(col); col = clamp(col, 0.0, 1.0); lowp vec4 p = texture2D(source, qt_TexCoord0); p.xyz = col; gl_FragColor = p * qt_Opacity; }</code></pre>
评论 #12312440 未加载
评论 #12312381 未加载
mirimiralmost 9 years ago
Is there any way to see the result without WebGL?
uwualmost 9 years ago
can i have this for selected text?