See what's going on with flipcode!


Submitted by , posted on 11 March 2003

Image Description, by

This shot shows a collection of cg shaders, which render various astronomical bodies, entirely on the GPU. While you get can the full details in the upcoming book ShaderX2, below is a brief description of what's being done in the shot.

First, the galaxy effect. This is a pretty simple cg shader, which works by taking a texture filled with random values, and then based on the distance from the center of the quad being textured, performs various mathematical equations, which produce the galaxy shape. The stars also twinkle, even though I know that is not very realistic(however,it looks nice). Many different types and variations of galaxies are possible, with just a few small modification of the equations.

The sun is done using 3D turbulence, which is animated by dragging it though time. The 3D turbulence is built using a type of value noise, which I found to be cheaper then a full perlin noise implementation. The cornea around the sun is a ring, the vertex positions of which are generated and displaced on the GPU.

Lastly the planet. The planet requires several shaders to complete. Firstly its geometry is deformed using a hybrid multifractal which is built with perlin noise(Perlin noise is much cheaper in a vertex shader then in a pixel shader). After which, the planet is textured, by taking the height of planet, adding noise to the height, and using this value to index into a planet texture. The planet is also light per pixel, however its normals are not perturbed by geometry changes, as I was unable to find a way to do this and remain within instruction count limits. The clouds are done with several octaves of the same noise function used to generate the sun.

Jesse Laeuchli

Image of the Day Gallery



Copyright 1999-2008 (C) FLIPCODE.COM and/or the original content author(s). All rights reserved.
Please read our Terms, Conditions, and Privacy information.