Commit 14027be2 authored by amandaghassaei's avatar amandaghassaei

boundaried

parent 90c01d49
...@@ -210,7 +210,9 @@ ...@@ -210,7 +210,9 @@
vec2 currentVelocity; vec2 currentVelocity;
if (u_scale == 1.0) currentVelocity = 1.0/u_scale*texture2D(u_velocity, fragCoord/u_textureSize).xy; if (u_scale == 1.0) currentVelocity = 1.0/u_scale*texture2D(u_velocity, fragCoord/u_textureSize).xy;
else { 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 //implicitly solve advection
...@@ -224,7 +226,7 @@ ...@@ -224,7 +226,7 @@
vec2 materialVal; vec2 materialVal;
//empty boundary //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); else materialVal = bilinearInterp(pos, u_material, u_textureSize);
gl_FragColor = vec4(materialVal, 0, 0); gl_FragColor = vec4(materialVal, 0, 0);
......
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