Facade Overview

A facade is a special type of object in the X-Plane scenery system. Normally an object is specified as an OBJ file and placed in the scenery at a point and given a heading. With a facade, a facade specification text file (.fac) specifies what texture should be used for the object and how to build flat walls from part of the texture. The facade object is then placed in the scenery file along a polygonal path, and a building is extruded.


 * [[Image:about_facades_recipe.gif|thumb|alt= |The recipe for a facade in X-Plane]]

Facades allow you to specify a large number of buildings, each with a different shape, using one texture. The facade object is built from your facade specification text file in a smart manner, with the texture being replicated as well as stretched to look good at different sizes.

Facade concepts
A facade specification text file (spelled out in depth here) specifies how to build a facade object along a polygonal path. The facade text file specifies a texture; each facade object may (like OBJ files) use only one texture.

The DSF file will specify a polygonal path for the facade object and the number of floors to build; this lets each facade object be a different height.

A facade specification text file may designate a ring or chain facade. A ring facade object is a closed loop, which is useful for a building. A chain facade object is simply a set of connected links, which might be useful for a fence, etc.


 * [[Image:about_facades_chainring.gif|thumb|alt= | ]]

A facade specification contains one or more levels of detail (LOD), or definitions for what the facade should look like at different distances. Each facade LOD specifies a minimum and maximum viewing distance. The various levels of detail must be continuous without gaps; the facade will not be drawn beyond the last level of detail. (This is the same as for OBJ files.)

Each LOD for a facade specification is in turn made up of one or more walls. Each wall is broken into a number of horizontal divisions called panels, and vertical divisions called floors. Each wall specifies its panels and floors in terms of the texture for the facade object, as well as a resolution for the texture, to convert from pixels to meters. As a wall in the facade object is stretched or shrunk, panels and floors are added and removed to make the wall the right size. Each floor and panel in a wall can be specified as repeatable or non-repeatable, for visual control of the wall.


 * [[Image:about_facades_panfloor.gif|thumb|alt= | ]]

Each wall has a minimum and maximum length; as a facade object is built, x-Plane will look through every wall definition and randomly pick one wall whose length range matches the wall being built inside the sim. This allows you to specify one wall for short building sides and one wall for long building sides.


 * [[Image:about_facades_two_walls.gif|thumb|alt= | ]]

The roof of a facade (if specified) is always a solid color and is specified as a coordinate on the facade's texture. Multiple roof coordinates can be provided, in which case X-Plane will pick one randomly.

The top floor of a facade can be sloped inward on a per-wall basis. Strange results may occur if the walls collide when angled.


 * [[Image:about_facades_angle.gif|thumb|alt= | ]]

How X-Plane Selects Facade Panels and Floors
The algorithm for selecting panels and floors is the same horizontally and vertically, and goes like this:
 * All end tiles are used before any middle tiles.
 * End tiles are equally balanced on both ends; for an odd number of tiles, the left/bottom end is preferred.
 * Only middle tiles can be repeated.
 * Middle tiles are used in left-to-right or bottom-to-top order.
 * Middle tiles will be split to match their left-right edges where possible.

Example: this horizontal stripe represents 9 panels: ABC = left panels, 123 = middle panels, XYZ = right panels. So the facade texture is organized as:

ABC123XYZ

This is the set of geometry created as the number of panels is increasd; spaces represent X-Plane inserting an additional quad to form the shape.

A A Z AB Z AB YZ ABC YZ ABC XYZ ABC1 XYZ ABC1 3XYZ ABC123XYZ    <= exact match, only one quad ABC12 23XYZ ABC123 23XYZ ABC123 123XYZ ABC123 1 123XYZ ABC123 12 123XYZ ABC123 123 123XYZ ABC123 123 1 123XYZ

Drawing a Facade in World Editor
See the Airport Customization tutorial for information on drawing a facade in World Editor.

= Facade Optimization =

Facade performance is typically limited by the amount of free memory, not framerate. That is, on most machines, a complex project with a large number of facades will exhaust memory before frame-rate becomes a problem. Most of these tips therefore focus on memory optimizations. (The smallest RAM footprint does also turn into lower vertex count, which is good for framerate too.)

Correct Winding Order
Facades must be wound counter-clockwise, per the DSF specification. If your facade building's roof is only visible when TWO_SIDED is set to 1, your facade is wound backward!

No Duplicate Vertices
Do not duplicate any vertices in the facade.

Do not repeat the first vertex as the last vertex; a square facade should have IS_RING 1 and contain only four vertices in the DSF. X-Plane will "close" your loop for you.

Avoid points in a facade that do not define the shape. For example:

123 |        | 5-4

Point 2 should be eliminated for performance.

Sloped Roofs
Sloped roofs have some extra requirements:


 * No duplicate points, and no "straight" points (see above).
 * The roof is built out of a floor, so most times you will want at least two floors.
 * The roof should not fold in on itself.
 * If the facade is wound wrong, sloped roofs will not work.

Reducing Mesh Complexity
The facade engine can consolidate adjacent panels, but it must use more geometry to repeat panels. For this reason, it is best to make a facade wall that contains enough texture and panels to model the largest wall in your facade without repeating/duplicating texture space. A facade can be built in as few as 1-4 quads when geometry is cut, but if the panels are small, repeating the panels burns through a lot of memory.

The facade engine is most efficient when you do not use sloped roofs, the facade is convex in footprint, and the wall definitions match the real size of the facade both vertically and horizontally.

TWO_SIDED
Do not use TWO_SIDED for buildings; use one sided geometry and fix your winding order if necessary. TWO_SIDED is intended only for fences.