ALS technical notes: Difference between revisions

Jump to navigation Jump to search
Line 1,194: Line 1,194:


sets up a grain overlay with a 10-time higher resolution over the base texture layer.
sets up a grain overlay with a 10-time higher resolution over the base texture layer.
== ALS procedural lights ==
The ALS framework supports procedurally generated lights (for instance aircraft position lights, strobe lights,... ) for aircraft and models. Note that the effect produces the visuals of the lights themselves, but they do not illuminate their surroundings.
=== Why procedural lights? ===
Traditionally aircraft position lights have been implemented as billboarded emissive textures. This technique is limited in scope, as it has difficulty producing a directional light or changes in the light appearance (for instance glare) with changed scene lighting. The ALS procedural lights are designed to give visuals consistent with the auto-generated scene lights (runway lighting, street lights) and support configurable directionality, glare and even the illumination of fog by the lights.
=== Basic implementation ===
The base of the light is a texture quad which has Effects/procedural-light.eff assigned. Start from including the template provided into your model as
<syntaxhighlight lang="xml">
<model>
  <path>/Models/Effects/procedural_light.xml</path>
        <offsets>
            <x-m> 0 </x-m>
            <y-m> 0 </y-m>
            <z-m> 2 </z-m>
        </offsets>
</model>
</syntaxhighlight>
and configure from there according to your own needs.
<b>Do not billboard the light via animation!</b> The GLSL code will take care of the billboarding. Use a scale animation to change the size of the light, do not change the quad (the *.ac) itself in size, the shader code requires its geometry to be fixed.
=== Configuring the light ===
Make your own derived effect inheriting from Effects/procedural-light.eff and assign it in the xml wrapper of the light.
* the base light color can be set via
<syntaxhighlight lang="xml">
    <light_color_base_r type="float">1.0</light_color_base_r>
    <light_color_base_g type="float">0.0</light_color_base_g>
    <light_color_base_b type="float">0.0</light_color_base_b>
</syntaxhighlight>
These take the normal set of values ranging from 0 to 1.
* how the light appears at full intensity in the center can be set via
<syntaxhighlight lang="xml">
    <light_color_center_r type="float">1.0</light_color_center_r>
    <light_color_center_g type="float">1.0</light_color_center_g>
    <light_color_center_b type="float">1.0</light_color_center_b>
</syntaxhighlight>
The idea behind this is that lights give a better visual appearance if their center is rendered visually brighter and de-saturated, but this occurs only if the light is at full intensity.
There are no sanity checks done, you can assign any center color you like even if this makes no sense - you can change center color or darken it, so use with care.
* to runtime change the light intensity, assign
<syntaxhighlight lang="xml">
    <intensity_scale type="float">1.0</intensity_scale>
</syntaxhighlight>
to a property and change that property in the range from 0 to 1.
* for directional lights, you need to assign a pointing vector in aircraft coordinates into which the light cone points and set the directionality flag to true to activate the computations. This is done via:
<syntaxhighlight lang="xml">   
    <pointing_x type="float">-1.0</pointing_x>
    <pointing_y type="float">0.0</pointing_y>
    <pointing_z type="float">0.0</pointing_z>
    <is_directional type="bool">true</is_directional>
</syntaxhighlight>
It would be customary to pass a normalized vector, but if you don't know how to do it, the shader will do it for you. By assigning properties to the pointing coordinates, the light direction can be changed runtime.
* fading of a directional light  away from the pointing axis is controlled by passing angles (or rather sines of angles).
<syntaxhighlight lang="xml">   
    <inner_angle type="float">0.2</inner_angle>
    <outer_angle type="float">0.4</outer_angle>
    <zero_angle type="float">0.7</zero_angle>
    <outer_gain type="float">0.5</outer_gain>
</syntaxhighlight>
Up to inner_angle, the light will have full intensity. From inner to outer angle the light will linearly fade to outer_gain. From outer angle to zero angle, the light intensity will linearly fade to zero.
* to get an automatic strobe effect you can set
<syntaxhighlight lang="xml">   
    <is_strobe type="bool">true</is_strobe>
</syntaxhighlight>
to true. If you want your own strobe pattern, generate a strobe function and use <b>intensity_scale</b> instead to pass it to the shader.


== ALS fuselage shadow effect ==
== ALS fuselage shadow effect ==
1,360

edits

Navigation menu