UV Mapping
Home Up UV Mapping Patterns Meshes Radiosity Photons Misc. Changes Media

 

Description

All textures in POV are defined in 3 dimensions. Even planar image mapping is done this way. However, it is sometimes more desireable to have the texture defined for the surface of the object. This is especially true for bicubic_patch objects and mesh objects, that can be stretched and compressed. When the the object is stretched or compressed, it would be nice for the texture to be "glued" to the object's surface and follow the object's deformations.

A new keyword has been added to object modifiers. If the modifier "uv_mapping" is specified, then that object's texture will be mapped to it using surface coordinates (u and v) instead of spacial coordinates (x, y, and z).  This is done by taking a slice of the object's regular 3D texture from the XY plane and wrapping it around the surface of the object, following the object's surface coordinates.

Important:  The "uv_mapping" keyword must be specified before the object is given its texture!

Important:  With uv_mapped objects, it does not matter whether a texture is added to the object before or after the object's transformations!

Demonstration of UV Mapping on a Lathe

DEMO_SOR.gif (23150 bytes)

a)  The texture exists throughout <x,y,z> space.  We take one slice from the plane z=0.  For a lathe object, as shown here, we use the square where (u,v) = (0,0) through (1,1).

b)  This shows a lathe object which is textured using normal mapping with a checker texture (the texture is scaled by 0.25 in every direction).   It visualizes the texture being "wrapped" around the object.

c)  Here we see the same lathe, but this time it is uv_mapped.

Example of POV-Ray Code

bicubic_patch
{
  <bicubic_patch specific stuff>
    .
    :
  uv_mapping

  texture { MyFavoriteWoodTexture }

  scale A
  rotate B
  translate C
}                

Supported Objects

Surface mapping is currently defined for the following objects:

Object

Description

bicubic_patch UV coordinates are based on the patch's parametric coordinates.  They stretch with the control points.  The default range is (0..1) and can be changed.
mesh, mesh2 UV coordinates are defined for each vertex and interpolated between.
lathe, sor modified spherical mapping... the u coordinate (0..1) wraps around the y axis, while the v coordinate is linked to the object's control points (also ranging 0..1).

Surface of Revolution also has special disc mapping on the end caps if the object is not 'open.'

sphere boring spherical mapping
box boxmap.gif (3854 bytes)image is wrapped around the box, as shown to the left.

Some other objects that should eventually get surface mapping are:  triangle, smooth triangle, cone, cylinder, superellipsoid, disc, height_field, plane, polygon, prism, and torus.  If anyone wants to help me program with these, let me know.

Objects that will probably never get surface mapping are:  blobs, julia fractals, cubic, polynomial, quadric, quartic, text, and isosurfaces (if these two patches are ever implemented concurrently).

Other changes related to UV mapping

I've added a new keyword, uv_vectors. This keyword can be used in bicubic patches to set the UV coordinates for the starting and ending corners of the patch. The default is

  uv_vectors <0,0>,<1,1>  // syntax is "uv_vectors <start>,<end>"

If you had another patch sitting right next to this (as happens often with sPatch or Moray), you could map the exact same texture to it but use something like

  uv_vectors <0,1>,<1,2>  // syntax is "uv_vectors <start>,<end>"

(depending on which side of this patch the other is on) so that the two textures fit seamlessly together.

This new keyword also shows up in triangle meshes (the original kind), and soon it will be in single triangles, too. Inside each mesh triangle, you can specify the UV coordinates for each of the three verticies with:

  uv_vectors <uv1>,<uv2>,<uv3>

This goes right after the coordinates (or coordinates & normals with smooth triangles) and right before the texture. Now that I think about it, I could maybe make the syntax a bit more flexible (allow you to interchange "uv_vectors" and "texture").

This page was last updated November 17, 1998.

If you have any comments, please email me. My email address is Nathan at Kopp dot Com.