1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553
|
<!-- This file copyright Persistence of Vision Raytracer Pty. Ltd. 2003-2004 -->
<html>
<head>
<!-- NOTE: In order to users to help find information about POV-Ray using -->
<!-- web search engines, we ask you to *not* let them index documentation -->
<!-- mirrors because effectively, when searching, users will get hundreds -->
<!-- of results containing the same information! For this reason, the two -->
<!-- meta tags below disable archiving and indexing of this page by all -->
<!-- search engines that support these meta tags. -->
<meta content="noarchive" name="robots">
<meta content="noindex" name="robots">
<meta content="no-cache" http-equiv="Pragma">
<meta content="0" http-equiv="expires">
<title>2.2.4 The Light Source</title>
<link href="povray35.css" rel="stylesheet" type="text/css">
</head>
<body>
<table class="NavBar" width="100%">
<tr>
<td align="left" nowrap="" valign="middle" width="32">
<a href="s_59.html"><img alt="previous" border="0" src="prev.png"></a>
</td>
<td align="left" valign="middle" width="30%">
<a href="s_59.html">2.2.3 CSG Objects</a>
</td>
<td align="center" valign="middle">
<strong class="NavBar">POV-Ray 3.6 for UNIX documentation</strong><br> <strong>2.2.4
The Light Source</strong>
</td>
<td align="right" valign="middle" width="30%">
<a href="s_61.html">2.2.5 Simple Texture Options</a>
</td>
<td align="right" nowrap="" valign="middle" width="32">
<a href="s_61.html"><img alt="next" border="0" src="next.png"></a>
</td>
</tr>
</table>
<h3><a name="s02_02_04">2.2.4 </a>The Light Source</h3>
<a name="s02_02_04_i1"><a name="s02_02_04_i2">
<dl class="famousquote">
<dt>
<em>You know you have been raytracing too long when ...<br> ... You take a photo course just to learn how to get
the lighting right.</em>
<dd>
<em>-- Christoph Rieder</em>
</dl>
<p>
In any ray-traced scene, the light needed to illuminate our objects and their surfaces must come from a light
source. There are many kinds of light sources available in POV-Ray and careful use of the correct kind can yield very
impressive results. Let's take a moment to explore some of the different kinds of light sources and their various
parameters.
</p>
<h4><a name="s02_02_04_01">2.2.4.1 </a>The Pointlight Source</h4>
<a name="s02_02_04_01_i1">
<p>
Pointlights are exactly what the name indicates. A pointlight has no size, is invisible and illuminates everything
in the scene equally no matter how far away from the light source it may be (this behavior can be changed). This is
the simplest and most basic light source. There are only two important parameters, location and color. Let's design a
simple scene and place a pointlight source in it.
</p>
<p>
We create a new file and name it <code>litedemo.pov</code>. We edit it as follows:
</p>
<pre>
#include "colors.inc"
#include "textures.inc"
camera {
location <-4, 3, -9>
look_at <0, 0, 0>
angle 48
}
</pre>
<p>
We add the following simple objects:
</p>
<pre>
plane {
y, -1
texture {
pigment {
checker
color rgb<0.5, 0, 0>
color rgb<0, 0.5, 0.5>
}
finish {
diffuse 0.4
ambient 0.2
phong 1
phong_size 100
reflection 0.25
}
}
}
torus {
1.5, 0.5
texture { Brown_Agate }
rotate <90, 160, 0>
translate <-1, 1, 3>
}
box {
<-1, -1, -1>, <1, 1, 1>
texture { DMFLightOak }
translate <2, 0, 2.3>
}
cone {
<0,1,0>, 0, <0,0,0>, 1
texture { PinkAlabaster }
scale <1, 3, 1>
translate <-2, -1, -1>
}
sphere {
<0,0,0>,1
texture { Sapphire_Agate }
translate <1.5, 0, -2>
}
</pre>
<p>
Now we add a pointlight:
</p>
<pre>
light_source {
<2, 10, -3>
color White
}
</pre>
<p>
We render this at 200x150 <code>-A</code> and see that the objects are clearly visible with sharp shadows. The
sides of curved objects nearest the light source are brightest in color with the areas that are facing away from the
light source being darkest. We also note that the checkered plane is illuminated evenly all the way to the horizon.
This allows us to see the plane, but it is not very realistic.
</p>
<h4><a name="s02_02_04_02">2.2.4.2 </a>The Spotlight Source</h4>
<a name="s02_02_04_02_i1"><a name="s02_02_04_02_i2">
<p>
Spotlights are a very useful type of light source. They can be used to add highlights and illuminate features much
as a photographer uses spots to do the same thing. To create a spotlight simply add the <code><a href="s_111.html#s03_04_07_02">spotlight</a></code>
keyword to a regular point light. There are a few more parameters with spotlights than with pointlights. These are <code><a href="s_111.html#s03_04_07_02">radius</a></code>,
<code><a href="s_111.html#s03_04_07_02">falloff</a></code>, <code><a href="s_111.html#s03_04_07_02">tightness</a></code>
and <code><a href="s_111.html#s03_04_07_02">point_at</a></code>. The <code>radius</code> parameter is the angle of the
fully illuminated cone. The <code>falloff</code> parameter is the angle of the <em>umbra</em> cone where the light
falls off to darkness. The <code>tightness</code> is a parameter that determines the rate of the light falloff. The <code>point_at</code>
parameter is just what it says, the location where the spotlight is pointing to. Let's change the light in our scene
as follows:
</p>
<pre>
light_source {
<0, 10, -3>
color White
spotlight
radius 15
falloff 20
tightness 10
point_at <0, 0, 0>
}
</pre>
<p>
We render this at 200x150 <code>-A</code> and see that only the objects are illuminated. The rest of the plane and
the outer portions of the objects are now unlit. There is a broad falloff area but the shadows are still razor sharp.
Let's try fiddling with some of these parameters to see what they do. We change the falloff value to 16 (it must
always be larger than the radius value) and render again. Now the falloff is very narrow and the objects are either
brightly lit or in total darkness. Now we change falloff back to 20 and change the tightness value to 100 (higher is
tighter) and render again. The spotlight appears to have gotten much smaller but what has really happened is that the
falloff has become so steep that the radius actually appears smaller.
</p>
<p>
We decide that a tightness value of 10 (the default) and a falloff value of 18 are best for this spotlight and we
now want to put a few spots around the scene for effect. Let's place a slightly narrower blue and a red one in
addition to the white one we already have:
</p>
<pre>
light_source {
<10, 10, -1>
color Red
spotlight
radius 12
falloff 14
tightness 10
point_at <2, 0, 0>
}
light_source {
<-12, 10, -1>
color Blue
spotlight
radius 12
falloff 14
tightness 10
point_at <-2, 0, 0>
}
</pre>
<p>
Rendering this we see that the scene now has a wonderfully mysterious air to it. The three spotlights all converge
on the objects making them blue on one side and red on the other with enough white in the middle to provide a balance.
</p>
<h4><a name="s02_02_04_03">2.2.4.3 </a>The Cylindrical Light Source</h4>
<a name="s02_02_04_03_i1"><a name="s02_02_04_03_i2">
<p>
Spotlights are cone shaped, meaning that their effect will change with distance. The farther away from the
spotlight an object is, the larger the apparent radius will be. But we may want the radius and falloff to be a
particular size no matter how far away the spotlight is. For this reason, cylindrical light sources are needed. A
cylindrical light source is just like a spotlight, except that the radius and falloff regions are the same no matter
how far from the light source our object is. The shape is therefore a cylinder rather than a cone. We can specify a
cylindrical light source by replacing the <code>spotlight</code> keyword with the <code>cylinder</code> keyword. We
try this now with our scene by replacing all three spotlights with cylinder lights and rendering again. We see that
the scene is much dimmer. This is because the cylindrical constraints do not let the light spread out like in a
spotlight. Larger radius and falloff values are needed to do the job. We try a radius of 20 and a falloff of 30 for
all three lights. That's the ticket!
</p>
<h4><a name="s02_02_04_04">2.2.4.4 </a>The Area Light Source</h4>
<a name="s02_02_04_04_i1"><a name="s02_02_04_04_i2">
<dl class="famousquote">
<dt>
<em>You know you have been raytracing too long when ...<br> ... You wear fuzzy clothing to soften your shadow.</em>
<dd>
<em>-- Mark Kadela</em>
</dl>
<p>
So far all of our light sources have one thing in common. They produce sharp shadows. This is because the actual
light source is a point that is infinitely small. Objects are either in direct sight of the light, in which case they
are fully illuminated, or they are not, in which case they are fully shaded. In real life, this kind of stark light
and shadow situation exists only in outer space where the direct light of the sun pierces the total blackness of
space. But here on Earth, light bends around objects, bounces off objects, and usually the source has some dimension,
meaning that it can be partially hidden from sight (shadows are not sharp anymore). They have what is known as an <em>umbra</em>,
or an area of fuzziness where there is neither total light or shade. In order to simulate these <em> soft</em>
shadows, a ray-tracer must give its light sources dimension. POV-Ray accomplishes this with a feature known as an area
light.
</p>
<p>
Area lights have dimension in two axis'. These are specified by the first two vectors in the area light syntax. We
must also specify how many lights are to be in the array. More will give us cleaner soft shadows but will take longer
to render. Usually a 3*3 or a 5*5 array will suffice. We also have the option of specifying an adaptive value. The <code>
adaptive</code> keyword tells the ray-tracer that it can adapt to the situation and send only the needed rays to
determine the value of the pixel. If adaptive is not used, a separate ray will be sent for every light in the area
light. This can really slow things down. The higher the adaptive value the cleaner the umbra will be but the longer
the trace will take. Usually an adaptive value of 1 is sufficient. Finally, we probably should use the <code> jitter</code>
keyword. This tells the ray-tracer to slightly move the position of each light in the area light so that the shadows
appear truly soft instead of giving us an umbra consisting of closely banded shadows.
</p>
<p>
OK, let's try one. We comment out the cylinder lights and add the following:
</p>
<pre>
light_source {
<2, 10, -3>
color White
area_light <5, 0, 0>, <0, 0, 5>, 5, 5
adaptive 1
jitter
}
</pre>
<p>
This is a white area light centered at <2,10,-3>. It is 5 units (along the x-axis) by 5 units (along the
z-axis) in size and has 25 (5*5) lights in it. We have specified adaptive 1 and jitter. We render this at 200x150 <code>-A</code>.
</p>
<p>
Right away we notice two things. The trace takes quite a bit longer than it did with a point or a spotlight and the
shadows are no longer sharp! They all have nice soft umbrae around them. Wait, it gets better.
</p>
<p>
Spotlights and cylinder lights can be area lights too! Remember those sharp shadows from the spotlights in our
scene? It would not make much sense to use a 5*5 array for a spotlight, but a smaller array might do a good job of
giving us just the right amount of umbra for a spotlight. Let's try it. We comment out the area light and change the
cylinder lights so that they read as follows:
</p>
<pre>
light_source {
<2, 10, -3>
color White
spotlight
radius 15
falloff 18
tightness 10
area_light <1, 0, 0>, <0, 0, 1>, 2, 2
adaptive 1
jitter
point_at <0, 0, 0>
}
light_source {
<10, 10, -1>
color Red
spotlight
radius 12
falloff 14
tightness 10
area_light <1, 0, 0>, <0, 0, 1>, 2, 2
adaptive 1
jitter
point_at <2, 0, 0>
}
light_source {
<-12, 10, -1>
color Blue
spotlight
radius 12
falloff 14
tightness 10
area_light <1, 0, 0>, <0, 0, 1>, 2, 2
adaptive 1
jitter
point_at <-2, 0, 0>
}
</pre>
<p>
We now have three area-spotlights, one unit square consisting of an array of four (2*2) lights, three different
colors, all shining on our scene. We render this at 200x150 <code>-A</code>. It appears to work perfectly. All our
shadows have small, tight umbrae, just the sort we would expect to find on an object under a real spotlight.
</p>
<h4><a name="s02_02_04_05">2.2.4.5 </a>The Ambient Light Source</h4>
<a name="s02_02_04_05_i1">
<p>
The <em>ambient light source</em> is used to simulate the effect of inter-diffuse reflection. If there was not
inter-diffuse reflection all areas not directly lit by a light source would be completely dark. POV-Ray uses the <code>ambient</code>
keyword to determine how much light coming from the ambient light source is reflected by a surface.
</p>
<p>
By default the ambient light source, which emits its light everywhere and in all directions, is pure white (<code>rgb
<1,1,1></code>). Changing its color can be used to create interesting effects. First of all the overall light
level of the scene can be adjusted easily. Instead of changing all ambient values in every finish only the ambient
light source is modified. By assigning different colors we can create nice effects like a moody reddish ambient
lighting. For more details about the ambient light source see "Ambient Light".
</p>
<p>
Below is an example of a red ambient light source.
</p>
<pre>
global_settings { ambient_light rgb<1, 0, 0> }
</pre>
<h4><a name="s02_02_04_06">2.2.4.6 </a>Light Source Specials</h4>
<a name="s02_02_04_06_i1">
<h5><a name="s02_02_04_06_01">2.2.4.6.1 </a>Using Shadowless Lights</h5>
<a name="s02_02_04_06_01_i1"><a name="s02_02_04_06_01_i2">
<p>
Light sources can be assigned the <code>shadowless</code> keyword and no shadows will be cast due to its presence
in a scene. Sometimes, scenes are difficult to illuminate properly using the lights we have chosen to illuminate our
objects. It is impractical and unrealistic to apply a higher ambient value to the texture of every object in the
scene. So instead, we would place a couple of <em>fill lights</em> around the scene. Fill lights are simply dimmer
lights with the <code>shadowless</code> keyword that act to boost the illumination of other areas of the scene that
may not be lit well. Let's try using one in our scene.
</p>
<p>
Remember the three colored area spotlights? We go back and un-comment them and comment out any other lights we have
made. Now we add the following:
</p>
<pre>
light_source {
<0, 20, 0>
color Gray50
shadowless
}
</pre>
<p>
This is a fairly dim light 20 units over the center of the scene. It will give a dim illumination to all objects
including the plane in the background. We render it and see.
</p>
<h5><a name="s02_02_04_06_02">2.2.4.6.2 </a>Assigning an Object to a Light Source</h5>
<a name="s02_02_04_06_02_i1"><a name="s02_02_04_06_02_i2"><a name="s02_02_04_06_02_i3">
<p>
Light sources are invisible. They are just a location where the light appears to be coming from. They have no true
size or shape. If we want our light source to be a visible shape, we can use the <code>looks_like</code> keyword. We
can specify that our light source can look like any object we choose. When we use <code>looks_like</code>, then <code>no_shadow</code>
is applied to the object automatically. This is done so that the object will not block any illumination from the light
source. If we want some blocking to occur (as in a lamp shade), it is better to simply use a union to do the same
thing. Let's add such an object to our scene. Here is a light bulb we have made just for this purpose:
</p>
<pre>
#declare Lightbulb = union {
merge {
sphere { <0,0,0>,1 }
cylinder {
<0,0,1>, <0,0,0>, 1
scale <0.35, 0.35, 1.0>
translate 0.5*z
}
texture {
pigment {color rgb <1, 1, 1>}
finish {ambient .8 diffuse .6}
}
}
cylinder {
<0,0,1>, <0,0,0>, 1
scale <0.4, 0.4, 0.5>
texture { Brass_Texture }
translate 1.5*z
}
rotate -90*x
scale .5
}
</pre>
<p>
Now we add the light source:
</p>
<pre>
light_source {
<0, 2, 0>
color White
looks_like { Lightbulb }
}
</pre>
<p>
Rendering this we see that a fairly believable light bulb now illuminates the scene. However, if we do not specify
a high ambient value, the light bulb is not lit by the light source. On the plus side, all of the shadows fall away
from the light bulb, just as they would in a real situation. The shadows are sharp, so let's make our bulb an area
light:
</p>
<pre>
light_source {
<0, 2, 0>
color White
area_light <1, 0, 0>, <0, 1, 0>, 2, 2
adaptive 1
jitter
looks_like { Lightbulb }
}
</pre>
<p>
We note that we have placed this area light in the x-y-plane instead of the x-z-plane. We also note that the actual
appearance of the light bulb is not affected in any way by the light source. The bulb must be illuminated by some
other light source or by, as in this case, a high ambient value.
</p>
<h5><a name="s02_02_04_06_03">2.2.4.6.3 </a>Using Light Fading</h5>
<a name="s02_02_04_06_03_i1"><a name="s02_02_04_06_03_i2"><a name="s02_02_04_06_03_i3">
<p>
If it is realism we want, it is not realistic for the plane to be evenly illuminated off into the distance. In real
life, light gets scattered as it travels so it diminishes its ability to illuminate objects the farther it gets from
its source. To simulate this, POV-Ray allows us to use two keywords: <code>fade_distance</code>, which specifies the
distance at which full illumination is achieved, and <code>fade_power</code>, an exponential value which determines
the actual rate of attenuation. Let's apply these keywords to our fill light.
</p>
<p>
First, we make the fill light a little brighter by changing <code> Gray50</code> to <code>Gray75</code>. Now we
change that fill light as follows:
</p>
<pre>
light_source {
<0, 20, 0>
color Gray75
fade_distance 5
fade_power 1
shadowless
}
</pre>
<p>
This means that the full value of the fill light will be achieved at a distance of 5 units away from the light
source. The fade power of 1 means that the falloff will be linear (the light falls off at a constant rate). We render
this to see the result.
</p>
<p>
That definitely worked! Now let's try a fade power of 2 and a fade distance of 10. Again, this works well. The
falloff is much faster with a fade power of 2 so we had to raise the fade distance to 10.
</p>
<br>
<table class="NavBar" width="100%">
<tr>
<td align="left" nowrap="" valign="middle" width="32">
<a href="s_59.html"><img alt="previous" border="0" src="prev.png"></a>
</td>
<td align="left" valign="middle" width="30%">
<a href="s_59.html">2.2.3 CSG Objects</a>
</td>
<td align="center" valign="middle">
<strong>2.2.4 The Light Source</strong>
</td>
<td align="right" valign="middle" width="30%">
<a href="s_61.html">2.2.5 Simple Texture Options</a>
</td>
<td align="right" nowrap="" valign="middle" width="32">
<a href="s_61.html"><img alt="next" border="0" src="next.png"></a>
</td>
</tr>
</table>
</body> </html>
|