Pages

Showing posts with label fluid dynamics. Show all posts
Showing posts with label fluid dynamics. Show all posts

Wednesday, 3 March 2010

3D Waves: Projected 2D fluid simulation

I found this experiment quite interesting. In an earlier post I gave an example of a 2-dimension fluid simulation that I'd been working on using the Navier-Stokes equations. I decided to play around with this code a bit and use the 3D point engine from my last experiment in conjunction with the fluid engine. The density from the fluid simulation is simply projected onto the XZ plane with density values corresponding to the height of corresponding point particles.

The results are certainly interesting. Click the image below to start up the experiment. To create waves just move your mouse around and drag the movie to change the camera angle. I decided to add a slight fade and blur on the particles which makes it look very pretty. Enjoy!

Wednesday, 30 December 2009

My Fluid Dynamics Engine in AS3

This post and my recent experiments have been inspired largely by the work of Eugene Zatepyakin and that of Jos Stam on fluid dynamics.

Jos Stam's article on fluid dynamics for games started it all, having a similar effect on this area of research as Thomas Jakobsen's article had on the use of Verlet Integration in physics engines. The beauty of the fluid solver is that it provides a computationally quick and stable approach to simulation of fluid dynamics, which can be easily expanded into 3 dimensions and used to solve many more advanced problems.

Eugene Zatepyakin was the next step in the chain creating a fast engine in AS3 which I talked about in a previous post. I decided to write my own version of the engine and here it is:

The first example shows 4000 particles floating around in the simulated fluid - just click on it to launch to flash file - once it is running click and drag to make the fluid move.





The second example shows the pressure grid being used as a displacement filter for the image below. This starts to add a bit of realism and creates a more three dimensional feel.

Monday, 5 October 2009

Fluid Dynamics using AS3

As a physicist I find things like this incredible. Fluids are extremely complex mathematically, so when I came across Eugine Zatepuakin's work on fluid dynamics I was amazed by the speed and accuracy of the simulations!

Just click the right image for a full preview, you'll be blown away! When I've got a bit more time I'll write a thread explaining how fluid dynamics simulations work, and explain the basic principles of coding something like this in flash, but for now check it out!

Move your mouse around to create dense regions and click to change the rendering mode. I love that flash is capable of handling these kinds of calculations. I remember playing a game called plasma pong which used very similar fluid dynamics to Eugine's model. Unfortunately the game is no longer available for download because pong is a trademark of Atari but here is a nice little video of the game in action.


Here is a little youtube clip of the game, just click to launch it! :)

Enjoy!

Wednesday, 13 May 2009

Liquid Webcam

I was just playing around with the convolution and displacement map filters in flash and here are few of the effects I managed to create. The first two use the convolution filter to displace pixels and cause the ripple like effects found. The 3rd just takes a pixel and averages it's height with the heights of surrounding pixels. The displacement map filter is then used to transform a webcam stream. In the first two examples the diffraction effect is actually quite realistic although a custom pixel transform would have to be created for factors such as surface angle to be taken into account.

A word of advice, only run one of these at a time because 3 webcam streams with filters can be quite CPU intensive!

So first we have a ripple effect. Click and drag to create ripples on the webcam stream.

Flash 10 demo

Next we have a rain effect. Random pixels are created which are the convoluted and create the effect of rain drops hitting water.

Flash 10 demo

Another mouse drag effect. Clicking the mouse increases the height of the water. This one is quite an interesting effect, not sure its as aesthetically pleasing as the other two though!


Enjoy!