Skip to main content
Version: 🚧 Alpha 🚧

Manipulating lights

A 3D display can use light sources to change how objects appear. Define lights inside a display block. GAMA supports ambient, directional, point and spot lights.

Ambient light​

The special name #ambient sets the ambient light for a display. Its intensity accepts an integer or a color. An integer sets a grayscale intensity; the default intensity is controlled by the OpenGL light intensity preference (180 by default).

light #ambient intensity: #red;

Scene illuminated by a red ambient light.

Directional lights​

A directional light uses a direction vector and has no location. It does not use positional attenuation. The special name #default replaces the display's default directional light.

light #default kind: #direction direction: {0.5, 0.5, -1} intensity: #white;
light "sun" kind: #direction direction: {1, 1, 1} intensity: #red;

Scene illuminated by a red directional light.

Point lights​

A point light has a location in model coordinates. Its intensity decreases with distance according to its attenuation facets. The constant, linear and quadratic attenuation values default to 1, 0 and 0, respectively.

light "lamp" kind: #point location: {10, 20, 10} intensity: #red;

Scene illuminated by a red point light.

Attenuation can be adjusted with constant_attenuation, linear_attenuation and quadratic_attenuation:

light "lamp" kind: #point location: {10, 20, 10}
intensity: #red linear_attenuation: 0.1;

Point light with linear attenuation.

Spot lights​

A spot light has a location, a direction and an angle in degrees. Its angle defaults to 45 degrees. Positional attenuation facets can also be used.

light "spot" kind: #spot location: {0, 0, 100}
direction: {0.5, 0.5, -1} angle: 30 intensity: #red;

Scene illuminated by a red spot light.

Default light​

A display uses default ambient and directional lighting. The #ambient and #default names let a model redefine these sources. Their default intensity is taken from the OpenGL light intensity preference, which defaults to 180.

Scene using the default display lighting.

Showing light sources​

Set show: true on a light to draw a visual representation of its source in the display. The representation can help inspect its location or direction. It is off by default.

light "lamp" kind: #point location: {10, 20, 10} intensity: #red show: true;
light "sun" kind: #direction direction: {1, 1, 1} intensity: #green show: true;
light "spot" kind: #spot location: {0, 0, 100}
direction: {0.5, 0.5, -1} angle: 30 intensity: #blue show: true;

Displayed direction, spot and point light sources.

Light facets​

The light statement is available inside a display. Each name should be unique; if the same name is defined more than once, the last definition is used. The kind facet accepts #direction, #point or #spot. The older type facet is deprecated in favor of kind.

FacetPurpose
kindSelects a directional, point or spot light.
locationSets the position of a point or spot light in model coordinates.
directionSets the direction of a directional or spot light.
angleSets the spot angle in degrees.
intensitySets intensity as an integer or color.
activeEnables or disables the light; defaults to true.
showDraws a representation of the light; defaults to false.
constant_attenuation, linear_attenuation, quadratic_attenuationSet attenuation for positional lights.
dynamicControls whether light parameters are updated each cycle; defaults to true.