I really implemented the technique described in this chapter using FrameBuffer Objects as a method of rendering texture (but in desktop OpenGL, since WebGL didn not exist at that time), so this is definitely possible. Unfortunately, I no longer believe that I have the code, but if you check any future questions that you have with [webgl], I will see if I can provide some help.
You will need ping-pong several times per frame (five steps are mentioned in the article, but it seems that I remember that the exact number depends on the quality of the simulation you want and on your exact boundary conditions). Using FBOs is quite a bit more efficient than it was when it was written (the author mentions the use of the GeForce FX 5950, which was recently), so I would not worry about the overhead that he mentions in the article. Until you return the data back to the CPU, you should not find the cost of switching between texture and framebuffer too high.
You will have some leakage if your borders are only pixel thick, but this may or may not be acceptable depending on how you do your results and the speed of your fluid. Deepening the boundaries can help, and there are documents that have been written since they explored various ways to limit fluid within the boundaries (I also recall several more effective diffusion / pressure solutions that you can check after the version works ... you will find interesting interesting results if you are looking for documents that provide an article on GPU gems for google Scientist ).
Addendum: I am not sure I fully understand your question about boundaries. The key is that you have to start the shader in every pixel of what you want to be a border, but it really doesn't matter how that pixel gets there, whether it is drawn by lines, dots or triangles (if it the inputs are correct).
In the most general case (which may not apply if you have only a limited number of boundary primitives), you probably have to draw a quadrant covering the framebuffer, since interactions with the velocity and pressure fields are more complex (any surrounding pixel can be a different border pixel , instead of having only certain edges). See Section 38.5.4 (Arbitrary Boundaries) for some explanation of how to do this. If something is not a border, you will not touch the vector field, and if so, instead of hard coding, what directions do you want to look to sum vector values, you will probably finish testing the surrounding pixels and only sum those that donβt are boundaries, so you can enforce boundary conditions.
source share