Endless POVabilities

- By Sonya Roberts

The Fifth Lesson - Fun With Images

Images can be used to create many special effects to enhance the graphics we create. They can be used as a "height field" to create landscapes and "carved" surfaces, applied to objects as image maps to colour them, as bump maps to give them a textured surface, and as material maps to vary what materials are applied to different areas of an object.

In this lesson, we're going to try out some simple examples of each of these methods. When we're done, we'll have created a simple scene that utilises images in many different ways to create very different effects.

The files for all the examples used here are included in this zip file. As usual, the examples shown here skip over the "lights, camera, background" part of these sample files.



Bonus Section!
While I normally work with an approximate scale of 1 unit=1 foot, starting with this tutorial I'm going to make a switch over to a *NEW* system of measurement (based on an idea posted to the IRTC mailing list). I'm using a file (units.inc) in which I've pre-defined a number of units of measure in terms of how many POV units they equal, and my measurements will be expressed in terms of these units, i.e., "4 inches by 1 foot by 3 cm" will be expressed as "<4*inches,1*foot,3*cm>". Feel free to use, edit, add to, copy, and send to all your friends this file. In this file, 1 unit=1 foot (30 cm), as this seems to be a relatively handy size to use as a base measurement.

My apologies in advance for what will likely be rather frequent mixes of imperial and metric measurements; Canada made the switch to metric when I'd already half-learned the Imperial system, and I have a tendency to use whatever unit of measurement seems handiest for the dimension I'm approximating.



Part 1 - Image Maps

One of the simplest things to do with an image is to use it as in image within your scene. You can make a poster on a wall, a photo in a frame, or a label on a pop can, all through the simple method of taking an image and applying it onto an object.

Let's look at how we'd create three simple objects by applying image maps to very basic shapes. Suppose we were going to make a scene that showed a polaroid photo, a small globe of the world, and a can of pop; by applying image maps to a box, a sphere, and a cylinder respectively we can make the basic shape for each of these objects, and do some minor additional CSG work to add details as needed.

The "polaroid" is the first one we'll tackle. For this, we'll want to apply the image as a planer (flat) mapping. By default, POV projects the image along the X-Y plane, so it fits into the space from <0,0,0> to <1,1,0> with each pixel applying it's colour along the Z-axis from -infinity to +infinity. So for our polaroid photo, we'll need to rotate the texture around the X-axis and scale it to fit the dimensions of our picture area.

image.pov

Polaroid Photo

object {
union {
difference {
box {<0,0,0>,<3.5*inches,1*mm,4.25*inches>}
box {<.25*inch,-1*mm,.75*inch>,<3.25*inches,2*mm,4*inches>}
}
box {
<.25*inch,-1*mm,.75*inch>,<3.25*inches,2*mm,4*inches>
texture {
pigment {
image_map {tga "photo.tga"}
rotate x*90
scale <3.75*inches,1,3.25*inches>
translate <.25*inch,0,.75*inch>
}
finish {ambient .3}
}
}
}
texture {
pigment {color White}
}
rotate y*-20
translate <-5*inches,0,-2*inches>
}


Next we'll create the globe. For this, we'll use a spherical mapping. To tell POV to use a mapping type different than the default planar, we use a parameter called map_type. Spherical mapping is type "1". The image will be formed into a sphere centered around the origin, with the top and bottom edges contracting to become the poles, and the left and right edges joining to form a seam from pole to pole. We'll create our object at the origin as well, so that the image will map correctly to it, and then translate it into it's final position.

Globe of World

object {
sphere {<0,0,0>,2*inches}
texture {
pigment {
image_map {
gif "world.gif"
map_type 1
}
}
finish {ambient .3}
}
rotate x*-15
rotate y*165
translate <3*inches,2*inches,0>
}


Finally, we'll create the can of pop. For this we'll CSG an image mapped cylinder with some additional cylinders and torii to form a basic popcan shape. We tell POV to use a cylindrical mapping for the image by using map_type 2. Cylindrical maps are centered around the Y-axis, and fit from <0,0,0> to <0,1,0>, so we'll need to create our cylinder and scale the texture accordingly.

Can of Pop

object {
union {
cylinder {
<0,0,0>,<0,5*inches,0>,1.25*inches
texture {
pigment {
image_map {
gif "popcan.gif"
map_type 2
}
scale <1,5*inches,1>
rotate y*20
}
finish {
ambient .3
reflection .25
}
}
translate <0,.25*inch,0>
}
torus {1*inches,.25*inches}
difference {
cylinder {<0,5.25*inches,0>,<0,5.5*inches,0>,1.25*inches}
cylinder {<0,5.35*inches,0>,<0,5.6*inches,0>,1*inches}
torus {1.25*inches,.2*inches translate <0,5.5*inches,0>}
}
}
texture {T_Silver_3C}
translate <0,0,1.5*inch>
}


Part 2 of - Fun With Images

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