Endless POVabilities

- By Sonya Roberts

The Fifth Lesson - Fun With Images -- Continued

Part 2 - Material Maps

As well as applying an image to an object to colour it, we can use an image to define where areas of different materials are to be applied. For the material mapping process, we need to use an indexed color image such as a GIF (some versions of PNG or TGA are also supported - please refer to the POVRay manual for further information). Each index of the image can be replaced with a different material. Suppose, for example, that we wanted to make a floor of inlaid stone tiles; we'd create a simple image in a few colours, that defines the areas the different stone types are to occupy, and then we'd use this as the template for a tile.

Tiled Floor

object {
plane {<0,1,0>,0}
texture {
material_map {
gif "tile.gif"
texture {T_Stone13}
texture {T_Stone8}
texture {T_Stone3}
texture {T_Stone11}
texture {pigment {color Black}}
}
rotate x*90
}
}






Part 3 - Bump Maps

Images can also be used to create the appearance of surface texture or detailing. In the same way that using a normal pattern can mimic patterns of bumps, ripples, and wrinkles (among other things), images can be used to create the illusion of textures such as woven fabrics, corrugated metal, low relief carving, brush patterns, embossing, etc. For bump maps, the apparent height of the "bump" is calculated based on the greyscale brightness of the image at that point (note - colour images are automatically evaluated as if they were greyscale during the parsing process; there is no need to convert them to greyscale ahead of time). Black is the lowest areas, white is the highest areas. By playing with the scaling values, the illusion of shallower or deeper areas can be created. However, it's only an illusion; when viewed in profile, the object will still be flat, and any shadows cast by the object will follow the form of the primitives, not of the bumps. For this reason, this method is only suitable for low-relief textures. Let's use bump maps to create a card embossed with a decorative border and a name.

Embossed Card

object {
box {<0,0,0>,<5*inches,1.5*mm,3*inches>}
texture {
pigment {color Wheat}
normal {
bump_map {tga "emboss.tga"}
rotate x*90
scale <5*inches,1,3*inches>
}
finish {phong .2}
}
rotate y*5
translate <-2.5*inches,0,-3*inches>
}






Part 4 - Height Fields

Now suppose we wanted to use an image to create something in "high relief", like a mountain range, or a carved wooden cookie mold. For this, we would use a special kind of object called a height field. A height field is an object that is created by taking an image and turning it into a mesh of triangles, with the height of each vertex being determined by the index number (for GIF and other colour-indexed formats) or the grayscale-equivalent value of the pixels. Let's take a fairly simple example that works under either system - an image in 256 shades of gray, with black as index 0 and white as index 255. The black/low index pixels will become "low" or valley areas of the height field. The white/high index pixels will become peaks. Unlike other image based POV items, there is currently only one type of mapping supported (planar) and the orientation is along the Y-axis rather than the Z-axis, with the height field created to fit within a cube running from <0,0,0> to <1,1,1>.

Miniature Mountain

object {
union {
intersection {
height_field {
gif "island1.gif"
smooth
translate <-.5*foot,.05*inch,-.5*foot>
scale <4.5*inches,2*inches,4.5*inches>
}
cylinder {&kt;0,0,0>,<0,5*inches,0>,2*inches}
texture {
pigment {
image_map {gif "island2.gif"}
rotate x*90
translate <-.5*foot,0,-.5*foot>
scale <4.5*inches,4*inches,4.5*inches>
}
}
translate <0,.5*inches,0>
}
torus {
2*inches,.1*inches
translate <0,.6*inches,0>
texture {T_Brass_3C}
}
torus {
2*inches,.25*inches
translate <0,.25*inches,0>
texture {T_Stone10}
}
}
translate <-5.5*inches,0,5*inches>
}





Part 5 of - Fun With Images

<Crystal Clarity> <Topas Try Me's> <Povabilities> <Soap Box> <Cranky's Corner>
<Top> <Home> <CG Web Board> <Contact>