Commit 8cf237b5 authored by amandaghassaei's avatar amandaghassaei


parent f24f6b8e

1.69 MB


1.99 MB

......@@ -60,7 +60,7 @@
float mat1 = texture2D(u_material, fragCoord/u_textureSize).x;
vec3 color = vec3(250.0/255.0, 235.0/255.0, 215.0/255.0);
vec3 color = vec3(0.98, 0.93, 0.84);
gl_FragColor = vec4(mat1*color, 1);
......@@ -352,10 +352,11 @@
It exhibits a phenomenon called <a href="" target="_blank">vortex shedding</a>,
where vortices of alternating spin spontaneously emerge behind the obstacle.
To increase performance, I solved for the velocity vector field of the fluid at a lower resolution than I used to compute the distribution of material moving through the fluid (shown in black and white).
I used bilinear interpolation to smooth out artifacts caused by this speedup.
I used bilinear interpolation to smooth out most artifacts caused by this speedup - though you can still see some artifacts around the boundary of the obstacle.
I ignored the viscous diffusion term from the Navier-Stokes formula to encourage better vortex formation (the implicit advection solving I'm using creates enough diffusion on its own for this system).
Click and drag to apply a force to the fluid.
Click and drag to apply a force to the fluid:
<img style="width:100%" src="img2.png"/>
To learn more about the math involved, check out the following sources:<br/>
<a href="" target="_blank">Fast Fluid Dynamics Simulation on the GPU</a> - a very well written tutorial about programming the Navier-Stokes equations on a GPU.
......@@ -26,7 +26,7 @@ canvas {
width: 30px;
text-align: center;
position: absolute;
color: #fff;
color: #faebd7;
......@@ -216,12 +216,14 @@ function resetWindow(){
var numCols = Math.floor(actualHeight/10);
if (numCols%2 == 1) numCols--;
var numPx = actualHeight/numCols;
var material = new Float32Array(actualWidth*actualHeight*4);
for (var i=0;i<actualHeight;i++){
for (var j=0;j<actualWidth;j++){
var index = 4*(i*actualWidth+j);
if (j==0 && Math.round(i/actualHeight*numCols)%2==0) material[index] = 1.0;
if (j==0 && Math.floor((i-2)/numPx)%2==0) material[index] = 1.0;
GPU.initTextureFromData("material", actualWidth, actualHeight, "FLOAT", material, true);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment