Level of detail creation (ASM tweak)
This article has been written by Christian Stock on the AvSim forum. It is kept here for knowledge gathering purposes. It has been written for Fs2002, so not everything is still valid in Fs2004. With the Fs2004 GMax gamepack, MS has also provided more details about LODs.
If you want to design scenery that has a lot of detail, but is also framerate friendly, there is no way around LOD (level of detail) models. The theory behind LOD models is to use several models of different detail, and displaying one of the models depending on how far you are away. If you are very close FS2002 should display a very detailed model, so you can see all the detail. When the you are far away, the model is much smaller on the screen, due to the perspective, and you can't see all that detail (on top of that the scene gets rendered to pixels, which only give a limited resolution). So drawing a detailed model would be wasted computing / rendering power. It makes more sense to use a less detailed model in that case.
FS2002 allows for different LOD models and for 'per parts LOD' which allows to switch parts of your model on and off depending on distance. Per parts LOD can be done in gMax directly and doesn't require any source code modifications. However, per parts LOD has one disadvantage. You can't use it to have a seperate shadow model. Computing a perspective shadow is demanding a bit of processing power, so the less detailed the shadow model is the better. Usually, it doesn't matter if the shadow isn't very accurate, so using your lowest LOD model for rendering the shadow is mostly a good idea.
On a side note, you can do even more advanced things with LOD models. For example, if you are using billboards (i.e. polygons that rotate towards the viewer) to render trees, you wouldn't get a very realistically looking tree shadow (i.e. it would be rectangular). You could make a simple 3D model for the tree that would cast a more realistic shadow instead.
Making LOD models isn't all too hard. First, you'll have to create your models. Since buildings don't have all that much detail, I usually make 2 or 3. You don't want to create models that have too many changes, i.e. a sequence of models with small changes is ideal (but also more work). The reason for having multiple objects is that you want to have as few visible changes as possible. Changing from one model to another will be noticable (the so called popping effect), and ideally this is minimised by placing the transition so far away that changes are barely visible. However, sometimes the popping effect can't be avoided, for example, if you place a one million polygon city next to an airport. If the player's aircraft is in the vicinity of the airport, only a low detail city should be used, otherwise the amount of polygons to render might push the framerates to a limit where landing will become more of a gamble. Chances are the player is busy concentrating on the airport anyway rather than on the high detail city.
Once the models are done, you'll have to rename them. Change the suffix of the gmax BGLC files, eg _0 becomes _0, _1, _2, etc. These will be your model files. Then you'll have to add this to your wrapper file (the one without a suffix), after the crash call:
BGL_CALL model_0000_crash (insert after this) IFSIZEV object_LOD_0000_1L, 10000, 1000 BGL_JUMP_32 LOD_0000_0L object_LOD_0000_1L label word BGL_JUMP_32 LOD_0000_1L
The IFSIZEV controls the distance of LOD change, i.e. 10,000m correspond to 1000 pixel on the screen. In other words, when each pixel corresponds to 10m of the building (e.g., the building is 100m high and is rendered onto 10 pixels) the rendered model gets exchanged with another LOD model. There are other commands you could use, but this is what Microsoft used in the default scenery.
At the end of the wrapper file you need something like this:
LOD_0000_0L label word include object_0.asm LOD_0000_1L label word include object_1.asm
This will call your LOD model source files. Compile your wrapper file and drop it into your scenery folder.