Friday, January 25, 2008

Noise, Fov...

The two new modules have been incredibly easy to port from the game to the library. Even the samples almost worked right after the first compilation ! If only coding could be always as easy...

The noise module provides easy access to 1d, 2d, 3d and 4d Perlin noise functions and two derived functions : fractional brownian motion (fbm) and turbulence. Exemple of 2d functions :

Perlin noise

Fractional Brownian Motion


The sample allows to easily modify the different parameters and see their impact on the noise function.

The Perlin noise is often associated with procedural texture generation and one can wonder what's its use in a roguelike. I personnally use intensively the 1d Perlin noise function as a 'smooth' random number generator. Look at the Perlin noise 2d squared picture and imagine you follow a straight path in this picture. The value of the pixel you're walking on randomly moves between 0 (black) and 1 (white), but always in a smooth way.

The Field Of View toolkit is really basic and doesn't restrain you from using any map format you want. It is based on the algorithm described on the TCOD website. The FOV sample is a mini dungeon in which you can wander to see how the fov behaves. There's also an 'eye-candy' mode with a realist torch flickering effect obtained with 1d perlin noise. Since tonight, TCOD actually uses the fov toolkit from the library.

Now, I have to find the time to compile this on every platforms (eventually including VS2008 / Borland C++ 5.5 targets as requested recently on r.g.r.d). If no major issue occurs, libtcod-1.1 should be out this week-end \o/