From 3ea3a54b4cda14becf653582c254e0a9e63ad0ac Mon Sep 17 00:00:00 2001 From: amandaghassaei <amandaghassaei@gmail.com> Date: Sun, 2 Apr 2017 19:20:45 -0400 Subject: [PATCH] small changes --- index.html | 4 ++-- main.js | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/index.html b/index.html index afdb0a8..f41143f 100644 --- a/index.html +++ b/index.html @@ -64,8 +64,8 @@ vec2 ceiled = ceil(pos); vec2 floored = floor(pos); - float n = texture2D(u_material, (ceiled+pxCenter)/u_textureSize).x;; - float s = texture2D(u_material, (floored+pxCenter)/u_textureSize).x; + float n = texture2D(u_material, (ceiled+pxCenter)/u_textureSize).x;//actually ne + float s = texture2D(u_material, (floored+pxCenter)/u_textureSize).x;//actually sw if (ceiled.x != floored.x){ float se = texture2D(u_material, (vec2(ceiled.x, floored.y)+pxCenter)/u_textureSize).x; float nw = texture2D(u_material, (vec2(floored.x, ceiled.y)+pxCenter)/u_textureSize).x; diff --git a/main.js b/main.js index 7eb8930..4e24ca7 100755 --- a/main.js +++ b/main.js @@ -62,10 +62,19 @@ function render(){ // gl.uniform2f(mouseCoordLocation, mouseCoordinates[0], mouseCoordinates[1]); // } else gl.uniform1f(mouseEnableLocation, 0); - GPU.step("advect", ["velocity", "material"], "advectedMaterial"); + // Apply the first 3 operators in Equation 12. + // u = advect(u); + // u = diffuse(u); + // u = addForces(u); + // // Now apply the projection operator to the result. + // p = computePressure(u); + // u = subtractPressureGradient(u, p); - GPU.step("render", ["advectedMaterial"]); + GPU.step("advect", ["velocity", "velocity"], "advectedVelocity");//advect velocity + GPU.swapTextures("velocity", "advectedVelocity"); + GPU.step("advect", ["velocity", "material"], "advectedMaterial"); + GPU.step("render", ["advectedMaterial"]); GPU.swapTextures("advectedMaterial", "material"); } else resetWindow(); @@ -96,11 +105,13 @@ function resetWindow(){ for (var i=0;i<height;i++){ for (var j=0;j<width;j++){ var index = 4*(i*width+j); - velocity[index] = i/100; - velocity[index+1] = j/100; + velocity[index] = i/1000; + velocity[index+1] = j/1000; } } GPU.initTextureFromData("velocity", width, height, "FLOAT", velocity, true); + GPU.initTextureFromData("advectedVelocity", width, height, "FLOAT", new Float32Array(width*height*4), true); + GPU.initFrameBufferForTexture("advectedVelocity"); var material = new Float32Array(width*height*4); for (var i=0;i<height;i++){ for (var j=0;j<width;j++){ -- GitLab