next up previous contents index
Next: Bump Mapping Up: Defining your own textures Previous: Chess Board Texture

Noise Texture

    

Noise is a continuous pseudorandom function which returns a number between 0 and 1. noise_3 is a function of a three dimensional vector. 

double noise_3(double *samplept)

Other noise functions are in the Mirage source code file noise.c

Three dimensional noise can be used to vary the colour of an object. The Noisetexture  class is defined in useful.h and useful.c.

The Noisetexture constructor requires three variables.

  Noisetexture(double scale, double amt, int prec);

amt is the amount the noise texture varies the material colour. It should be between 0 and 1. 0 is no variance and 1 varies the colour from black to the material colour. scale varies the size of the space which the noise texture is selected over. Noise does not vary much over a small area so if small objects are to be textured then the scale factor can be increased. prec is the texture precedence. If an object has just one texture applied to it then just set this to zero. However if there are several textures, higher precedence textures are applied first. A negative precedence overrides all other textures.

Figure 15 shows three spheres textured with Noisetexture with different variables. Figure 16 shows an example use of Noisetexture to create a woodgrain pattern.

  figure415
Figure 15: Varying scale and amt in Noise Texture

  figure420
Figure 16: Stretched Noise Texture (WoodGrain)

  object bluesphere = new_sphere();
  bluesphere->material = blue;
  bluesphere->texture = new Noisetexture(1,1,0);
  LINK(the_scene, PLUS, shift(-3,0,0,bind(bluesphere)));

  object redsphere = new_sphere();
  redsphere->material = red;
  redsphere->texture = new Noisetexture(10,1,0);
  LINK(the_scene, PLUS, bind(redsphere));

  object greensphere = new_sphere();
  greensphere->material = green;
  greensphere->texture = new Noisetexture(20,0.5,0);
  LINK(the_scene, PLUS, shift(3,0,0,bind(greensphere)));

  //fake wood plane.
  object the_floor = bind(reflect(Z,new_plane()));
  the_floor->material = brown;
  the_floor->texture = new Noisetexture(5, 1, 0);
  LINK(the_scene, PLUS, bind(stretch(8, 1.0, 1.0, the_floor)));
   



Sophie Day
Fri Feb 20 15:47:19 NZDT 1998