Tag Archives: GPU

Fluid Simulation and Rendering

For effects like smoke or water, a fluid simulation and rendering approach is needed. There are currently two popular methods for this:

  1. Simulate the fluid on the CPU and send the result as particles to the GPU for rendering as billboards. This is often called a particle system. The technique has been around since the dawn of computer graphics.

  2. Simulate the fluid on the GPU and render the result into textures. This will then be rendered by doing volume ray casting (or ray marching) on the GPU. This technique is new and rather unexplored, and there are few real-life implementations. The result can be very realistic but slow.

Technique one burdens both CPU, bandwidth and GPU. Although in modern solutions, it’s the bandwidth that’s the bottleneck. The GPU based technique only burdens the GPU ( but a lot ).

The movie shows the GPU method of fluid simulation and rendering. More info about this particular implementation in the two last links.

Building an Advanced Particle System
http://www.mysticgd.com/misc/AdvancedParticleSystems.pdf
Building a Million Particle System
http://www.2ld.de/gdc2004/MegaParticlesPaper.pdf
Real-Time Simulation and Rendering of 3D Fluids
http://http.developer.nvidia.com/GPUGems3/gpugems3_ch30.html
The previous page’s authors homepage:
http://www.cs.caltech.edu/~keenan/project_fluid.html

Rendering Countless Blades of Waving Grass

A full article that presents every aspect of implementing billboarded grass fields in games. It uses a vertex shaders for animating the grass in the wind.

A grass rendering

Here’s the full article for free (also the source for the image). Or you could buy the great book “GPU Gems 1″ which also contains the article.
http://http.developer.nvidia.com/GPUGems/gpugems_ch07.html

An implementation of the grass rendering by Nvidia:
http://developer.nvidia.com/object/nature_scene.html

Terrain Texturing with Texture Splatting

The old way to do splatting was to assign a texture for each triangle/quad in the terrain and then let GPU create the fading between the different textures. The following link is to one of the most famous descriptions of such an technique:

http://cbloom.com/3d/techdocs/splatting.txt

The drawback with the method is that is uses fillrate a lot as each triangle is drawn multiple times to archive the fade. Therefore new methods with shaders or multitexturing is to prefer.

Many games uses nowadays alpha maps together with terrain textures to do splatting. The alpha map decides where the texture should be splatted to the terrain. For each texture that should be used on the terrain, one texture channel is needed for the alpha map. The size of this texture determines the quality/resolution of the transitions between different types of textures on the terrain. Below is and example of a such alpha map and how it looks like in a game.

To the left is the textures used, notice how low resolution they are allowed to have. To the right is one of the alpha maps (for the dark grass).  

Alpha Map Texture Splatting

Render of the terrain with splatting in jMonkeyEngine:

Splatting in jMonkeyEngine

In the following link is a comparision of using a single large texture to cover the whole terrain versus using splatting of a few small textures.

http://mikescodeblog.blogspot.com/2007/11/3d-landscape-rendering-with-texture.html 

The game Sid Meier’s Railroads uses a kind of splatting that is either vertex or quad based. Their maps consist of a single texture where each pixel in the texture has a colour that is connected to a specific terrain texture. This allows for a large amount of different textures for the terrain in the same map, but limits the type of fading between different textures.

Example of how a map could look like in RailRoads

Here’s a screenshot of how the maps in the game Supreme Commander are created. The game uses splatting and can only handle five different textures. One is the base texture and fills up where no other texture are. The rest of the four texturelayers requires alpha maps and they are saved in a single RGBA texture. The shot below shows how beautiful splatting can be when implemented correctly. The water is only height dependent and is therefore not splatted.

Alpha Map creation for Supreme Commander

The source of the image is the following tutorial of how to make maps for Supreme Commander:
http://supcom.wikia.com/wiki/Height-_/_Texturemaps_with_image_editing_tools