POV-Ray : Newsgroups : povray.general : Images as surface textures : Re: Images as surface textures Server Time
1 Aug 2024 02:13:46 EDT (-0400)
  Re: Images as surface textures  
From: Kenneth
Date: 22 May 2006 16:55:01
Message: <web.447224b6a4196442ba6018cb0@news.povray.org>
"POV Shadow" <PCH### [at] gmailcom> wrote:
> I know it's possible to apply bitmap files to an object to create a custom
> texture.  My question is "how?"  What should the code syntax look like?
> What's the best resolution to use? and how should I go about constructing
> the image itself outside of POV ray so that when it's imported in, it does
> what it is supposed to do?
>
> Thanks!

Using an image_map is the trick. The first thing to do is to make your image
in some graphics program like Photoshop. A square image is best (because, by
default, POV will apply the image to a flat "square area" of 1X1 units in
the X-Y plane, beginning at the origin ... that is, from <0,0,0> to
<1,1,1>.)  This is called "planar" mapping, and is projected from the
"front" by default (which can be changed to any orientation.) There are
other types of mapping, but planar is the easiest to understand. The
image_map can of course be scaled up later in POV, to cover a larger area.
The resolution of your image can be anything you like--the bigger the image
the better, so you don't see any individual pixels when itis applied to your
object. (Practically speaking, there's no real reason to make your image any
larger than maybe twice the screen-size of your final rendered POV object.)
Finally, save the image file in a format that POV will recognize for
image_maps (take a look at the documentation.) I'll use the .jpeg format
for the following example.

Then, in POV, having made a 1X1X1-unit box object at the origin (just a
simple object as an example), texture it like this:

texture{
 pigment{
  image_map { jpeg "my_image.jpeg" map_type 0 once interpolate 2}
  scale <...whatever...> // to optionally scale the IMAGE, not the box
  translate <...whatever...> // optional as well
                          }
 finish{
  ambient 1
  diffuse 0
                     }
              }

The MAP_TYPE  0, ONCE and INTERPOLATE 2 keywords are all optional too. What
you should see is your image projected onto the front (and back) faces of
your cube.

Once you get a feel for how this works, then the fun can begin--spherical
and cylindrical mapping using a different MAP_TYPE; using "invisible" alpha
channel areas in the image_map; applying multiple images to different parts
of your object from different directions; using the same image to create
surface normals; etc.

Ken W.


Post a reply to this message

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