Howto:Multi-channel lightmap: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 223: Line 223:




== Using XML and GLSL to activate the lightmap in FlightGear ==
== Using XML and GLSL to activate the multi-channel lightmap in FlightGear ==




Now that we have a multi-channel lightmap we are ready to use it in FlightGear. First thing we need is to assign the lightmap effect to the objects that the lightmap was created for. The code looks like this. Even though in my Blender baking example I joined all the object into one object prior to baking (I called it cabin). In the XML they need to be listed as they are actually used or called in the XML. In the case of the shuttle there were approximately 600 objects affected by the lights and subsequent lightmap. But for this example I will only use a small subset of the total objects involved.
Now that we have a multi-channel lightmap we are ready to use it in FlightGear. First thing we need is to assign the lightmap effect to the objects that the lightmap was created for. The code looks like this. Even though in my Blender baking example I joined all the object into one object prior to baking (I called it cabin). In the XML they need to be listed as they are actually used or called in the XML. In the case of the shuttle there were approximately 600 objects affected by the lights and subsequent lightmap. But for this example I will only use a small subset of the total objects involved.


First in the aircraft's model file. Where shuttle-interior is the name assigned to the effects code in the effects file that will contain the code to activate the lightmap. This block tells the program what objects to apply the associated effect to.
First in the aircraft's model file. Where shuttle-interior is the name assigned to the effects code in the effects file that will contain the code to activate the lightmap. This block tells the program what objects to apply the associated effect to.


Aircraft/SpaceShuttle/Models/cockpit.xml
Aircraft/SpaceShuttle/Models/cockpit.xml
Line 245: Line 247:




Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior.xml
Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior.eff
<syntaxhighlight lang="xml">
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
Line 251: Line 253:
<PropertyList>
<PropertyList>
     <name>Effects/shuttle-interior</name>
     <name>Effects/shuttle-interior</name>
     <inherits-from>Aircraft/SpaceShuttle/Effects/model-interior-extended</inherits-from>
     <inherits-from>Aircraft/SpaceShuttle/Effects/model-interior</inherits-from>
     <parameters>
     <parameters>
         <lightmap-enabled type="int">1</lightmap-enabled>
         <lightmap-enabled type="int">1</lightmap-enabled>
Line 274: Line 276:
</PropertyList>
</PropertyList>
</syntaxhighlight>
</syntaxhighlight>
Note:
lm-F1-F2-F3-F4.png is the multi-channel (four channel) rgba lightmap.
lightmap-factor is a property created in the -set file that allows you to control the intensity of the lightmap effect.
== Extending the multi-channel lightmap to use 8 channels or 2 X 4 rgba channels ==
The multi-channel lightmap effect can be extended relatively easy to allow for as many as 8 light light sources. The SpaceShuttle was extended to use 8 lights in the cockpit.
But because it is out of the scope of this tutorial I will just refer you to look at the following files to see how it is accomplished.
Extending the multi-channel lightmap to allow for more light should only be undertaken by experienced developers that are somewhat familiar with the XML wrapper and GLSL code.
Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior.eff
Aircraft/SpaceShuttle/Effects/model-interior-extended.eff
Aircraft/SpaceShuttle/Shaders/model-interior-ALS-extended-lightmap.frag
You can compare the above files against their counterparts to see the differences and how it was extended.
Aircraft/SpaceShuttle/Models/Effects/Interior/shuttle-interior.eff (the above example file).
fgdata/Effects/model-interior.eff
fgdata/Shaders/model-interior-ALS-detailed.frag
330

edits