Coloring algorithm's

An important factor in fractal rendering is the coloring algorithm. The coloring algorithm takes as variable the number of iterations made. A color is assigned to every number of iterations. Usually numbers that are close to eachother will give values close to one another. However some algorithms 'jump' to other colors at certain points. The 'Blue Lagoon', 'Polar' and 'Polar log' algorithm are completely continues.

The following chapters describe the different coloring algorithms used in FracHunt.

You cannot define your own coloring algorithm however if you have that 'killer' coloring algorithm I am likely to integrate it in a later version of FracHunt.

Fantasy 2304

This algorithm uses 2304 colors selected by hand. It is compiled mostly of continues blocks of 256 colors. The "Ln" is taken from the number of iterations and converted to the range 0-2304. The corresponding color is returned.

Red Shift

The same as the previous algorithm except that not the "ln" is taken but the number of iterations is used directly.

RGB

This coloring algorithm works as follows. Count the number of iterations and then use a 64 base numbering system. The first number is Red the second Green and the third Blue. Also shift the resulting bytes to the left so we have maximum brightness.

For example 63 iterations give 255 as Blue and no Red or Green.

64 Iterations will result in 1 as Green value and no Red or Blue.

Blue Lagoon

This is the coloring algorithm I like most.

Picture a cube with as X, Y and Z axes the RGB colors Red, Green and Blue. Now use a sine and cosine to travel through the cube based on the number of iterations and with an offset of half the axe (128). For the Z axes just take the iterations divided by the maximum number of iterations. The sine however has a frequency of 13/7 times that of the cosine.

Polar

Same as the previous algorithm but now the sine and cosine have the same frequency.

Polar Log

Same as blue lagoon but now also the Z axe is a sine with different frequency.

POV-Ray height field

This option let you render your fractal as a POV-Ray height field. You have to save this file as a 'TGA' file. To do this first render your fractal as a POV-Ray height field and then right click on the render window, choose 'Save As...' and specify 'TGA' from the file list drop down box.

Although the number of colors is variable the program silently limits it to 65535 which is the maximum number for a 16 bit number. Lower numbers will reduce the available heights.

The rendered picture consists of Red (MSB) and Green (LSB) values. These are actually 16 bit numbers. The 16 numbers will be mapped to the Y Axe Values in the resulting picture.

Let's do an example if you have some time. Press the next button to render a mandelbrot fractal as a height field.

When the render window is ready right click on it. A context menu will popup. Select 'Save As...'. In the save dialog box select 'TGA' as file type and enter 'C:\FracHunt' as destination.

Note; do not type FracHunt.tga and forget to select the proper file type otherwise it might be saved as FracHunt's native format but with 'tga' as extension! You will get a 'corrupt file' error in POV-Ray and in every graphics program.

Here is a sample scene. Select 'new' from the POV-Ray file menu and cut and paste the following code. If you have saved your tga file in another location you also have to adjust the file specification in the height field.


// Persistence of Vision Ray Tracer Scene Description File
// File: FracHunt.pov
// Vers: 3.1
// Desc: Basic Scene Example
// Date: 06/11/2000
// Auth: pollux@wxs.nl
//

#version 3.1

#include "colors.inc"

global_settings
{
  assumed_gamma 1.0
}

// ----------------------------------------
camera
{
  location  <0.0, 2, -10.0>
  direction 1.5*z
  right     4/3*x
  look_at   <0.0, 0.0,  5>
}

sky_sphere
{
  pigment
  {
    gradient y
    color_map { [0.0 color blue 0.6] [1.0 color rgb 1] }
  }
}

light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <-30, 30, -30>
}   


light_source
{
  0*x // light's position (translated below)
  color red 1.0  green 1.0  blue 1.0  // light's color
  translate <30, 60, -10>
}

// ----------------------------------------

height_field{ tga "c:\FracHunt.tga"      
  smooth

  pigment
  {
    gradient y
    color_map 
    { 
      [0.0 color rgb<0.2,0.2,0.1>] 
      [0.23 1 color rgb<0.2,0.2,0.1> color rgb<1,1,1>] 
    }

  }
  
  translate<-0.5,0,-0.5>
  scale<20,3,20> 
  
  
  translate<0,-1,0>       
               
}

Finally select render and see the following picture.

If you compare it with a 'regular' render of a mandelbrot you might recognize which part of the mandelbrot fractal it is.

The saved 'TGA' file is a regular 32 bit (true color) file.

Copyright 2000,2004 by Ron AF Greve "http://informationsuperhighway.eu+31878753207