Vizard 8 » Reference » Lights » Light basics
8.0

Light basics

You can add several different kinds of OpenGL lights to your scene.  Depending on the type of light, you will have available different parameters that can be adjusted.

 

The three different kinds of light objects are:

Each kind of light has a slightly different effect when enabled and the difference between the lights are discussed below.

Directional lights

Directional lights are infinite waves of light always in the same direction. Rather than the positioning, the main importance of a directional light is in its orientation. Therefore, it is important to note that the light does not attenuate with distance and simulates a source that is infinitely far away as rays remain parallel.

myLight = viz.addLight()
myLight.setEuler( 90, 0 ,0 )

Point lights

A point light simulates a light originating from a single point in space and illuminates in all directions. Much like a candle, it casts omnidirectional light equally but the intensity falls off with distance.

mylight = viz.addLight()
mylight.enable()
mylight.position(0, 1, 0)
mylight.spread(180)
mylight.intensity(2)

Spot lights

Spot lights combine both directional and point lights, and casts a cone of illumination that can be adjusted to have either a sharp or soft edge around a circular illumination area.

mylight = viz.addLight()

#Set the light parameters
mylight.position(0,0,0)
mylight.direction(0,0,1)
mylight.spread(90)
mylight.intensity(2)
mylight.spotexponent(2)
mylight.setPosition(0,1,0)

If you want to use either point or spot lights to create special effects, keep in mind that your geometry must be tessellated in order to take full advantage of these particular lighting effects. Tessellation is the process of sub-dividing an object into smaller subcomponents. For example, to properly use a spotlight on a flat square, the square would have to be composed of many sub-squares so that OpenGL can differentially illuminate and interpolate across the individual vertices. You can easily experiment with these effects by building an object in your modeler and changing the level of tessellation and look at how lighting effects are affected.

Head-lamp

Vizard has an automatic head-lamp attached to the default viewpoint. To deactivate the head-lamp, use the disable command shown below (the head-lamp is always light #0).

#Get a handle to the main headlight and disable it
headLight = viz.MainView.getHeadLight()
headLight.disable()
#Turn the headlight back on with a keypress.
vizact.onkeydown( ' ', headLight.enable )

See also

In this section:

Light properties

Adding lights

Lights Command Table

Other sections:

3D model basics

Scene basics

Example scripts:

Spotlight

Shadows