From 14027be2185edc42aec3355cdf357b2bb6cb2c93 Mon Sep 17 00:00:00 2001
From: amandaghassaei <amandaghassaei@gmail.com>
Date: Mon, 3 Apr 2017 21:59:22 -0400
Subject: [PATCH] boundaried

---
 index.html | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/index.html b/index.html
index 3b83d9b..c3008d9 100644
--- a/index.html
+++ b/index.html
@@ -210,7 +210,9 @@
             vec2 currentVelocity;
             if (u_scale == 1.0) currentVelocity = 1.0/u_scale*texture2D(u_velocity, fragCoord/u_textureSize).xy;
             else {
-                currentVelocity = 1.0/u_scale*bilinearInterp((fragCoord-pxCenter)*u_scale + 2.0*pxCenter, u_velocity, (u_textureSize-4.0*pxCenter)*u_scale);
+                vec2 scaledCoord = (fragCoord-pxCenter)*u_scale;
+                vec2 scaledSize = u_textureSize*u_scale;
+                currentVelocity = 1.0/u_scale*bilinearInterp(vec2(1.0, 1.0) + scaledCoord/scaledSize*(scaledSize-vec2(3.0, 3.0)), u_velocity, scaledSize);
             }
 
             //implicitly solve advection
@@ -224,7 +226,7 @@
 
             vec2 materialVal;
             //empty boundary
-            if (pos.x < 0.0 || pos.x >= u_textureSize.x || pos.y < 0.0 || pos.y >= u_textureSize.y) materialVal = vec2(0.0);
+            if (pos.x < 0.0 || pos.x >= u_textureSize.x-1.0 || pos.y < 0.0 || pos.y >= u_textureSize.y-1.0) materialVal = vec2(0.0);
             else materialVal = bilinearInterp(pos, u_material, u_textureSize);
 
             gl_FragColor = vec4(materialVal, 0, 0);
-- 
GitLab