yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Back: 3D mapping Forward: 3D gnomon   FastBack: Animation Up: 3D graphics FastForward: Embedding         Top: Yorick Contents: Table of Contents Index: Concept Index About: About this document

3.10.2 Lighting

Yorick's pseudocolor model cannot describe a shaded color object. (You need to be able to specify arbitrary colors for that.) Therefore, if you want shading to suggest a 3D shape, you must settle for black and white (or any single color -- the `heat.gp' palette works about as well as `gray.gp' for shading).

You also need to worry about more variables -- namely the position and relative brightness of any lights illuminating your object. You call the light3 function to set up light sources.

The 3D surfaces comprising your object (plotted by either plf or plfp for the `plwf.i' or `slice3.i' interfaces) consist of a number of polygonal facets. Yorick assigns a 3D normal vector to each facet (for non-planar polygons, the direction is somewhat arbitrary). The lighting model, which you set up by light3 calls, maps normal directions to surface brightness. If the facet is oriented so that it reflects one of your light sources directly toward your camera, that facet will appear very bright.

The functional form of this specular reflection model is (1+cos(alpha))^n, where alpha is the angle between your camera and the light source, as seen from the center of the facet. You can adjust the power n. Large n gives a polished metallic look; small n gives a matte look. You can specify as many light sources as you want. However, the light sources are all infinitely far away. Also, although you can specify a different n for each light source, you cannot get dfferent values of n for different surfaces or parts of surfaces.

Instead of or in addition to these specular light sources, you can also get diffuse lighting. In this model, the brightness of a surface is simply proportional to the cosine of its angle relative to your viewing direction. Thus, a surface you view face on is brightest, while one viewed edge on is dimmest (the effect is called limb darkening).

All of these effects are controlled by keywords to the light3 function: specular (brightness of specular light sources), sdir (directions to specular light sources), spower (the powers n for the specular light sources), diffuse (brightness of diffuse light source), and ambient (an overall additive brightness). The light3 function also returns a value, which you can pass back to it in a later call in order to restore a previous lighting specification.

These lighting models -- which are actually the standard models you find in most 3D graphics packages -- bear little relationship to the appearance of real world scenes. There are no shadows, and surfaces have no intrinsic texture. Your goal is excitement, not realism.


Back: 3D mapping Forward: 3D gnomon   FastBack: Animation Up: 3D graphics FastForward: Embedding         Top: Yorick Contents: Table of Contents Index: Concept Index About: About this document