Category: Development

Is X-Plane on Crack?

I just fixed a bug in the mesh crack-patching code. This is a tricky subject, so here’s some information before you file bugs:

Two separate scenery tiles (whether DSF or ENV) may not line up perfectly when placed edge-to-edge. The most common reason is because their elevation data can come from different data sources, but in a few cases files from the same render can have alignment problems.

(In the case of the global scenery, if we have special circumstances like water or airports that must be flat and the features span a tile boundary, the flattening may not work the same way in both tiles. The scenery is also rendered on blocks on different computers, and the blocks may not tile perfectly.)

Whether the error is due to a bug or just two scenery packs together, the sim tries to do its best to fix any gaps in the terrain mesh. (The sim does not try to fix different textures that touch; this is beyond the sim’s capabilities of analysis.) X-Plane will take whichever file is loaded most recently and try to realign its edges to match the old edge. When this works right, you can’t see a seam. More importantly, if an airport spans that border, you can drive over the border (on a runway) without the plane hitting a bump.

I just fixed a bug in the crack-patching code where it would sometimes incorrectly fix a patch. So if you see a ‘crack’ in the terrain (basically you would see the sky color showing between terrain triangles as a sliver of light blue or grey) please report it as a bug, but be sure to include the following information:

  • Please include a log.txt file so we can see what you have installed. Be sure to quit x-plane before emailing the log.txt file.
  • Please include a screenshot of the crack. Turn on the framerate, plane lat/lon and camera position datarefs.
  • Please set your sim resolution to 1024×1024 or smaller and send the original PNGs. Please do not crop, process, or compress them. Please do not send JPEGs.
  • Please tell us the nearest ICAO airport so that we can easily go to this location.

As always our bug reporter can be found on a link from

Some crack bugs may be due to a scenery defect (to be addressed the next time we make new scenery), some may be due to sim bugs, and some may be due to the combination of two scenery packages next to each other.

Posted in Development by | 1 Comment

Lights and LOD

EDIT FROM 2/19/07: this article mentions some bugs with light visibility from X-Plane 850 betas. These bugs were fixed, and the mechanism of detachment is entirely internal to X-Plane. So please bear in mind when reading this that while this describes the internal engine of X-Plane, you as an author don’t need to DO anything special for lights.

One user reported that the taxiway lights are visible a very long way away from the airport. This is true, but it is probably not a cause for concern. By comparison, the airport beacon has a way of disappearing – hopefully less so in beta 11. Here’s what’s going on:

(When I say “light” in this blog post, I mean the little ball of color that is supposed to simulate the look of a light bulb. “Fixture” refers to the 3-d object modeling the real-world device that holds that bulb in place. The actual rays of light cast are not simulated – that’s why the approach lights don’t illuminate part of the plane no matter where you fly. Current graphics hardware just doesn’t give us that ability yet.)

In X-Plane 850 all “lights” are made via OBJ8 objects. The OBJ8 object may contain both 3-d geomemtry that forms the fixture, and one or more “lights”, created via either the LIGHT_NAMED or LIGHT_CUSTOM command. Objects may also have multiple versions based on LOD. If you don’t use ATTR_LOD, a single LOD range is assigned by X-Plane based on how big your object is. (Bigger objects will need to be visible farther away.)

Now here’s where it gets weird. Some of the lights in an object are “detached” by X-Plane from the OBJ and stored separately in the scenery. We do this for performance – the detached lights can be fed to the graphics card via a different mechanism that is much faster than regular OBJ drawing. One of the effects of light detachment is that the detached lights are no longer limited by the LOD of the object. They instead are drawn to much further distances. The fixtures of the objects, however, are never detached…thus some of the airport light OBJs in X-Plane are only visible to 500 meters. We can get away with such a low distance because the light bulb itself is detached and will remain visible.

So which lights are detached? Well, it depends on a number of factors – lights are only detached if they are not subject to animation and they are simple enough to be drawn in bulk. Which lights are these? It’s hard to predict.

So the airport beacon and taxiway light work differently; the taxiway lights are very simple and are detached – hence they are visible a long way away. The airport beacon lights are animated (the light bulbs rotate with the fixture), and are never detached. Thus the airport beacon is subject to LOD constraints and taxiway lights are not.

If you set the world level of detail setting to “low” or “very low” it simply reduces the LOD ranges of all objects. Thus on “very low” the airport beacon may be seen to disappear before the (detached) taxiway lights. For beta 11 I have tried to set the airport beacon LOD large to be enough that even on such low settings the beacon will be visible farther away.

There is one more piece to the puzzle: all lights become dimmer with distance. So in theory our hope is that the lights will become fully dim due to distance before we stop drawing them with LOD, producing a gradual fade-out rather than a sudden disappearance. But if we don’t tune all of these parameters right, lights can randomly appear to disappear in the distance instantaniously.

If there’s a moral of the story, I’m not sure what it is, except perhaps: this new light system is very new, and I am sure our artists will tune it a bit over the next few versions of X-Plane, helping to hide these implementation artifacts.

Posted in Development by | 1 Comment

Taking a Detached View

EDIT FROM 2/19/07: during X-Plane 850 when I was developing the new lighting system (particularly used for airports, but also for the rest of scenery) I brought up the subject of “detachment”, a internal process by which the X-Plane rendering engine processes lights.

Simply put: detachment is virtually never a factor for scenery authors. Back when I wrote the article, it was possible for an author to make a few special optimizations if he or she knew about detachment. This is no longer true! The sim will correctly optimize all lighting cases as much as possible without any special help from the author.

So….the blog article in its original form follows and may be useful as an insight into how X-Plane works, but as an author, just remember: you don’t need to do anything – just make nice OBJs.

I think I’ve confused just about everybody in the last few days – especially Sergio and Austin – with work on the new lighting system. One reason I’m so scrambled: the internal representation of lights in X-Plane is very different from the commands you can put in an OBJ8 file. So there’s a whole set of terms and ideas that are important to how X-Plane works that I shouldn’t have mentioned to anyone making OBJ8s because they won’t even be part of the file format.

Then there’s detachment. I think I can explain it simply like this: detachment is when X-Plane changes the order that lights are drawn inside an OBJ and the LOD ranges in which they are drawn to improve framerate.

X-Plane 840 does not do detachment. X-Plane 850 will probably not do detachment for objects made only with the old lighting commands. But 850 will do detachment for objects that use new (to 850) lighting commands, and this will allow those objects to render very quickly even with textured lights.

This picture is actually from X-Plane 8.03 I believe. It’s a simple trick: edit the roads file to add street light objects along all roads. Make a street light object with a light command and then turn roads on and watch teh city at night appear.

The only problem is the frame-rate – this experiment brought 8.03 to a standstill.

The goal of detachment is to make textured lights in objects fast enough that this kind of scene can be rendered at reasonable framerates. I do not know if this will be possible, but detachment should certainly improve performance in cases like this.

Posted in Development by | 2 Comments