home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 2555 / povhlp / hfields.hlp < prev    next >
Encoding:
Text File  |  1994-07-04  |  8.8 KB  |  161 lines

  1.     Height fields are fast, efficient objects that are generally used to
  2.  create mountains or other raised surfaces out of hundreds of triangles in a
  3.  mesh.
  4.  
  5.     A height field is essentially a 1 unit wide by 1 unit long box with a
  6.  mountainous surface on top.  The height of the mountain at each point is
  7.  taken from the color number (palette index) of the pixels in a graphic image
  8.  file.
  9.                     ________     <---- image index 255
  10.                   /        /|
  11.             +1y  ---------- |
  12.                  |        | |
  13.                  |        | |+1z <- Image upper-right
  14.                  |        | /
  15.             0,0,0---------- +1x
  16.                  ^
  17.                  |____ Image lower-left
  18.  
  19.     NOTE: Image resolution is irrelevant to the scale of the heightfield.
  20.  
  21.     The mesh of triangles corresponds directly to the pixels in the image
  22.  file.  In fact, there are two small triangles for every pixel in the image
  23.  file.  The Y (height) component of the triangles is determined by the pal-
  24.  ette index number stored at each location in the image file.  The higher the
  25.  number, the higher the triangle.  The maximum height of an unscaled height
  26.  field is 1 unit.
  27.  
  28.     The higher the resolution of the image file used to create the height
  29.  field, the smoother the height field will look.  A 640 X 480 GIF will create
  30.  a smoother height field than a 320 x 200 GIF.  The size/resolution of the
  31.  image does not affect the size of the height field.  The unscaled height
  32.  field size will always be 1x1.  Higher resolution image files will create
  33.  smaller triangles, not larger height fields.
  34.  
  35.     There are three types files which can define a height field as follows:
  36.        height_field { gif 'filename.gif' }
  37.        height_field { tga 'filename.tga' }
  38.        height_field { pot 'filename.pot' }
  39.  
  40.     The image file used to create a height field can be a GIF, TGA or POT
  41.  format file.  The GIF format is the only one that can be created using a
  42.  standard paint program.
  43.  
  44.     In a GIF file, the color number is the palette index at a given point.
  45.  Use a paint program to look at the palette of a GIF image.  The first color
  46.  is palette index zero, the second is index 1, the third is index 2, and so
  47.  on.  The last palette entry is index 255.  Portions of the image that use
  48.  low palette entries will be lower on the height field.  Portions of the ima-
  49.  ge that use higher palette entries will be higher on the height field.  For
  50.  example: an image that was completely made up of entry 0 would be a flat 1x1
  51.  square.  An image that was completely made up of entry 255 would be a 1x1x1
  52.  cube.
  53.  
  54.     The maximum number of colors in a GIF are 256, so a GIF height field can
  55.  have any number of triangles but they will only 256 different height values.
  56.  
  57.     The color of the palette entry does not affect the height of the pixel.
  58.  Color entry 0 could be red, blue, black, or orange, but the height of any
  59.  pixel that uses color entry 0 will always be 0.  Color entry 255 could be
  60.  indigo, hot pink, white, or sky blue, but the height of any pixel that uses
  61.  color entry 255 will always be 1.
  62.  
  63.     You can create height field GIF images with a paint program or a fractal
  64.  program like 'Fractint'.  If you have access to an IBM-PC, you can get
  65.  Fractint from most of the same sources as POV-Ray.
  66.  
  67.     A POT file is essentially a GIF file with a 16-bit palette.  The ma ximum
  68.  number of colors in a POT file is greater than 32,000.  This means a POT
  69.  height field can have over 32,000 possible height values.  This makes it
  70.  possible to have much smoother height fields.
  71.  
  72.     NOTE: The maximum height of the field is still 1 even though more inter-
  73.  mediate values are possible.
  74.  
  75.     At the time of this writing, the only program that created POT files was
  76.  a freeware IBM-PC program called Fractint.  POT files generated with this
  77.  fractal program create fantastic landscapes.  If you have access to an IBM-
  78.  PC, you can get Fractint from most of the same sources as POV-Ray.
  79.  
  80.     The TGA file format may be used as a storage device for 16-bit numbers
  81.  rather than an image file.  The TGA format uses the red and green bytes of
  82.  each pixel to store the high and low bytes of a height value.  TGA files are
  83.  as smooth as POT files, but they must be generated with special custom-made
  84.  programs.  Currently, this format is of most use to programmers, though you
  85.  may see TGA height field generator programs arriving soon.  There is example
  86.  C source code included with the POV-Ray source archive to create a TGA file
  87.  for use with a height field.
  88.  
  89.     It is nearly impossible to take advantage of the 16 bits of resolution
  90.  offered by the use of tga files in height fields when the tga file is cre-
  91.  ated in a paint program.  A gif file is a better choice for paint created
  92.  height fields in 8 bits.  Also see Appendix B.5 for a tip on creating tga
  93.  files for height fields.
  94.  
  95.     An optional 'water_level' parameter may be added after the file name and
  96.  It consists of the keyword 'water_level' followed by a float value tells the
  97.  program not to look for the height field below that value.  Default value is
  98.  0 and legal values are between 0 and 1.  For example: 'water_level .5' tells
  99.  POV-Ray to only render the top half of the height field.  The other half is
  100.  'below the water' and couldn't be seen anyway.  This term comes from the po-
  101.  pular use of height fields to render landscapes.  A height field would be
  102.  used to create islands and another shape would be used to simulate water
  103.  around the islands.  A large portion of the height field would be obscured
  104.  by the 'water' so the 'water_level' parameter was introduced to allow the
  105.  ray tracer to ignore the unseen parts of the height field.  Water_level is
  106.  also used to 'cut away' unwanted lower values in a height field.  For exam-
  107.  ple: if you have an image of a fractal on a solid colored background, where
  108.  the back ground color is palette entry 0, you can remove the background in
  109.  the height field by specifying, 'water_level .001'
  110.  
  111.     Normally height fields have a rough, jagged look because they are made of
  112.  lots of flat triangles.  Adding the keyword 'smooth' causes POV-Ray to modi-
  113.  fy the surface normal vectors of the triangles in such a way that the light-
  114.  ing and shading of the triangles will give a smooth look.  This may allow
  115.  you to use a lower resolution file for your height field than would other-
  116.  wise be needed.
  117.  
  118.     Height fields can be used in CSG shapes and they can be scaled, rotated
  119.  and translated.  Because they are finite they respond to automatic bounding.
  120.  
  121.     Here are a notes and helpful hints on height fields from their creator,
  122.  Doug Muir:
  123.        'The height field is mapped to the x-z plane, with its lower left
  124.        corner sitting at the origin.  It extends to 1 in the positive x
  125.        direction and to 1 in the positive z direction.  It is maximum 1
  126.        unit high in the y direction.  You can translate it, scale it, and
  127.        rotate it to your heart's content.'
  128.  
  129.     When deciding on what water_level to use, remember, this applies to the
  130.  untransformed height field.  If you are a Fractint user, the water_level
  131.  should be used just like the water_level parameter for 3d projections in
  132.  Fractint.
  133.  
  134.     Here's a detailed explanation of how the ray-tracer creates the height
  135.  field.  You can skip this if you aren't interested in the technical side of
  136.  ray tracing.  This information is not needed to create or use height fields.
  137.  
  138.     To find an intersection with the height field, the ray tracer first
  139.  checks to see if the ray intersects the box which surrounds the height
  140.  field.  Before any transformations, this box's two opposite vertexes are at
  141.  (0, water_level, 0) and (1, 1, 1).  If the box is intersected, the ray
  142.  tracer figures out where, and then follows the line from where the ray
  143.  enters the box to where it leaves the box, checking each pixel it crosses
  144.  for an intersection.
  145.  
  146.     It checks the pixel by dividing it up into two triangles.  The height
  147.  vertex of the triangle is determined by the color index at the corresponding
  148.  position in the GIF, POT, or TGA file.
  149.  
  150.     If your file has a uses the color map randomly, your height field is go-
  151.  ing to look pretty chaotic, with tall, thin spikes shooting up all over the
  152.  place.  Not every GIF will make a good height field.
  153.  
  154.     If you want to get an idea of what your height field will look like, I
  155.  recommend using the IBM-PC program Fractint's 3d projection features to do a
  156.  sort of preview.  If it doesn't look good there, the ray tracer isn't going
  157.  to fix it.  For those of you who can't use Fractint, convert the image pal-
  158.  ette to a gray scale from black at entry 0 to white at entry 255 with smooth
  159.  steps of gray.  The dark parts will lower than the brighter parts, so you
  160.  can get a feel for how the image will look as a height field.
  161.