POV-Ray : Documentation : Material Maps
  POV-Ray 3.6 Documentation Online View Tiles   2.5.6 Layered Textures Material Maps

The material_map patterned texture extends the concept of image maps to apply to entire textures rather than solid colors. A material map allows you to wrap a 2-D bit-mapped texture pattern around your 3-D objects.

Instead of placing a solid color of the image on the shape like an image map, an entire texture is specified based on the index or color of the image at that point. You must specify a list of textures to be used like a texture palette rather than the usual color palette.

When used with mapped file types such as GIF, and some PNG and TGA images, the index of the pixel is used as an index into the list of textures you supply. For unmapped file types such as some PNG and TGA images the 8 bit value of the red component in the range 0-255 is used as an index.

If the index of a pixel is greater than the number of textures in your list then the index is taken modulo N where N is the length of your list of textures.

Note: The material_map statement has nothing to do with the material statement. A material_map is not a way to create patterned material. See "Material" for explanation of this unrelated, yet similarly named, older feature. Specifying a Material Map

The syntax for a material_map is:

            BITMAP_TYPE "bitmap.ext"
    gif | tga | iff | ppm | pgm | png | jpeg | tiff | sys
    map_type Type | once | interpolate Type

After the required BITMAP_TYPE keyword is a string expression containing the name of a bitmapped material file of the specified type. Several optional modifiers may follow the file specification. The modifiers are described below.

Note: earlier versions of POV-Ray allowed some modifiers before the BITMAP_TYPE but that syntax is being phased out in favor of the syntax described here.

Note: sys format is a system-specific format such as BMP for Windows or Pict for Macintosh.

Filenames specified in the material_map statements will be searched for in the home (current) directory first and, if not found, will then be searched for in directories specified by any +L or Library_Path options active. This would facilitate keeping all your material maps files in a separate subdirectory and giving a Library_Path option to specify where your library of material maps are. See "Library Paths" for details.

By default, the material is mapped onto the x-y-plane. The material is projected onto the object as though there were a slide projector somewhere in the -z-direction. The material exactly fills the square area from (x,y) coordinates (0,0) to (1,1) regardless of the material's original size in pixels. If you would like to change this default you may translate, rotate or scale the texture to map it onto the object's surface as desired.

The file name is optionally followed by one or more BITMAP_MODIFIERS. There are no modifiers which are unique to a material_map. It only uses the generic bitmap modifiers map_type, once and interpolate described in "Bitmap Modifiers".

Although interpolate is legal in material maps, the color index is interpolated before the texture is chosen. It does not interpolate the final color as you might hope it would. In general, interpolation of material maps serves no useful purpose but this may be fixed in future versions.

Next is one or more texture statements. Each texture in the list corresponds to an index in the bitmap file. For example:

  texture {
     material_map {
        png "povmap.png"
        texture {  //used with index 0
           pigment {color red 0.3 green 0.1 blue 1}
           normal  {ripples 0.85 frequency 10 }
           finish  {specular 0.75}
           scale 5
        texture {  //used with index 1
           pigment {White}
           finish {
             ambient 0 diffuse 0 
             reflection 0.9 specular 0.75
        // used with index 2
        texture {pigment{NeonPink} finish{Luminous}}
        texture {  //used with index 3
           pigment {
              gradient y
              color_map {
                 [0.00 rgb < 1 , 0 , 0>]
                 [0.33 rgb < 0 , 0 , 1>]
                 [0.66 rgb < 0 , 1 , 0>]
                 [1.00 rgb < 1 , 0 , 0>]
           finish{specular 0.75}
           scale 8
     scale 30
     translate <-15, -15, 0>

After a material_map statement but still inside the texture statement you may apply any legal texture modifiers.

Note: no other pigment, normal, or finish statements may be added to the texture outside the material map.

The following is illegal:

  texture {
    material_map {
      gif "matmap.gif"
      texture {T1}
      texture {T2}
      texture {T3}
    finish {phong 1.0}

The finish must be individually added to each texture. Earlier versions of POV-Ray allowed such specifications but they were ignored. The above restrictions on syntax were necessary for various bug fixes. This means some POV-Ray 1.0 scenes using material maps many need minor modifications that cannot be done automatically with the version compatibility mode.

If particular index values are not used in an image then it may be necessary to supply dummy textures. It may be necessary to use a paint program or other utility to examine the map file's palette to determine how to arrange the texture list.

The textures within a material map texture may be layered but material map textures do not work as part of a layered texture. To use a layered texture inside a material map you must declare it as a texture identifier and invoke it in the texture list.

More about "Material" Tiles   2.5.6 Layered Textures

Copyright 2003-2004 Persistence of Vision Raytracer Pty. Ltd.