David's Blog

Mostly Hobby Stuff

Archive for the ‘Heightfield Fluids’ Category

Shallow Water Simulator, OpenCL + Rigid Body Interaction

leave a comment »

Just a quick update to post a video of my current progress on my shallow water simulator.

Recently I converted the simulator to OpenCL(from plain C# code) and added rigid body to water and water to rigid body interaction. The conversion to run in parallel was very straightforward, for the rigid body interaction I subdivide the collision shapes into triangles when they first touch the waters bounding box, then just process each triangle separately using atomic operations to update the height and velocity fields. I need to investigate the performance in more detail and generally optimize things, but the initial conversion seems quite fast(the ducks scene runs at 45+fps when not recording video).

I have also added FFT wave simulation for small scale details and/or providing a nice water effect when interaction is not needed(although this is not shown in the video). You can find further details about this method at http://tessendorf.org/ .

Advertisements

Written by therealdblack

March 6, 2011 at 5:51 pm

Real-Time Simulation of Large Bodies of Water with Small Scale Details

leave a comment »

I should highlight this rather useful paper(pdf).

It discusses issues faced when building a 2D heightfield fluid simulator (see my former post about the bare bones simulator I added to my engine).  What is so useful is that it provides many references and nuggets of information needed to extend a basic simulator to increase stability and improve interaction with other systems.

Thankfully it contains only a minimum amount of GPU Compute marketing:-)

Written by therealdblack

July 8, 2010 at 7:22 pm

Higher Resolution Video

leave a comment »

I also have a better quality version of the water shader video on Vimeo, the reason I posted a YouTube version was that Vimeo took like 2 days to encode the video once I uploaded it…

Written by therealdblack

April 12, 2010 at 7:05 pm

Water Shader Video

leave a comment »

I figured out how to capture video and post to my blog, so I am posting a quick test video of my water shader. For anyone that is interested in the simulation of the water a great site to check out is: http://www.matthiasmueller.info/ (don’t be put off by the scary photo:-). What is shown here is the most basic shallow water simulation possible.

So here’s the water video:

Note: The artwork/settings are only preliminary, so things like the shadows, water colour, reflection image etc will look a lot better when I show proper artwork. Also ignore the misbehaving bit of cloth in the background, it is badly tuned and was put in the test scene a while ago to debug something.

Written by therealdblack

April 10, 2010 at 9:45 pm

Water Shader

leave a comment »

Recently I have added support for rendering water(and other similar effects). The features I added:

  • Refraction texture coordinate generation, this is done in screen space with depth checks to ensure only geometry behind the refracting geometry is shown.
  • Support for distortion maps(i.e. a copy of the main render target is made before executing distortion shaders).
  • Reflection texture coordinate generation, the texture coordinates are generated in the texture space of planar reflectors and offsets added for normals which are not planar with the reflector.
  • Support for object space normal maps
  • Support for displacement mapping/texture sampling(in the vertex shader).
  • Support for applying a blur to reflection maps, this allows much lower resolution reflection maps without the reflection becoming pixelated. Plus it looks better too.
  • A Fresnel material node.
  • Support for dynamically binding values to material constants(e.g. the projection matrix for reflectors).

In addition I added a basic shallow water simulation module for dynamic models which allows the user to use vertex painting to specify the height of the ground and water. I will talk later about the water simulation after I have added a few more interesting features.

Below I have added a screen shot of the water shader, in the editor. I will have to get around to figuring out how to post a video in order to do an actual render of the water justice. However, the node based shader editor is beginning to prove its worth, it would have been much more tedious to tweak the water into something acceptable had I not had the ability to re-arrange nodes, tweak values etc etc:-)

In addition I made a few optimizations to improve the frame rate, especially at higher resolutions. In particular I disabled bilinear filtering for a bunch of screen space operations which didn’t need it(going from one render target to another of the same size). This provided a huge boost to the SSAO shader… Which went from being memory bandwidth limited to shader instruction limited. (it works in view space, so can probably be improved further).

mar17

Written by therealdblack

April 10, 2010 at 5:11 pm