diff --git a/index.html b/index.html index f4d29e248f25ca11a1a1ab00a699992001f7c70a..78692eeacdc1ca2dc57abedee03d8789d3d926d1 100644 --- a/index.html +++ b/index.html @@ -46,15 +46,15 @@ vec2 currentVelocity = texture2D(u_velocity, fragCoord/u_textureSize).xy; //implicitly solve advection - + if (length(currentVelocity) == 0.0) {//no velocity gl_FragColor = vec4(texture2D(u_material, fragCoord/u_textureSize).x, 0, 0, 0); return; } vec2 pxCenter = vec2(0.5, 0.5); - vec2 pos = fragCoord - pxCenter - u_dt*currentVelocity; - if (pos.x < 0.0 || pos.x >= u_textureSize.x || pos.y < 0.0 || pos.y >= u_textureSize.y){ + vec2 pos = fragCoord - pxCenter + u_dt*currentVelocity; + if (pos.x < 0.0 || pos.x >= u_textureSize.x-1.0 || pos.y < 0.0 || pos.y >= u_textureSize.y-1.0){ //boundary gl_FragColor = vec4(0); return;