|
Creating caves in POV-Ray
by Mauro
Pierluigi
This tutorial will show us a simple but
successfull method to create caves and grottos, by manipulating
height field objects in POV-Ray.
Note: This tutorial is not for beginners and
it assumes that we know already the basics of POV-Ray rendering
system, coordinates and scripting.
An height field is a fast and efficent way to generally
create mountains or other complex surfaces. It needs a particular
image map. The rendering engine reads every single pixel
of the image map and accoring to the color of the pixels
it draws triangles different in height. The more a pixel is
near to white the more the triangle is high, the more a pixel
is near to black the more the triangle is low, and so on with
all the color scales.
So, let's start with creating the image maps. You will need
a program like Photoshop, Photopaint Paint Shop Pro, etc.
Create a black square, let's say about 500x500 pixels, but the
size doesen't matter.

With a gradient fill tool we have to create many spots
like it is shown on picture 1 and we have to fill a large
area paying attention to left the border of the image completely
black. Then save it as *.tga or *.gif file. This
will be the upper part of the cave.
Now we have to create the lower part, to do that we have nothing
else to do than invert the first image using some inverting
function of your preferred graphics application. Save it also
as *.tga or *.gif image.

In picture 2 are shown the two images map that
I created for the two height field objects.
This two pictures will create two opposite and simmetric height
field objects, the first will develope in an upper direction
and the second in a lower direction.
Now we are going to write the code to see how the height
field will look after the rendering.
#include "colors.inc"
camera {
location <5, 8, -6>
look_at <5, 3, 0>
}
light_source {
<0, 50, -50> color White }
height_field {
tga "map1.tga"
pigment { Yellow }
scale <10, 1, 10>
}

The result of this rendering is shown in
picture 3, to look at the other height field we
just have to change the name of the image file from map1.tga
to map2.tga or whatever we called it. The result of the second
is shown in picture 4.

Now we have to join the two objects togheter, the flat areas
shown in the pictures must be in the same Y position. So the
code for that is the following:
#include "colors.inc"
camera {
location
<5, 1, -8>
look_at <5, 1, 0>
}
light_source {
<0, 50, -50> color White shadowless }
union {
height_field { tga "map2.tga"
scale <1, 5, 1>
}
height_field { tga "map1.tga"
translate -3*y
}
scale <10, 1, 10>
pigment { Yellow }
}

The result of the rendering is shown on
picture 5, as we see they are the upper part and the
lower part of a cave and they are perfectly joining each other
in the shape. We scaled the upper part to make it look more
high and give it a more real look. If we change the value of
the translation from -3*y to -1*y we see that
the two flat areas joins perfectly how shown in picture 6.

Now if we shift the camera position inside this object we will
see like we are inside a cave. The result of the rendering is
shown on picture 7 and we can see how the shape of the
two objects are perfectly joining each other.

The result of the scene with textures and some objects inside
is shown on picture 8.

Mauro Pierluigi is a
graphic designer and programmer and collaborated for years with
some of the most important italian ISP. He owns a company which
creates multimedia products, animations, web design, etc, find
out more about him at www.pmworld.net
Editors Note: For more information on POVRAY,
try http://www.povray.org/
|