Very cool. Any chance of incorporating mouse interaction to stir the fluid? :)
-Ken
Evgeny that's a very interesting demo!
I'd like to extend my work on Energy2D-JS (https://github.com/concord-consortium/energy2d-js) to use calculations on the GPU (right now the calculations are all in JavaScript) and your example makes it easier to understand how this can be done.
Are the result arrays for temperature and velocity stored in the textures?
Is it possible to get these data out of the WebGL context and into JavaScript?
FYI: your links to Jos Stam's work don't work properly because of the extra text in the href attributes:
<a href="Url: http://www.dgp.toronto.edu/people/stam/reality/index.html">Real-Time
Fluid Dynamics for Games</a> and
<a href="Url: http://www.dgp.toronto.edu/people/stam/reality/index.html">Stable
Fluids</a>
Jos Stam's papers on computer graphics: http://www.dgp.toronto.edu/people/stam/reality/Research/pub.html
Real-Time Fluid Dynamics for Games
http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/GDC03.pdf
Stable Fluids
http://www.dgp.toronto.edu/people/stam/reality/Research/pdf/ns.pdf
----
What license are you releasing your fluid-dynamics scripts under?
I see on this page: http://www.ibiblio.org/e-notes/webgl/webgl.htm the statement:
"All scripts are free for any use."
Does this statement cover the code on this page?
http://www.ibiblio.org/e-notes/webgl/gpu/fluid.htm
Would you be willing to release your work under an existing open-source license?
MIT: http://www.opensource.org/licenses/mit-license.php
Simplified BSD: http://www.opensource.org/licenses/BSD-2-Clause
Is your work saved in a source code repository like git?
I would be interested in following your work as you make changes and improvements.
Having your scripts in a git repository would make it easy to see and understand improvements you are making.
To Ken: I'll try to make interactive 2d ink droplet simulations.
To make an accurate (and realistic) simulation one should add:
1. control of iterations convergence
2. diffusion
3. 3D textures for 3D simulations
it is more suitable for WebCL (sorry... but we need WebGL for
visualisation :)
This script just shows that real time simulations on 512x512 grid
(without diffusion) are fast (~20fps) even on a (beginning level) E-350
netbook. So 128x128x128 (/4 due to symmetry) 3d droplet simulations are
possible too. But rather complicated in WebGl without 3D textures.
Evgeny
I don't know if it will work for your needs but you can simulate 3d
textures with 2d textures.
There's a sample copied from
http://code.google.com/p/webglsamples/source/browse/color-adjust/color-adjust.html
vec4 sampleAs3DTexture(sampler2D tex, vec3 texCoord, float size) {
float sliceSize = 1.0 / size; // space of 1 slice
float slicePixelSize = sliceSize / size; // space of 1 pixel
float sliceInnerSize = slicePixelSize * (size - 1.0); // space of size pixels
float zSlice0 = min(floor(texCoord.z * size), size - 1.0);
float zSlice1 = min(zSlice0 + 1.0, size - 1.0);
float xOffset = slicePixelSize * 0.5 + texCoord.x * sliceInnerSize;
float s0 = xOffset + (zSlice0 * sliceSize);
float s1 = xOffset + (zSlice1 * sliceSize);
vec4 slice0Color = texture2D(tex, vec2(s0, texCoord.y));
vec4 slice1Color = texture2D(tex, vec2(s1, texCoord.y));
float zOffset = mod(texCoord.z * size, 1.0);
return mix(slice0Color, slice1Color, zOffset);
}
-Ken
Thanks for raising this issue. It's a recent regression; I've filed http://code.google.com/p/chromium/issues/detail?id=93150 to track it. Still investigating. -Ken
-Ken
As far as I can tell these tests are running identically in Chrome and
Firefox on Windows, as well as in Chrome on the Mac.
If there is some problem, please file a bug at http://crbug.com ,
provide clear reproduction steps, and email me the bug ID once you've
filed it. Thanks.
-Ken