GPU-based Smoothed Particle Hydrodynamics

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!

GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Sun Aug 01, 2010 5:57 pm

Hi, I would like to show you my implementation of SPH (Smoothed Particle Hydrodynamics) using CUDA.
This work is part of my masters thesis in Computer Science at NTNU (Norwegian University of Science and Technology).
I have created a SPH library that uses the power of the GPU (through CUDA) to simulate fluids with extremely high performance ("real-time").
In addition I have created a small demo application that uses Ogre to render the simulation interactively.
The application (and library) supports simple "wall" boundaries as well as "terrain" boundaries. The terrain is rendered using Ogre's excellent new terrain component.

ImageImage

The video below is the "real-time" performance when running on an NVIDIA GTX 470 (more details in the youtube video itself)


I have not seen many projects like this where CUDA/GPU computations are rendered in real-time using Ogre, and as such it might be useful for other people here:)
At the moment only OpenGL works well, though all the code that deals with the CUDA and Ogre integration was made for Direct3D9 to work as well. Unfortunately there are some bugs when using D3D9 (one in the particle shader, and one that makes D3D/Cuda very slow).

Full code can be found here: http://code.google.com/p/gpusphsim/

I hope someone can make use of this, I feel obligated to contribute as much as possible back to this great project:)
Øystein Krog

EDIT; added some quick captures of the flowing snow avalanche simulations:

Last edited by thegeek on Fri Aug 20, 2010 4:10 pm, edited 2 times in total.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby koirat » Sun Aug 01, 2010 7:24 pm

Impressive. Nice work.
Fluid dynamics is always so spectacular!. Loves it.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
koirat
Orc
 
Posts: 446
Kudos: 13
Joined: 25 Feb 2008

Re: GPU-based Smoothed Particle Hydrodynamics

Postby DavlexDesign » Mon Aug 02, 2010 12:57 am

G'day ???
I didn't want to say geek.
Now that's something that's really nice,
Would you have a problem with me maybe using some of this for my planet engine (river dynamics mainly) ?
I have a river system in there already, but something like this could just make the difference for the look and feel of the rivers and water falls.

Alex
User avatar
DavlexDesign
Gnome
 
Posts: 397
Kudos: 16
Joined: 23 Apr 2009
Location: Australia

Re: GPU-based Smoothed Particle Hydrodynamics

Postby cybereality » Mon Aug 02, 2010 2:31 am

Very cool. Have you thought about doing any volume rendering to make it look more like water?
User avatar
cybereality
Orc
 
Posts: 454
Kudos: 6
Joined: 12 Jul 2006

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Mon Aug 02, 2010 5:31 pm

DavlexDesign wrote:G'day ???
I didn't want to say geek.
Now that's something that's really nice,
Would you have a problem with me maybe using some of this for my planet engine (river dynamics mainly) ?
I have a river system in there already, but something like this could just make the difference for the look and feel of the rivers and water falls.

Hehe, I embrace my geekness:) Feel free to use the code, that's why I uploaded it;P

cybereality wrote:Very cool. Have you thought about doing any volume rendering to make it look more like water?

More advanced rendering is certainly something I considered, but I decided to focus on SPH itself so as to limit the scope of my thesis (and because of time constraints;P)
I think the new CUDA fluid sample from NVIDIA (also using SPH) is very interesting. They use a very lightweight (relatively) screen-space rendering technique which seems to produce very good results.
For some very good (implementation) details on this method see the pdf slides from NVIDIA: http://developer.download.nvidia.com/pr ... ffects.pdf
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby Xypher » Tue Aug 03, 2010 2:11 pm

Beautiful work, took me a moment to figure out the significance of your coloring scheme, lol.
Ubuntu Studio 13.04 64-bit
GCC 4.8.1
Ogre3D 1.8.1
AMD Athlon FX 8120 @4Ghz
16Gb G.Skill Ripjaws (PC3-12800)
EVGA GeForce 560 Ti FTW

http://www.hellbatgames.com
User avatar
Xypher
Gremlin
 
Posts: 188
Kudos: 0
Joined: 29 Jun 2004
Location: Richmond, IN; USA

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Tue Aug 03, 2010 6:45 pm

Hehe, the coloring scheme in that video is a hue-based gradient based on the velocity of each particle.
The SPH library itself support other gradients, and you can apply the gradients to physical values of the fluid such as pressure, shear stress etc.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby Nefbrethilion » Sun Aug 15, 2010 8:25 pm

Hi,
last year I did a thesis on SPH myself. I can see it's based on the CUDA particles demo ;-)

What did you use as an acceleration structure? The same as the particles demo or maybe something else?

SPH is nice, and CUDA is fun. The movement of your water looks very good too. Congrats!
Nefbrethilion
Gnoblar
 
Posts: 24
Kudos: 0
Joined: 14 Dec 2009

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Sun Aug 15, 2010 10:37 pm

Thank you, I am very happy I chose to work with CUDA and SPH, the combination is indeed very fun:)
Regarding the acceleration data structure I use the same acceleration structure as the particles demo ("hashed radix sorted uniform grid") (including cudpp/satish radix sorting).

It is also worth mentioning that a large part of my thesis is regarding the use of SPH to model flowing snow avalanches.
What I've shown here is from the "preproject" to my thesis where I implemented Mueller's SPH model and simulate "simple" water-like fluids only.

For my thesis I implemented a more advanced SPH model that more correctly calculates the stress tensor in the fluid.
Using this stress tensor and various (non-newtonian) rheological models it is possible to approximate the behavior of a wide range of fluids, in my case a flowing snow avalanche.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby Nefbrethilion » Wed Aug 18, 2010 12:01 pm

Interesting, do you have any movies of this flowing snow? :-)

Greets,
Nefbrethilion
Gnoblar
 
Posts: 24
Kudos: 0
Joined: 14 Dec 2009

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Fri Aug 20, 2010 4:07 pm

A quick upload of some movies of the flowing snow simulation.
I hope to do some better captures if I ever find time;P

Last edited by jacmoe on Fri Aug 20, 2010 4:08 pm, edited 1 time in total.
Reason: Inlined videos
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby jacmoe » Fri Aug 20, 2010 4:10 pm

Really impressive! :D
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, Fueled by Passion.
Ogre AppWizards - Ogre project wizards for VC 8-10, Code::Blocks and KDevelop.
OgreAssimpConverter - command-line to convert models to Ogre format.
TwOgreGUI - wrapper for AntTweakBar GUI library.
I accept donations | Me on Google+
User avatar
jacmoe
OGRE Moderator
OGRE Moderator
 
Posts: 21024
Kudos: 162
Joined: 22 Jan 2004
Location: Denmark

Re: GPU-based Smoothed Particle Hydrodynamics

Postby DanielSefton » Fri Aug 20, 2010 4:16 pm

Cool! I also think that would look really effective as lava :)
User avatar
DanielSefton
Ogre Magi
 
Posts: 1235
Kudos: 9
Joined: 26 Oct 2007
Location: Mountain View, CA

Re: GPU-based Smoothed Particle Hydrodynamics

Postby koirat » Fri Aug 20, 2010 6:57 pm

Great.

Do you know how precise is this simulation compared to the real life avalanche.
This is a block of text that can be added to posts you make. There is a 255 character limit.
User avatar
koirat
Orc
 
Posts: 446
Kudos: 13
Joined: 25 Feb 2008

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Sun Aug 22, 2010 8:59 pm

DanielSefton wrote:Cool! I also think that would look really effective as lava :)

Indeed, the model I used is in fact probably better used for other geomorphological flows, such as lava, mud flows, rock avalanches etc.

koirat wrote:Do you know how precise is this simulation compared to the real life avalanche.

I did not try to quantify the accuracy/precision of my simulation, indeed the focus of my thesis was not on the accuracy of the simulation, but on the performance of the SPH implementation. (I am a student of computer science, not physics;P).
Simulations of snow avalanches can be accurate, but many simulations employ other methods, such as statistics etc to compute the fallout zones. My approach was to use fluids dynamics, where the viscosity is non-newtonian (not constant), but a function of the shear stress. In this way the behavior of a flowing avalanche can be approximated by tuning the viscosity model.
However, in my thesis I focus a lot more on the performance aspect of SPH simulations (using GPUs). I implemented two different SPH models, one fairly "simple" model (the "water" model by Mueller, and a new "complex" model which uses techniques from several other SPH models. I found that even though the complex model requires a lot more calculations and data, the performance is still very good compared to CPU implementations, and that the performance of SPH on GPUs actually scale fairly well with the complexity of the simulation.
In the literature there are many examples of studies which use SPH for much more accurate simulations, with fairly good results. Compared to more "traditional" fluid simulations SPH is not considered as accurate, or mature, but there is a lot of work being done in this area since SPH has some very compelling attributes.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby Nefbrethilion » Mon Aug 23, 2010 11:59 am

Very interesting, and it was nice to see your avalanche simulation! I guess you can just render the particles as point sprites, just like in the first movie, to get this result? That's a benefit too: you don't really need to extract a surface :-)

The viscosity would be higher when the shear stress is higher, meaning that particles close to the terrain will slow down the movement of upper particles, which will experience less friction and thus flow less viscuous. Do I understand this right?

For the accuracy, SPH makes a lot of simplifications and will never, ever be able to predict flows. The biggest simplifications is ignoring all forces applied by particles "too far away". This speeds up the simulations incredibly but you lose detail. The application of SPH to fluids has been proposed originally by Muller, and is useful to create visual pleasing fluid like effects in realtime (exactly what we want in games or other interactive applications!). Don't forget that the method for avalanches here is not physically accurate either: it is a way to tweak the fluid simulation to look like an avalanche. Which is very clever, but don't "trust" these simulations to predict anything :-)

Again, congrats with your results, I'm impressed!
Nefbrethilion
Gnoblar
 
Posts: 24
Kudos: 0
Joined: 14 Dec 2009

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Mon Aug 23, 2010 7:14 pm

Nefbrethilion wrote:Very interesting, and it was nice to see your avalanche simulation! I guess you can just render the particles as point sprites, just like in the first movie, to get this result? That's a benefit too: you don't really need to extract a surface

Yes, the simple shader used here actually works pretty well for snow;P

Nefbrethilion wrote:The viscosity would be higher when the shear stress is higher, meaning that particles close to the terrain will slow down the movement of upper particles, which will experience less friction and thus flow less viscuous. Do I understand this right?

In these simulations I actually did the opposite; the viscosity is less (flows easier) when the shear stress is higher. In this way the snow will "solidify" when the shear stresses are low (such as at the end of avalanche).

Nefbrethilion wrote:For the accuracy, SPH makes a lot of simplifications and will never, ever be able to predict flows. The biggest simplifications is ignoring all forces applied by particles "too far away". This speeds up the simulations incredibly but you lose detail. The application of SPH to fluids has been proposed originally by Muller, and is useful to create visual pleasing fluid like effects in realtime (exactly what we want in games or other interactive applications!). Don't forget that the method for avalanches here is not physically accurate either: it is a way to tweak the fluid simulation to look like an avalanche. Which is very clever, but don't "trust" these simulations to predict anything :-)

Again, congrats with your results, I'm impressed!


Thank you, however I am not so sure that SPH (and derivate algorithms) will never be able to predict flows. In fact I think it can be argued that some of the "improved" SPH models are pretty good even right now. There exist a very wide range of "corrections" to SPH that mitigate many of the weak points of SPH of improve accuracy a lot.
However my SPH implementations should probably not be used for flow prediction as they are right now;P
Mueller was also far from the first person to employ SPH for fluids, however he might have been (one of?) the first to do so in computer graphics.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby ecoumans » Mon Aug 23, 2010 8:54 pm

I think the new CUDA fluid sample from NVIDIA (also using SPH) is very interesting. They use a very lightweight (relatively) screen-space rendering technique which seems to produce very good results.


The NVIDIA screen-space rendering technique using blending of point sprites looks great from a distance but bad from closeup, see attached running that demo with the camera close-up.
Unless those 'blobby' artifacts are fixed this method doesn't seem useable in outside of a demo that keeps the camera at a distance from the fluid.
zoom_spheres.jpg


Here is another link that discusses various SPH rendering/surface reconstruction methods: http://www.rchoetzlein.com/theory/?p=129

It would be great to have some open source fast and good looking SPH rendering available.
Thanks!
Erwin
ecoumans
Kobold
 
Posts: 39
Kudos: 4
Joined: 12 Sep 2005
Location: San Francisco

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Tue Aug 24, 2010 7:18 pm

That is the old screen-space rendering from NVIDIA, the new one seems a bit better?
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby ecoumans » Tue Aug 24, 2010 8:36 pm

The picture with the artifacts is from a very recent version. From a bigger distance (within the default limited range of the camera) it looks great.

Where is a link to the "new" one and where are details about the improvements?
Thanks,
Erwin
ecoumans
Kobold
 
Posts: 39
Kudos: 4
Joined: 12 Sep 2005
Location: San Francisco

Re: GPU-based Smoothed Particle Hydrodynamics

Postby thegeek » Thu Aug 26, 2010 4:32 pm

Screen Space Fluid Rendering for Games, Simon Green, NVIDIA: http://developer.download.nvidia.com/pr ... ffects.pdf
Here is a video: http://www.youtube.com/watch?v=UYIPg8TEMmU
I'm not sure if this is newer than what you are referring to though.
thegeek
Gnoblar
 
Posts: 23
Kudos: 0
Joined: 29 Jan 2010

Re: GPU-based Smoothed Particle Hydrodynamics

Postby vagrantpostman » Sun Aug 29, 2010 11:30 pm

Excellent work sir. I'm already going to my hand at an ingame render for use with things like SPH as it is; if I come up with anything good I'll post it up in a new thread ;P. Hopefully the two will go hand in hand.
vagrantpostman
Gnoblar
 
Posts: 21
Kudos: 5
Joined: 08 Jan 2010


Return to Showcase

Who is online

Users browsing this forum: Google Adsense [Bot] and 4 guests