-
Notifications
You must be signed in to change notification settings - Fork 5
light_params
type | property | description | default |
---|---|---|---|
float | size | diameter of the light source (reflector or bulb) | 0 |
float | angle | light field angle [deg], ignored on point lights | 50 |
float | edge | soft edge coefficient, 0..1 portion of the light area along the edges where light fades to make it soft | 0.5 |
float | intensity | light intenity (can be left 0 and use the range instead) | 0 |
float4 | color | RGB color and near-infrared component of the light emitter | float4(1,1,1,0) |
float | range | desired range of light | 0 |
float | fadeout | time to fade after turning off | 0 |
If either intensity or range are specified alone, the other one is computed automatically. If neither one is specified, the intensity is taken from the color value, otherwise the colors are normalized. If both intensity and range are specified, the light can have shorter range to avoid leaking outside of cockpits etc.
Note: the final intensity of light is affected not only by intensity parameter, but also by angle and range.
When defining spotlights (light with direction), the intensity parameter should not be used, only the range parameter. The combination of intensity and range should be used only in specific cases, such as when defining cabin lights.
Passing lights - used as front low beam lights and rear tail lights
Main lights - used as front high beam lights, they are brighter than passing lights
Brake lights - used when the car brakes, they are brighter than the rear tail lights
Turn lights - used as signal lights, they are activated on one side to advertise intent to turn or change lanes towards that side
Emergency lights - used as hazard lights, all turn lights used simultaneously as a hazard warning signal to warn other drivers of a vehicle parked on the road
Reverse lights - used to warn of a vehicle's rearward motion, and to provide illumination to the rear when reversing
Cabin lights - lights in cabin
Aircraft visibility lights
Navigation lights - to identify the aircraft direction - red light on the left wing tip, green light on the right wing tip and may have white light on the tail
Strobe lights - flashing high intensity white lights on wing tips and also on tail, they are turned on, when entering an active runway for takeoff and turned off, after landing and exiting the active runway
Beacon lights - flashing red lights on top and bottom of the fuselage, they are turned on, before the engine has started and turned off when the engines are shut down.
Pilot's visibility lights (for outside of the aircraft)
Taxi lights - high intensity lights with front direction, used during taxiing (moving on ground). They may be installed on the nose landing gear or on the wing root
Runway turn off lights - similar to taxi lights, but they illuminate the right and left side from the nose landing gear
Landing lights - high intensity lights used during takeoff and landing to illuminate the runway surface. They may be installed on the landing gear, fuselage or the wings. They are turned on before takeoff and during approach.
Wing inspection lights - installed on fuselage, they illuminate the leading edge of wings and engine pylons, to inspect them before/during flight.
Other lights
Cabin lights - lights in cabin
Logo lights - mounted on horizontal stabilizer, pointed towards the vertical stabilizer to illuminate the company logo on the tail of the aircraft
Bitmasking is used for lights to manipulate individual lights (represented as bits).
Imagine, that we have 4 lights, which we can represent as 4 bits. These lights can be for example turn lights for our car, which we defined in the following way:
lightProp = {size:0.1, edge:0.8, fadeout:0, color:{x:0.4,y:0.1,z:0},range:0.004, intensity:1 };
let turnLightOffset =
add_point_light({x:-0.71,y:2.25,z:0.63}, lightProp); //left front turn light (0001)
add_point_light({x:-0.64,y:-2.11,z:0.72}, lightProp); //left rear turn light (0010)
add_point_light({x:0.71,y:2.25,z:0.63}, lightProp); //right front turn light (0100)
add_point_light({x:0.64,y:-2.11,z:0.72}, lightProp); //right rear turn light (1000)
Now as we want to use them, for example, in function light_mask(), we need to know, which bits should be affected.
Here is representation of our 4 lights in binary, decimal and hexadecimal system, which system you use is up to you.
Decimal | Binary | Hexadecimal | Description |
---|---|---|---|
1 | 0b0001 | 0x1 | left front turn light |
2 | 0b0010 | 0x2 | left rear turn light |
4 | 0b0100 | 0x4 | right front turn light |
8 | 0b1000 | 0x8 | right rear turn light |
And here are the combinations, which we can use
Decimal | Binary | Hexadecimal | Description |
---|---|---|---|
0 | 0b0000 | 0x0 | used for lights to turn off |
1 | 0b0001 | 0x1 | left front turn light |
2 | 0b0010 | 0x2 | left rear turn light |
3 | 0b0011 | 0x3 | left rear + left front (left side) |
4 | 0b0100 | 0x4 | right front turn light |
5 | 0b0101 | 0x5 | right front + left front (front side) |
6 | 0b0110 | 0x6 | right front + left rear |
7 | 0b0111 | 0x7 | right front + left rear + left front |
8 | 0b1000 | 0x8 | right rear turn light |
9 | 0b1001 | 0x9 | right rear + left front |
10 | 0b1010 | 0xa | right rear + left rear (rear side) |
11 | 0b1011 | 0xb | right rear + left rear + left front |
12 | 0b1100 | 0xc | right rear + right front (right side) |
13 | 0b1101 | 0xd | right rear + right front + left front |
14 | 0b1110 | 0xe | right rear + right front + left rear |
15 | 0b1111 | 0xf | all turn lights (emergency lights) |
For turn lights, we want to activate left lights, right sides or all lights (emergency).
We can do that, by creating light mask, where we use left shift operator (<<) to shift our lights by the first turn light offset.
TurnLeftMask = 0x3<<turnLightOffset;
//Add previous left turn lights to the offset (or you can make another offset for right turn lights and use that....)
TurnRightMask = 0x3<<(turnLightOffset + 0x2);
//When the left turn signal button was pressed, we want to activate turn lights on the left side
light_mask(TurnLeftMask, val == 1 );
//When the right turn signal button was pressed, we want to activate turn lights on the right side
light_mask(TurnRightMask, val == -1 );
or directly, by adding first light offset as 3. parameter in light_mask() function
//When the left turn signal button was pressed, we want to activate turn lights on the left side
light_mask(0x3, val == 1, turnLightOffset );
//When the right turn signal button was pressed, we want to activate turn lights on the right side
light_mask(0x3, val == -1, (turnLightOffset + 0x2) );
Test