### Lights

The converter supports:

- ambient light
- positional lights

You can set the ambient light for your sector adding properties to the max level. Clicking on File>File Properties. Select the Custom Tab, enter this data:

Name: red / Type: Text / Value: <enter the value from 0 to 1>
Name: green / Type: Text / Value: <enter the value from 0 to 1>
Name: blue / Type: Text / Value: <enter the value from 0 to 1>

If you do not specify these values, the engine will use it's default of red=0.2 green=0.2 blue=0.2

To add positional lights you should add 'Omni' lights. There are the only ones supported by the exporter. To place a new light click on Create->Lights->Omni.

To have the same effect in PlaneShift and in 3DSMax you should define your omni light with these parameters:
Under "General Parameters" you should have "Diffuse" and "Specular" checked, "Ambient Only" UNchecked.

Color:
Colors can be defined in the RBG or HSV sections of the light.

Multiplier:
Mutiplier is supported. Normal light intensity in PlaneShift can go from 0 to 1, if multiplier is used then it can go beyond 1.

Range:
The maximum range of the light is defined by the value of "Far Attenuation End" in Attenuation menu. This is considered also if you no attenuation is used (see below).

Attenuation:
"Near Attenuation" IS NEVER used, the exporter simply ignore the setting.
If in section "Far Attenuation" the checkbox "Use" is NOT checked, then the light will be defined in PlaneShift with parameter "No Attenuation", so light will be costant up to the maximum radius.
If you want attenuation to be used, then check the "Far Attenuation" box, and insert the radius value in "End" field. Leave Start at "0".

Dynamic Lights:
Lights can have a dynamically changing color. If this is the case, read the "Export Lights" chapter or more info on how to define hue changes.

Lightmap cell size:
Every illuminated object has a lightmap associated. A pixel in the lightmap is created for every cellsize x cellsize pixels of texture size.
Example: Using a size of 32, 1 pixel in the lightmap will be created every 32x32 pixel in the texture.
Bigger cellsize means that less lumels are created to describe the illumination of an illuminated polygon this means less used ram but less defined shadows.

You can set the Lightmap cell size value with this procedure:

- Clicking on File>File Properties. Select the Custom Tab

- Enter this data:

  Name: lightmapsize
  Type: Text
  Value: <enter the size, e.g. 16 or 32>

- Click on Add.

If this entry is not specified the engine will use CS default (that is 16).

Auto On/Off based on Threshold:
Lights can be turned automatically on or off based on the value of another light (controller). This is used to turn on house/street lights at night and turn them off at sunrise. To enable this feature you must abide to these constraints:
- the light that will turn on/off must not be dynamic, it should have a fixed light color during the day/night cycle.
- the controller light must be named 'crystal' and should be dynamic. This light will be affected by other factors like rain. So depending on its intensity value will control the on/off of other lights.
- there must be only one controller light for each sector.
- All lights that should turn on/off must have these parameters set in the Custom Properties tab:

TURNONOFF_R=0.2
TURNONOFF_G=0.2
TURNONOFF_B=0.2
TURNONOFF_FADE=1000

for RGB range is from 0 to 1, fade is expressed in msecs.

In the example above lights will turn off when the 'crystal' light is >0.2 and will turn on when the 'crystal' light is <0.2

Lights with same RGB threshold values are packed in one event for the game, so performances will be better if you give lights same threshold values.

Lightning: The engine now support a brief sequence that simulates a lightning, this sequence will be triggered randomly by the server in all the sectors with the lightining property set. To enable it :

- Click on File>File Properties. Select the Custom Tab

- Enter this data:

  Name: lightning
  Type: Text
  Value: yes

- Click on Add.

## Export Lights

This command allows you to export the light information that will be used by PS engine to render lights at different times in the day.

Select PlaneShift->Export Lights.

Please note that:

- You must set the total frame number to 24 (from 0 to 23) or to 48 (from 0 to 47)
- Every frame represents a certain time of the day: 1 frame for each hour starting from 0:00 am (midnight)
- You can add an OmniLight called "ambient" that represent the ambient light. This light will not be exported as a normal light, the coordinates it has are not relevant.
- The lights will be exported to a separate xml file, but those MUST be the same ones present when you exported the level.

The first 24 frames are used to get the light colors when the sun shines and no rain is present. The frames from 25 to 48 are used to get the light colors when the is heavily raining so the sun will be obscured by clouds and rain. The engine uses those extreme values to find the good ones when it's raining at 20%, 50%, etc...

If you set the animation length to be 24 frames, then shining sun condition and heavy rain condition will have the same light color values.

Next: Sectors and Portals