Lights
Lights
There are 3 light sources in the scene that are controlled by the environment. These are the sun (or moon at night), the sky (always directly above) and reverse specular from the sun / moon. To modify these, see the sky editor page?.This page is about the small lights that are used in the scene, especially at night, for streetlamps, car headlights, etc.
Using lights in a class
At the moment, you can add lights to a class and the lights will always be on. This will change soon.Point lights
class "MyClass" (ColClass) {
-- the usual stuff goes here
lights = {
{ pos=vector3(0, -1.7, 7.85), diff=vector3(5, 3.5, 0), spec=vector3(5, 3.5, 0), range=14 },
{ another light here },
{ and here },
}
}
The 'pos' attribute gives the position of the light (the point where the rays will shine from) in the object's model space. (DEFAULT: vector3(0,0,0)
The 'diff' and 'spec' attributes give the diffuse and specular colours for the light. These are floating point values so can be greater than 1. DEFAULT: vector3(1,1,1)
The 'range' attribute is the maximum distance the light will affect in metres. DEFAULT: 10
Spotlights
For spotlights, there are 3 additional parameters. lights = {
{ ... iangle=20, oangle=60, aim=quat(-90,vector3(0,1,0)) },
{ another light here },
{ and here },
}
The 'aim' attribute gives the orientation of the light in terms of a quaternion. For a quick primer on quaternions see Quaternion Primer. The base orientation of the light is to point in the direction of vector3(0,1,0). The reason this is a quaternion instead of a simple vector3 is that we may later support lights with a projective texture, in which case a single vector3 is no-longer enough to pin down all of its freedoms.
The 'iangle' and 'oangle' shape the beam. They are angles in degrees, and if both are set to 180 the light is an omnidirectional point light since it shines behind itself. If oangle is set to 90, the light is a hemisphere. DEFAULT: 180
Note that by setting them both to 0 you will get no light at all, and by setting them both to the same value between 0 and 180 you will get a 'sharp edge' to the light.
Coronas
A corona is the lit ball of gas (or mist / smoke) surrounding a light. During a lunar eclipse, the sun's corona is visible because it is much larger than the sun itself. In Grit, each point or spot light has a corona that can be independently positioned, sized, and coloured from the actual light source. lights = {
{ ... coronaPos=coronaSize=5, coronaColour=vector3(1,1,1) },
}
The 'coronaSize' attribute is the diameter in metres of the corona. DEFAULT: The largest colour channel of the 'diff' attribute.
The 'coronaColour' attribute is the colour of the corona. This should usually be a similar colour to the light itself, but about 25% as bright. The actual corona texture itself is normalised to 0 and 1 in order to make use of the full range of the image format, but most lights will not need coronas that bright. DEFAULT: The 'diff' attribute scaled down until no channel is larger than 1, and divided by 4.
The 'coronaPos' attribute gives the position of the corona as a vector3 in model space. DEFAULT: Equal to the 'pos' attribute.
Category:Mapping?
Category:Graphics?
