Monday, May 26

Shader Noise

After some gnashing of teeth -- mostly involving "stupid" stuff like creating a proper 2-channel 3D texture and computing lighting vectors -- I have working shader noise functions in the noise library. The raw noise functions do 3D Perlin, fbm, and turbulent noise. To demo them I created a script that bump-maps three rotating spheres with some simple real-time procedural textures. The first is just a bumpy texture using straight Perlin noise, the second is a crinkly texture using 4 octaves of fbm noise. The third (bottom) is an embossed turbulent noise texture.


Note that all three spheres use exactly the same vertex geometry, the apparent differences in the shapes are entirely due to the shaders. The effect is even better with a moving image, as is usual with these types of things.

Get the code

Tuesday, May 20

Giant Planet Noise

Among other things, I've been recently working on a Perlin noise library for use in Python games. It does all the heavy lifting in native code, for speed. I'm also working on a shader-based noise function so you can do texture generation on the GPU. I have a few examples of how to use the noise functions, and the other day I added one to generate textures for planets (gas giants to start with). Below are three screen shots illustrating how the texture is composed. The first shot is just several octaves of noise stretched parallel to the equator of the planet mixing two colors. The next adds turbulence by warping the first texture using input from a second noise call. The third uses the turbulence value to alter the luminance of the colors, simulating up and down-drafts in the atmosphere. Given the simplicity of the code and short dev time, I was quite happy with the results.


If I were to use these in a game, I would add some additional features: For one I would use per-pixel lighting instead of the default per-vertex in the fixed functionality to get rid of some ugly faceting artifacts on the shadow border and specular highlight. Also, some sort of planetary glow shading would be nice. I'll probably add the latter to the example sometime.

I haven't released the noise library yet, but it does work and you can grab it from my Google code repository if you want to play with it.