Cockpit lighting

From SIMboxWiki
Jump to navigation Jump to search

The Graphic engine has a system for implementing and controlling lights within cockpits (consoles). This feature comes to answer the need for simulating dynamic light systems within a cockpits. The system can be integrated into cockpits so that a single cockpit may work well under any light condition, both during day and night time. While providing easy control over it.

This feature is implemented from version 5.5.1 in Simigon Graphic Engine Version 5 (SGEV5) only.

Implementation

Ambient vs. dimmer light

Under the cockpit lighting system there are 2 recognizable light sources: Ambient light and dimmer light.

  • Ambient light represents light within a cockpit environment that has no distinct light source. This light refers either to the general amount of light in the atmosphere created by sun. Or in the case of a closed space, by the general amount of light provided by the various light bulbs, reflected and refracted by the walls or bulkheads of the cockpit.
  • Dimmer light refers to small individual light sources. Either light sources placed within consoles, such as exist in car dashboards. Or light emanating from small light bulb with limited area of influence.

Note that there may be multiple dimmer lights within a single cockpit, but only one ambient light.

Lighting model

AGIs

Each AGI may work under 1 of 4 lighting models:

  • None - The color of the AGI is not controlled by any light source. AGI is colored constantly in full brightness. This light model is the default value. This light model is provided both for backward compatibility and to ensure that when creating simple consoles which do not require the light control system the setup of these consoles remain as simple as possible.
  • Ambient - The color of the AGI is modulated by the amount of ambient light in the cockpit. The further the ambient light decreases the darker the AGI gets. This model can be used to simulate most normal material.
  • Dimmer - The color of the AGI is controlled exclusivly by a dimmer light. Dimmer light brightness and color may be defined by the user per cockpit and per dimmer. This model is usually used to simulate small indicator lights, such as found within car dashboards.
  • Ambient & dimmer - The color of the AGI is controlled by a both of a dimmer and the amount of ambient light in the cockpit. The AGI is colored using the brighter of the two lights. This model is usually used to simulate normal material which is lit with a dimmer light.

Dimmer textures

In certain cases, a different representation is required for when an element is affected by ambient light vs when an element is effected by a dimmer light.

Consider needles in car speedometers. There are many car dashboards in which during the daytime the speedometer needle appears as an elongated white triangle. While at night, when only visible by the dimmer light, it appears as a thin red or yellow line.

To cover this scenario, AGIs can be defined with an extra dimmer texture. The dimmer texture will be affected by the assigned dimmer light. While the regular texture will be affected by the ambient light. Note that this extra texture is only valid for when using an "ambient & dimmer" light model.

Console model

Consoles are by default affected only by the ambient light. This behavior can be modified to allow using additional texture to simulate dimmer lights affecting the cockpit. For further details consult the dimmer control in cockpit materials section

Light controls

Ambient light

The ambient light with a cockpit may be given from 2 sources externally by the sun or internally by use of light bulbs. For this reason ambient light can be controlled in one of two ways. A user can define whether the ambient light is provided externally (i.e. from the sun) which may vary during the hours of the day. In addition to this the user may define a minimum amount of ambient light which is always maintained within the cockpit.

Dimmer switches

As stated in the previous sections there are multiple dimmer lights within a cockpit. Each AGI may be connected to a different dimmer light. And each dimmer may be set with a different color / intensity. Note that this will only affect the AGI if it's lighting model is set to Dimmer or Ambient & Dimmer.

The current limit on the number of dimmers within a cockpit is set to 20.

API

AGI

This following is a list of the functions used to control the light system in the AGI API:

agiRet Agi::SetLightingModel(HAGI hAgi, AgiLightingModel eModel) - Sets the lighting model with which the AGI is to be colored.

agiRet Agi::GetLightingModel(HAGI hAgi, AgiLightingModel& eModel) - Returns the lighting model with which the AGI is colored.

agiRet Agi::SetAssociatedDimmer(HAGI hAgi, UINT nChannelId) - Sets the dimmer light number the AGI is associated with.

agiRet Agi::GetAssociatedDimmer(HAGI hAgi, UINT& nChannelId) - Returns the dimmer light number the AGI is associated with.

agiRet Agi::SetDimmerColor(HAGI hCockpit, UINT nChannelId, COLORREF dimmerColor) - Sets a dimmer's color.

agiRet Agi::SetDimmerColor(HAGI hCockpit, UINT nChannelId, COLORREF dimmerColor) - Returns a dimmer's color.

agiRet Agi::SetDimmerImage() - Sets a dimmer texture. A texture which is only affected by dimmer lights.

agiRet Agi::GetDimmerImage() - Returns the texture dimmer texture.

TriD

This following is a list of the functions used to control the light system in the TriD API:

zsRET TriD::SetCameraCockpitDisplayAttrib(UINT nCamID, zsCameraCockpitDisplayAttrib& attrib) - Used to set the properties controlling the amount of ambient light within a cockpit.

zsRET TriD::GetCameraCockpitDisplayAttrib(UINT nCamID, zsCameraCockpitDisplayAttrib& attrib) - Used to retrieve the properties controlling the amount of ambient light within a cockpit.

Dimmer control in cockpit materials

To add dimmer control to light textures within a follow the folllowing instructions:

  • Create and export a model with 2 textures. One texture providing the regular texture of the cockpit. The other providing a light map which a dimmer will control. Order the textures so that the first texture is the light map and the second texture is the regula texture.
  • Open the material file. locate the light map textures under the section texture_unit section. note that this texture should be the first of the two textures in the material. Add the following lines:
rtshader_system console

{ layered_blend lighten source_modifier src1_modulate custom [Dimmer number] }

    Where [Light Number] is a number between 0 and 19 describing the dimmer number which will control the system

  • You may also want to set the texture coordinate number with which the texture is placed. This can be provided using the property "tex_coord_set [Coordset number [0-7] ]" within the texture_unit section. If not provided all textures use the first texture unit to place themselves.
  • Repeat this process for all materials within the material file.

You should and up with a file containing material definition similar to the following format:

material [Material Name]

{ technique { pass { ... [Various pass properties] ...

texture_unit { texture [Light texture file name] tex_coord_set [Texture coordinate set number]

... [Various texture properties] ...

rtshader_system console { layered_blend lighten source_modifier src1_modulate custom [Dimmer number] } }

texture_unit { texture [Regular texture file name] tex_coord_set [Texture coordinate set number]

... [Various texture properties] ... } } } }

A note on the lines added to the material:

  • "rtshader_system console" - Tells the system that we need to use a special shader on the given texture and that that shader is intended for the console/cockpit.
  • "layered_blend lighten" - Tells the system which shader to use. In this case a shader which will select the maximum color between the given ambient light and the light of the texture
  • "source_modifier src1_modulate custom [Dimmer number]" - Tells the system that the current texture should be modulated by a value which the system internally connects to the proper dimmer color.


Performance considerations

  1. It is preferable, performance-wise, to create only a single AGI with both a regular and dimmer texture, instead of creating 2 AGIs, one to simulate normal lighting and one for the dimmer lighting.
  2. It is important to note that while setting the ambient model of an AGI or the dimmer it is attached to carries a performance penalty, updating the color of a specific dimmer light or the amount of ambient light in the cockpit does not. These values may be changed frequently.