GPU-based Smoothed Particle Hydrodynamics
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
GPU-based Smoothed Particle Hydrodynamics
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.
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:
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.
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.
- koirat
- Orc
- Posts: 446
- Joined: Mon Feb 25, 2008 7:56 pm
- x 13
Re: GPU-based Smoothed Particle Hydrodynamics
Impressive. Nice work.
Fluid dynamics is always so spectacular!. Loves it.
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.
- DavlexDesign
- Orc
- Posts: 400
- Joined: Thu Apr 23, 2009 7:23 am
- Location: Australia
- x 19
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
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
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
- cybereality
- Hobgoblin
- Posts: 563
- Joined: Wed Jul 12, 2006 5:40 pm
- x 12
Re: GPU-based Smoothed Particle Hydrodynamics
Very cool. Have you thought about doing any volume rendering to make it look more like water?
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
Hehe, I embrace my geekness:) Feel free to use the code, that's why I uploaded it;PDavlexDesign 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.
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)cybereality wrote:Very cool. Have you thought about doing any volume rendering to make it look more like water?
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
- Xypher
- Gremlin
- Posts: 180
- Joined: Tue Jun 29, 2004 1:35 am
- Location: Richmond, IN; USA
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
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
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
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
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.
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.
-
- Gnoblar
- Posts: 24
- Joined: Mon Dec 14, 2009 12:15 pm
Re: GPU-based Smoothed Particle Hydrodynamics
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!
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!
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
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.
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.
-
- Gnoblar
- Posts: 24
- Joined: Mon Dec 14, 2009 12:15 pm
Re: GPU-based Smoothed Particle Hydrodynamics
Interesting, do you have any movies of this flowing snow?
Greets,
Greets,
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
A quick upload of some movies of the flowing snow simulation.
I hope to do some better captures if I ever find time;P
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
Reason: Inlined videos
- jacmoe
- OGRE Retired Moderator
- Posts: 20570
- Joined: Thu Jan 22, 2004 10:13 am
- Location: Denmark
- x 179
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
Really impressive!
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
- DanielSefton
- Ogre Magi
- Posts: 1235
- Joined: Fri Oct 26, 2007 12:36 am
- Location: Mountain View, CA
- x 10
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
Cool! I also think that would look really effective as lava
- koirat
- Orc
- Posts: 446
- Joined: Mon Feb 25, 2008 7:56 pm
- x 13
Re: GPU-based Smoothed Particle Hydrodynamics
Great.
Do you know how precise is this simulation compared to the real life avalanche.
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.
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
Indeed, the model I used is in fact probably better used for other geomorphological flows, such as lava, mud flows, rock avalanches etc.DanielSefton wrote:Cool! I also think that would look really effective as lava
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).koirat wrote:Do you know how precise is this simulation compared to the real life avalanche.
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.
-
- Gnoblar
- Posts: 24
- Joined: Mon Dec 14, 2009 12:15 pm
Re: GPU-based Smoothed Particle Hydrodynamics
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!
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!
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
Yes, the simple shader used here actually works pretty well for snow;PNefbrethilion 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
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: 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?
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.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!
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.
-
- Kobold
- Posts: 39
- Joined: Mon Sep 12, 2005 10:07 am
- Location: San Francisco
- x 4
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
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.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.
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. 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
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
That is the old screen-space rendering from NVIDIA, the new one seems a bit better?
-
- Kobold
- Posts: 39
- Joined: Mon Sep 12, 2005 10:07 am
- Location: San Francisco
- x 4
- Contact:
Re: GPU-based Smoothed Particle Hydrodynamics
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
Where is a link to the "new" one and where are details about the improvements?
Thanks,
Erwin
-
- Gnoblar
- Posts: 23
- Joined: Fri Jan 29, 2010 1:28 am
Re: GPU-based Smoothed Particle Hydrodynamics
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.
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.
-
- Gnoblar
- Posts: 21
- Joined: Fri Jan 08, 2010 3:33 am
- x 5
Re: GPU-based Smoothed Particle Hydrodynamics
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.