Category:LSL Light
LSL Portal | Functions | Events | Types | Operators | Constants | Flow Control | Script Library | Categorized Library | Tutorials |
Light sources
Properties of light
The quality of light cast by an object is determined by five parameters found on the "Settings" page of the Edit dialog, which can also be set by script commands. The controls appear in the dialog in the same order as used in the script commands (see example below).
The first is a simple on/off switch: either the object is a light source (checkbox activated or TRUE) or it isn't. The light's colour is set by a colour picker (dialog) or as an RGB vector (script) as usual. The intensity of light is a measurement of how strong in absolute terms the light is. This is a floating-point number ranging from 0 to 1, where 1 is fully on and 0 is equivalent to "off."
The two remaining settings are trickier, because their effects are quite subtle and they do interact with each other. Radius is the distance that light will travel from the centre of the object before it blends into and becomes indistinguishable from the scene's natural ambient lighting. This is a floating-point number measured in metres. Falloff is the extent to which light "decays" as is travels away from the object. This is a floating-point number ranging from 0 to 2, where 2 is a strong (abrupt) falling-off of intensity and 0 is relatively little change over distance.
To illustrate how these settings work, imagine (or better still: build) a hollow grey cube 8 by 8 by 8 metres on the inside, with a light source hovering in the middle of one end-wall, and yourself standing below the light source looking at the opposite wall. (Hint: if you do actually build this, turn the sun off while you are testing; you may also need to close the curtains and extinguish all lights in the room you're working in.)
While the radius is less than 4 metres (i.e. under halfway to the opposite wall), it remains fairly dark. Turning the falloff up to 2 (maximum decay) makes the room somewhat darker.
As the radius approaches 8 metres (the distance to the wall), the room is only slightly brighter; at maximum falloff, the room is about as dark as it was when the radius was 4 metres and falloff was 0.
Only after the radius is greater than the distance to the opposite wall does it become significantly brighter. The effect of falloff is greater: when it is zero, direct illumination begins to make concentric circles on the wall, centred on the point where it intersects the light's axis; at maximum (2) the room is again as dark as it was when the radius was only 4 metres.
Controlling light sources
Light in SL is determined by the OpenGL standard which allows for eight lights. Traditionally and practically, two sources are reserved for the Sun and Moon, leaving six for incidental lighting. All eight are really generated on the client-side video card, so different video card models may show the same scene slightly differently. If more than six user light sources are present in a scene, only the light from the closest six will show in the environment.
An example - How to generate, switch and change light from LSL:
// simple light source demonstrator // 8feb07 "tetsumo kuri" // thanks to squee janitor for line to dissect integer light_s = TRUE; // "_s" for status default { state_entry() { // llSetText("click me",<1,0,0.6>,.5); // in case you like labels } touch_start(integer total_number) { if ( light_s ) { light_s = FALSE; // fullbright doesn't have anything to do with light in NEW(2006?) lighting model // setting fullbright does look good though llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE]); llSetPrimitiveParams([PRIM_POINT_LIGHT, FALSE, // if this is false, light is off, <0.0,1.0,0.0>,1.0, 10.0, 0.5]); // rest of params don't matter } else { light_s = TRUE; //llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,TRUE]); //leave fullbright commented for now llSetPrimitiveParams([PRIM_POINT_LIGHT,TRUE, <1.0,0.7,1.0>, // light color vector range: 0.0-1.0 *3 1.0, // intensity (0.0-1.0) 10.0, // radius (.1-10.0) 0.6 ]); // falloff (.01-1.0) // this could have been done in one line, like this //llSetPrimitiveParams([PRIM_FULLBRIGHT,ALL_SIDES,FALSE,PRIM_POINT_LIGHT,TRUE,<1.0,1.0,0.5>,20,1.0,0.5]); // ... but thats kinda hard to take in... } //llSay(0, " Click!"); } }
Pages in category "LSL Light"
The following 14 pages are in this category, out of 14 total.