The Online POV-Ray Tutorial
Lights
The following topics are covered in this section.
The following scene will be used to demonstrate the effects of different lighting
effects.
Adaptive
The adaptive keyword controls the rendering of area
lights. Normally, when you create an area light, POV-Ray has to test the
visibility of each point in the array. So for a 5 by 5 area light, POV-Ray
has to do 25 times as much work to light one surface than it normally would.
The adaptive keyword tells POV-Ray to use adaptive sampling of the area
light. Adaptive sampling works by only testing the corners of the light for
visibility. If about the same amount of light is received from each corner,
POV-Ray assumes the light is either fully visible or fully blocked. If
different amounts of light are received, POV-Ray assumes the light is partially
visible and divides the light up further to determine how much shadow to use.
The parameter for adaptive is an integer, greater than or equal to zero,
which controls the minimum amount of subdividing to use. With "adaptive 0",
POV-Ray will do its initial test with only four rays (each of the corners).
While this is fast, it can lead to errors in the shadows (which manifest themselves
as bright spots where there shouldn't be any). "adaptive 1" will initially
test with 9 rays, "adaptive 2" will initially test with 16 rays, etc. Note that
POV-Ray will not do an adaptive test with more rays than you have lights
in the array. This means that if you have an array with 10 lights, using
anything higher than "adaptive 1" won't do any adaptive sampling.
Area Light
Area lights are used to spread out shadows to make them more realistic. One
of the hallmarks of raytraced or computer generated images is the hard,
well-defined shadow boundaries. This results from the zero dimensional
quality of the standard light source. Since the
light is a point, it's either visible, or it's not. Hence an area is either
shaded, or it's not. Area lights can rectify this situation somewhat. They
work by spreading the intensity of the light out into a rectangle. Since the
light now has an area, it can be partially blocked, leading to shadows which
have soft edges. The general syntax for declaring an area light like this
light_source {
<location> color color
area_light <side-1>, <side-2>, len-1, len-2
[adaptive adaptive value]
[jitter]
/* specifications for spotlight, if desired */
}
Adaptive and jitter are both optional, and are covered in their own sections.
side-1 and side-2 are <x, y, z> vectors describing
the orientation of the sides. Since area lights are rectangular, these vectors
should be perpendicular. Your light will not end up like you intended if
they are at some weird angle. The lengths of these vectors correspond the
lengths of the sides. len-1 and len-2 are the number of
lights along the corresponding dimensions of the light. For example
light_source {
<0, 0, 0> color White
area_light <2, 0, 0>, <0, 0, 2>, 6, 6
}
This defines an area light centered at <0, 0, 0> in the x-z plane. The
light is two units on a side and contains 36 point sources. The intensity
of the light is divided evenly between the 36 points.
Interesting shadow effects can be created with linear lights. A linear light
is an area light that only has one light along one of its dimensions. This can
be used to simulate fluorescent light bars.
Here's a sample image using an area light instead of a point source. Note
how the shadows get softer towards the top of the image.
For more information on declaring light sources, see the light
source section.
Falloff
The falloff keyword only applies to spotlights. The
float parameter for falloff controls the angle at which the lighting from the
spotlight goes to zero. This parameter should always be larger than the
radius value and smaller than 180. Setting this to
the same value as the radius of the hot spot gives the spotlight a hard
(and rather unrealistic looking) edge. The larger the falloff value, the
softer the edge. The tightness parameter can control
exactly how the light falls off between the radius value and the falloff value.
As with the radius keyword, the parameter for this keyword is the angle (in
degrees) between the center of the hotspot and the edge of the lit area.
The following images give examples of the falloff keyword. All three images
use "radius 1.5". The first uses "falloff 1.5" (note the hard edge on the light),
the second uses "falloff 2", and the third uses "falloff 3".
The falloff radius for a spotlight needs to be specified. For more
information about declaring lights, see the light
source section.
Jitter
The jitter keyword only applies to area lights. This keyword is just a
toggle, it takes no parameter. If you use jitter in an arealight, for each
ray traced, the individual point sources in the light are moved a small
random amount. This creates smooth shadows that don't have bands of
different intensity. This feature can be used to create nice, smooth shadows
without gargantuan area light that take years to render. However, jitter
is one of the few completely random features of POV-Ray (like crand)
and will not be the same in two traces of the same scene. For this reason,
using jitter in animations is probably a bad idea.
Light Source
The light_source declaration allows you to declare various types of lights
for your scenes. Light sources are what give your objects three dimensionality.
It's possible to "light" a scene completely with ambient
lighting, but this produces objects which look unexciting and rather two
dimensional. Well placed light sources, in combination with good surface
finishes well make your objects appear
extremely lifelike. Four types of light sources can be defined. The
most basic is the point source. This is a geometric point from which light
rays eminate. Its only properties are its color
and its position. The second type of light is a spotlight. Spotlights are
basically point sources which only cast their light in certain directions. The
third type of light is an area light. These lights
are no longer simgle points, but rather arrays of lights which can be used
to make more realistic shadows. The fourth type is a spot area light. This
is just a directional area light. But anyway, here's the general form for
a light source.
light_source {
/* these two are required */
<location>
color color-spec
/* optional area light specifiers */
area_light <side-1>, <side-2>, len-1, len-2
adaptive adapt level
jitter
/* optional spotlight specifiers */
spotlight
point_at <target>
radius hotspot radius
falloff falloff radius
tightness tightness
/* misc. optional specifiers */
looks_like {
object { obj }
}
}
The two required components of a light source are its location and its color.
All light sources must have these defined. The location is a standard
three component <x, y, z> vector. The color parameter is used to
define the color of the light source (go figure). The usage of color
is covered elsewhere.
The spotlight specifiers are used to turn the light into a
spotlight. Spotlights can be used to emphasize
parts of a scene, or just to light things selectively.
The area light specifiers change the light from a zero dimensional object into
a one or two dimensional object. They can be used to create objects that
have soft-edged shadows, instead of the hard, well defined edges produced by
point lights. They can be used in conjunction with spotlights to confine
the soft shadow calculations to a certain area of the scene.
The looks_like parameter is just sort of weird. It can be used to assign
a "shape" to the light. THe object specified is automatically translated to
the location of the light source and has the no shadow
keyword set.
The source for the various sample scenes shown in this section will give
numerous examples of the different types of light sources.
Looks Like
The looks_like parameter can be used to assign a shape to a light source.
Normally, individual light sources are just invisible points which radiate
light. This applies to area lights, too, as they are just collections of
points sources. Any object may put in the looks_like field. Note that the
object will be automatically translated
to the location of the light source. Also, the object is automatically set
to not cast a shadow (see no_shadow).
If this were not done, the light source object would not let any of the light
that was on the inside out. This would be bad. If you want the associated
object to cast a shadow, you can include the light source in a union.
Here's an example of "looks_like".
light_source {
<50, 50, -50> color White
looks_like {
sphere {
<0, 0, 0>, 0.5
pigment { color rgb <0.8, 0.8, 1> }
}
}
}
Note how the sphere is created at the origin. Again, this is because it will
be automatically translated to the light_source's location. Declaring
the sphere's center to be at <50, 50, -50> would result in the sphere
being moved again (and ending up at <100, 100, -100>).
For more information on declaring light sources, see the
light source section.
Point At
The point_at keyword is a required specifier for spotlights.
It declares the point at which you wish the light source to point (it's similar
to look_at for cameras).
This parameter is used to orient the light; all in all, it's pretty intuitive.
Enjoy some sample images. The first pointed at <0, 0, 0>, the second
at <0, 10, 0>.
For information on declaring light sources, see the light
source section.
Radius
Radius is used to specify the size of the central highlight in a spotlight.
It must be specified for all spotlights. The best way to think of a
spotlight is as a cone of light originating from the light source. The
parameter for radius is a float specifying the angle (in degrees) between
the central axis of the cone, and the edge of the cone which defines the
hot spot. This is similar to the parameter for falloff.
The value for radius should always be less than the value for falloff.
Here are some sample images for varying radii. The first has a radius of
0.75, the second 1.5, and the third 2.5.
For more information on declaring light sources, see the light
source section.
Spotlight
Spotlights allow you to specify directed lights. The default type of light
source is a point that radiates light in all directions. A spotlight is a
point that radiates light only in specified directions. You can turn any
light into a spotlight by specifying the keyword "spotlight" in its
declaration. Anyway, the following is the general syntax for a spotlight.
light_source {
<location color color spec
spotlight
point_at <target>
radius radius
falloff falloff radius
[tightness tightness]
}
All of the above parameters have to be specified except for tightness, which
is optional. A spotlight basically can be considered to be two coaxial cones
of light. The inner cone is fully lit by the point source at the location.
Its angular radius is specified by the "radius" keyword. The outer cone is
the region in which light falls off from fully lit (at the radius angle) to
unlit (at the angle specified for "falloff"). The tightness keyword can be
used to control how the light falls off in the angles between radius
and falloff radius. Although the POV-Ray authors say that your radius
may be up to 180, in my experience, POV-Ray won't render any light beyond
the 90-degree mark. Anyway, here's an example of a spotlight.
Note how only the regions around the "point_at" point are lit. The region
is elliptical because the light is not shining straight down at the "point_at"
point.
For more information on declaring light sources, see the light
source section.
Tightness
Tightness is an optional modifier for spotlights.
It controls how the light falls off the zero at the edge of the falloff
radius. It also controls (to a much lesser extent) the falling off of light
in the central hot spot. The default tightness is 10. Values can range to
nearly zero (but zero itself is bad) for a very soft-edged spotlight, and up to
100 for a very tight edged spotlight. Here are some variations on tightness,
rendered with "tightness 1", "tightness 10", and "tightness 100" respectively.
For more information on declaring light sources, see the light
source section.