diff --git a/index.html b/index.html index 1b6b195b646cf6c8ea6329aeffb3e1049cfc57d6..3566b54d04406a85864b4b609b9c3f3d87cb524b 100644 --- a/index.html +++ b/index.html @@ -181,7 +181,7 @@ 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 + pxCenter, u_velocity, u_textureSize*u_scale); + else currentVelocity = 1.0/u_scale*bilinearInterp((fragCoord-pxCenter)*u_scale, u_velocity, u_textureSize*u_scale); //implicitly solve advection @@ -192,13 +192,12 @@ vec2 pos = fragCoord - pxCenter - u_dt*currentVelocity; - //periodic boundary - if (pos.x < 0.0) pos.x += u_textureSize.x-1.0; - if (pos.x >= u_textureSize.x-1.0) pos.x -= u_textureSize.x-1.0; - if (pos.y < 0.0) pos.y += u_textureSize.y-1.0; - if (pos.y >= u_textureSize.y-1.0) pos.y -= u_textureSize.y-1.0; + vec2 materialVal; + //empty boundary + 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(bilinearInterp(pos, u_material, u_textureSize), 0, 0); + gl_FragColor = vec4(materialVal, 0, 0); } </script>