Apron lighting using effects and GMax
From FSDeveloper Wiki
There has always been some confusion regarding the limitations of placing effects as ground lighting in Flight Simulator. This document gives you complete and correct information regarding these matters and should ensure better scenery from all of you! Detailed below are my and other peoples findings summarized into one document.
Should you have a suggestion for the document, I would appreciate if you could comment on the forum first before changing here.
 Previous requirements
 Creating an Effect
Before creating an effect, you have to undertand a problem that happens with effects. When you start Flight Simulator outside of the spawn area, you get to the airport and you have no effects. What's happening is that the model is spawning outside of the radius that the effects work, which means that the model spawns, the effects say "Oh I'm nowhere near the plane, I'm not going to draw" and then the effects don't respawn because they were a one-time effect with infinite lifetime.
You have two options.
 Emitter Workaround
The first option is to set the lifetime of the emitter to 0 in your effect file. Look for:
[Emitter.0] Lifetime=0.00, 0.00
However, it should be noted that when you use this method if your **framerate drops** the **lights will get brighter** if the effect overlaps.
 Controller Workaround
The second option is to use a controller file. There was a lot of discussion on this top on [thread]. I am now certain that the following instructions work, I have tested them a few times now.
What you want to do is create a static effect much like the plane navlights, use fx_navwhi.fx as a template. (This will eliminate the brightness problem with frame rate fluctuations) and then create a proximity controller that triggers the effect within the radius of the model instantiation.
So what happens is the controller tests proximity and creates the effect right after the model is created. In the sample below, I spawn the navwhih effect 10km out. I tested this by placing the effect in Westport (on the Washington coast) and then started my flight in Olympia (about 60 miles away). The effect was there when I got there. You could probably adjust the distance out even further as well. Here's the controller snippet to use:
[Library Effect] Lifetime=5 Version=1.00 Radius=200 Priority=0 [controller.0] lifetime=0.0, 0.0 type=3 distance=10000.00, 10000.00 delay=10000000.00, 10000000.00 x offset=0.00, 0.00 y offset=0.00, 0.00 z offset=0.00, 0.00 effect.0=fx_navwhih, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00
As you can see, type 3 controller is proximity, which means the effect will trigger when you are within [distance] of the effect. In this case, 10,000 meters. The delay set to 10000000.00 means that the controller will not trigger the effect again until 10000000 seconds have passed (and who's going to fly that long really). Therefore it triggers a single instance of the effect when you are within 10,000 meters of the effect. The only possible problem with this solution is that if you go outside of the radius of the effect and unload it, you might not get it back again. But, if do that, the model will also unload, and then reload when you get within range.
 Drawing your light boxes
After you have created your ground / apron in GMAX or another program, set that as your background in a **NEW** gmax file. Obviously, if you used GMAX this will be really easy as you simply copy your ground / apron file and place it in the same location in the scenery XML.
The reason for the new file is that you can export your lighting as a seperate MDL to your ground layout, and then you can use MDLTweaker to set display parameters for that MDL. This means that you do not need to create effects parameters because you can turn "on and off" your entire MDL. The other advantage of a seperate MDL file will be the fact that you can also create LOD files for you lights which we will get into later.
Now. Here is the time consuming part :)
A more in depth tutorial for developing the light box and material can be found here here
 Placing the Effect Methods
 Using the Attachtool Script
You can use the attach tool that Microsoft kindly supplied. This can be a time consuming method as you **must** run the tool against every object separately. In fact, the more I think about it... you would be crazy to place this many lights using this method :) Forget I even wrote this.... unless you are a glutton for punishment.
 Placing the Effect using a script for multiple objects
Thanks to Adrian Woods, from the ACES Team, the following script will take every object that is named box_whatever and will attach the effect of your choice with a little editing. When I get a chance I will get it to actually prompt you for the effect name and also ask you what the last box number was that you applied to (therefore you can run over and over again).
Download this GMAX Script then edit it as required. The information you will need to change is pretty obvious, but I shall explain.
Simple eh ;)
 Creating a bounding box
Once you have placed all of your lights and have attached your effects, you **must** create a transparent bounding box around the entire set of lights / boxes. To do this simply draw a box, and ensure that it encompasses all the boxes / lights, and then apply a standard texture. Once that is done, set the texture to "0" opacity, then convert the box to an Editable Mesh.
 Exporting to Flight Simulator
Export the Boxes (now named attachpt_whatever) and the bounding box to a MDL file. Place this MDL file in the usual manner.
I would strongly suggest that the lights are placed a little above the ground as this will stop the flickering of the lights.
You may, of course, want to edit the MDL parameters using the MDLTweaker tool before compiling to your BGL library. You should now have ground lighting!
 I cannot see all my lights - Effect.cfg
Due to a limitation in the FS Game engine, you need to add a file called **effect.cfg** into your Effects folder to ensure that all your lighting shows up. (There is, of course, a MDL limitation of about 2000 objects - but this is not what I am referring to here).
The file must contain:
[Sprite Limit] Medium=500 High=9999999999 Low=100
 Scenery Excludes and Library Objects with Attached Effects
There is a "feature" of the Flight simulator Exclude XML that causes effects to dissapear if you exclude Library Objects. What this means is that the RefPoint of your excluded MDL must NOT have an exclude that includes Library Objects. The best method is to create small excludes around object you want to get rid of.
 View Limitation of the Effects
There is a limitation on the view distance of an effect. For apron lighting this should not really matter, but if you are creating runway lights it may. The answer is to create LOD's of your placed effects and use a "brighter" effect on each LOD. The way you give this impression of brightness is to actully increase the size of the effect itself. This way, the lights show up at a distance.
 Effects and how they affect framerates
Effects, IMHO, have very little effect on framerates.... but they DO have an effect. There has been a few threads on the forum regarding this subject.
//(Is it affect, effect or what? - the dictionary does not help here)//
It's indeed "effect". Affect is a verb, generally. Of course, so is effect sometimes. Gotta love English ;-)
 Limitation of 2000 attachpoints per GMAX export
If you are creating a ground layout of lets say 1000 Effects, and then you lay down those effects again for night=1, again for dusk=1 and again for dawn=1 you now have 3000 attachpoints. You will get an error of "Too Many Objects" when exporting using MakeMDL.
Now... here is a "gotcha" as well... if you had this GMAX scene, with these 3000 objects and selected only 1000 of them for "Export Selected" **this will still fail!**. The reason is that MakeMDL will ALWAYS try to export any attachpoint in your scene, even if you did not select the object that those attachpoints were attached to. Get me? :)
The workaround is simple. Create 3 GMAX files, one for each set of 1000 attachpoints, and export them as seperate MDL files. Then, place all these MDL files in the same location. Problem sorted! :)