Previous:Cylinder Main Index Next:Julia Fractal

#### Height Field

Height fields are fast, efficient objects that are generally used to create mountains or other raised surfaces out of hundreds of triangles in a mesh. The `height_field` statement syntax is:

HEIGHT_FIELD:

`
  height_field{
` HF_TYPE "filename" [HF_MODIFIER...] `}`
HF_TYPE:
`
  gif
` | `tga` | `pot` | `png` | `pgm` | `ppm` | `sys`
HF_MODIFIER:
`
  hierarchy
` [Boolean] | `
  smooth
` [Boolean] | `
  water_level
` Level |
  OBJECT_MODIFIER

A height field is essentially a one unit wide by one unit long square with a mountainous surface on top. The height of the mountain at each point is taken from the color number or palette index of the pixels in a graphic image file. The maximum height is one, which corresponds to the maximum possible color or palette index value in the image file.

The size and orientation of an un-scaled height field.

The mesh of triangles corresponds directly to the pixels in the image file. Each square formed by four neighboring pixels is divided into two triangles. An image with a resolution of N*M pixels has (N-1)*(M-1) squares that are divided into 2*(N-1)*(M-1) triangles.

Four pixels of an image and the resulting heights and triangles in the height field.

The resolution of the height field is influenced by two factors: the resolution of the image and the resolution of the color/index values. The size of the image determines the resolution in the x- and z-direction. A larger image uses more triangles and looks smoother. The resolution of the color/index value determines the resolution along the y-axis. A height field made from an 8 bit image can have 256 different height levels while one made from a 16 bit image can have up to 65536 different height levels. Thus the second height field will look much smoother in the y-direction if the height field is created appropriately.

The size/resolution of the image does not affect the size of the height field. The un-scaled height field size will always be 1 by 1 by 1. Higher resolution image files will create smaller triangles, not larger height fields.

There are six or possibly seven types of files which can define a height field. The image file type used to create a height field is specified by one of the keywords `gif`, `tga`, `pot`, `png`, `pgm`, `ppm`, and possibly `sys` which is a system specific (e. g. Windows BMP or Macintosh Pict) format file. The GIF, PNG, PGM, and possibly SYS format files are the only ones that can be created using a standard paint program. Though there are paint programs for creating TGA image files they won't be of much use for creating the special 16 bit TGA files used by POV-Ray (see below and "HF_Gray_16" for more details).

In an image file like GIF that uses a color palette the color number is the palette index at a given pixel. Use a paint program to look at the palette of a GIF image. The first color is palette index zero, the second is index one, the third is index two and so on. The last palette entry is index 255. Portions of the image that use low palette entries will result in lower parts of the height field. Portions of the image that use higher palette entries will result in higher parts of the height field.

Height fields created from GIF files can only have 256 different height levels because the maximum number of colors in a GIF file is 256.

The color of the palette entry does not affect the height of the pixel. Color entry 0 could be red, blue, black or orange but the height of any pixel that uses color entry 0 will always be 0. Color entry 255 could be indigo, hot pink, white or sky blue but the height of any pixel that uses color entry 255 will always be 1.

You can create height field GIF images with a paint program or a fractal program like `Fractint`. You can usually get `Fractint` from most of the same sources as POV-Ray.

A POT file is essentially a GIF file with a 16 bit palette. The maximum number of colors in a POT file is 65536. This means a POT height field can have up to 65536 possible height values. This makes it possible to have much smoother height fields. Note that the maximum height of the field is still 1 even though more intermediate values are possible. At the time of this writing the only program that created POT files was a freeware MS-Dos/Windows program called `Fractint`. POT files generated with this fractal program create fantastic landscapes.

The TGA and PPM file formats may be used as a storage device for 16 bit numbers rather than an image file. These formats use the red and green bytes of each pixel to store the high and low bytes of a height value. These files are as smooth as POT files but they must be generated with special custom-made programs. Several programs can create TGA heightfields in the format POV uses, such as Gforge and Terrain Maker.

PNG format heightfields are usually stored in the form of a grayscale image with black corresponding to lower and white to higher parts of the height field. Because PNG files can store up to 16 bits in grayscale images they will be as smooth as TGA and PPM images. Since they are grayscale images you will be able to view them with a regular image viewer. `gforge` can create 16-bit heightfields in PNG format. Color PNG images will be used in the same way as TGA and PPM images.

SYS format is a platform specific file format. See your platform specific documentation for details.

In addition to all the usual object modifiers, there are three additional height field modifiers available.

The optional `water_level` parameter may be added after the file name. It consists of the keyword `water_level` followed by a float value telling the program to ignore parts of the height field below that value. The default value is zero and legal values are between zero and one. For example `water_level 0.5` tells POV-Ray to only render the top half of the height field. The other half is below the water and couldn't be seen anyway. Using `water_level` renders faster than cutting off the lower part using CSG or clipping. This term comes from the popular use of height fields to render landscapes. A height field would be used to create islands and another shape would be used to simulate water around the islands. A large portion of the height field would be obscured by the water so the `water_level` parameter was introduced to allow the ray-tracer to ignore the unseen parts of the height field. `water_level` is also used to cut away unwanted lower values in a height field. For example if you have an image of a fractal on a solid colored background, where the background color is palette entry 0, you can remove the background in the height field by specifying, `water_level 0.001`.

Normally height fields have a rough, jagged look because they are made of lots of flat triangles. Adding the keyword `smooth` causes POV-Ray to modify the surface normal vectors of the triangles in such a way that the lighting and shading of the triangles will give a smooth look. This may allow you to use a lower resolution file for your height field than would otherwise be needed. However, smooth triangles will take longer to render. The default value is off. You may optionally use a boolean value such as `smooth on` or `smooth off`.

In order to speed up the intersection tests an one-level bounding hierarchy is available. By default it is always used but it can be switched off using `hierarchy off` to improve the rendering speed for small height fields (i.e. low resolution images). You may optionally use a boolean value such as `hierarchy on` or `hierarchy off`.

Previous:Cylinder Main Index Next:Julia Fractal