Managing Translucency

About Translucency Problems

A surface on a model is translucent if you can partly see through it – that is, its opacity is somewhere between 0 and 100%. Translucency presents problems for X-Plane models because it produces artifacts.

When Does a Model Have Translucency

A model will have translucency if any part of its texture has an alpha channel value that is not fully opaque or fully transparent.

A model will also have translucency at the soft edges between an opaque and transparent region. If blending is disabled (ATTR_no_blend for objects), there will be no translucent parts of the model.

Artifacts Introduced by Translucency

When there is a translucent section of an object, any scenery, model or airplane drawn after the translucent surface that is behind the translucent surface will disappear. For example, the interior of an airplane will not be visible behind the windows if it is drawn after the windows.

X-Plane’s Drawing Order

X-Plane’s drawing order is important because translucent surfaces must be drawn after the objects they are in front of.

Drawing Order Within Objects

The drawing order within an object is determined by the OBJ file – that is, the drawing order is not changed by X-Plane. This means that within an object, translucency problems can be solved by reordering the object.

Drawing Order Between Objects

The drawing order between scenery objects is not guaranteed, and will depend on runtime factors. Currently X-Plane has no mechanism for managing translucency between objects.

Drawing Order of Objects in an Airplane

Within an airplane, the drawing order is:

  1. The cockpit object, for external views (cockpit_OUT.obj).
  2. Attached objects with “outside” lighting, in order.
  3. Attached objects with “inside” lighting, in order.
  4. The cockpit object, for internal views (cockpit_INN.obj).
  5. Attached objects with “glass” lighting mode, in order.

Use Cases For Dealing With Translucency Problems

In all cases, the correct draw order will be opaque objects, then translucent objects in the order we see them (farthest to closest).

Translucency In Front of Opaque

If a translucent surface is always in front of an opaque surface, the translucent surface simply needs to be drawn after the opaque surface. The simplest way to do this is to make the translucent surface be at the end of the OBJ. This works well for cases where the camera cannot get in between the translucent surface and the opaque surface behind it. Examples:

  • Glass windows in the front of a building, where only the interior of the building is visible behind them, as long as the user cannot fly into the building.
  • An overlay decal like a pavement line on top of pavement. (If the pavement lines are not ATTR_no_blend, then they effectively have translucency around their edges, so this case does have to be considered!)

Multiple Windows for Airplane Cabins

The airplane cabin provides a real challenge: we can see in one window and out the other, or we can look out from the inside. To make this case work right, follow the following steps:

  • Put all windows in an object of type “glass”. This puts them at the end of the airplane’s draw order, after the cockpit object (which might have opaque elements like a pilot).
  • Within the glass, make each window out of two sets of one-sided geometry. This allows you to order the “inside” view of the glass” and “outside” view separately.
  • Within the glass object, put all glass that is visible from the INSIDE before all glass that is visible from the OUTSIDE.
  • Facebook
  • Reddit
  • StumbleUpon
  • Twitter
  • Google Buzz
  • LinkedIn