4.6. Lights

Lights provide illumination of the scene (beyond that of the sun/moon) and also provide a corona sprite. They exist at a given place in the scene and (if set up to be spotlights) can be rotated to light in a given direction. They are implemented using deferred shading, which means their performance cost is proportional to the number of screen pixels lit by them. This allows lots of small lights to be rendered efficiently.

The lights are nodes in the scene graph, so can be attached to other nodes and have the same fields. Like graphics bodies, they can be individually enabled/disabled and faded.

Light Diagram
Illustration of various light fields.
l = gfx_light_make()
l.localPosition = vec(1, 2, 3)
l.orientation = quat(1, 0, 0, 0)
l.diffuseColour = vec(2,2,2) -- note use of HDR
l.specularColour = vec(2,2,2)
l.range = 10 -- light extends for 10m
l.innerAngle = 50  -- see diagram
l.outerAngle = 60

The outerAngle must be >= the innerAngle, as shown in the diagram. If the innerAngle is 180, then the light is not directional, so the orientation does not matter. Otherwise it shines in the +Y direction unless oriented differently.

4.6.1. Coronas

If desired, Grit can draw a corona to simulate the blinding effect of the light itself. The corona's size (diameter) must be specified, as it defaults to 0 which means no corona. The corona also has its own colour, which you must set otherwise it defaults to white.

l.coronaSize = 0.3 -- sphere diameter in metres
l.coronaLocalPosition = vec(0, 0, 0)
l.coronaColour = vec(1,1,1) -- white