article_type: Reference

X-Plane 11 Material Model

X-Plane 11’s Physically Based Rendering (PBR) uses a new material model for solid textured objects and meshes.

Physical Simulation

The X-Plane lighting and material model divide the light interaction with materials into two categories:

  • Specular reflection – this is light that bounces directly off the surface of a material. Speuclar reflection is responsible for mirror-like reflections, glossy appearances on materials and any white “sun spot”.
  • Diffuse reflection – this is light that makes it past the surface of the material and is partly absorbed. Diffuse reflection is significantly less directional and may be strongly tinted.  Diffuse reflection gives materials a “matte” look.

X-Plane 11 conserves energy between diffuse and specular reflection – having a stronger specular reflection reduces the amount of diffuse reflection automatically; in this way highly glossy and reflective materials don’t appear to be overly bright compared to matte materials.

Comparison to X-Plane 10: in X-Plane 10, specularity could be added without reducing diffuse reflectance; this meant that most reflective materials were brighter than non-reflective ones. An artist could choose to manually darken the albedo of a texture to compensate.

The microsurface of a material is considered to be rough or glossy (or some measure in between); roughness and glossiness are measures of how smooth the surface is, not how reflective it is. A surface can be highly reflective and highly rough at the same time.

Roughness serves to spread out specular reflections; a mirror image in a rough surface appears blurry, as each ray of incoming light bounces in several directions.

X-Plane 11 conserves energy as roughness is adjusted; the same amount of energy is reflected in a rough or glossy surface. The difference is that a glossy surface has a highly focused reflection; a light source’s specular reflection will go in one direction on a glossy surface, resulting in a specular highlight that is very bright but small.

By comparison, a rough surface diffuses the specular energy in all directions; the specular reflection is visible over a wide range of angles but is not very strong.

Comparison to X-Plane 10: in X-Plane 10, all surfaces are glossy and only the overall specular reflectance could be changed. Therefore it was impossible in X-Plane 10 to model a surface like asphalt, which is simultaneously very reflective and very rough. An artist could attempt to simulate this by creating a high frequency noise pattern of highly reflective and non-reflective pixels to manually “break up” the reflection, but when zoomed out this effect is incorrect.

Surfaces become more reflective when viewed at glancing angles; this is called the Fresnel effect. X-Plane 11’s rendering engine simulates this automatically. The specular reflectance of a material that is specified by the artist is its minimum reflectance, when the material is viewed directly (e.g. the camera is orthogonal to the surface).

X-Plane 11 automatically decreases diffuse light as the effective reflectivity increases. This avoids materials appearing too bright at glancing angles.

(This is probably a bug – the incoming light is not more glancing based on view angle! The actual effect of fresnel is more complicated because it is affected by the integral of all incoming light.)

Comparison to X-Plane 10: X-Plane 10 does not provide camera-angle-based variable reflectivity; as a result, materials often have to be made too reflective at all angles to make glancing angles look adequately reflective.

Material Properties

The major properties of a material are controlled by two channels of the normal map of a model:

  • Roughness is stored in the alpha channel of the object, with 1.0 (maximum opacity) being the most glossy surface, and 0.0 (the most transparent) being the roughest surface.
  • Base reflectance (how much light is reflected off of the surface at an orthogonal angle) is optionally stored in the blue channel; no blue means no base reflectance and maximum blue means a completely reflective material at all viewing angles.

This scheme is opt-in; objects use the NORMAL_METALNESS directive to indicate that the blue channel is suitable for base reflectance. (Since legacy models typically have strong blue values from tangent space normal maps, the blue channel must be ignored in legacy models.)

If metalness is not used, a base reflectance of 0.04 is assigned to the entire material; this is a good approximation for most dielectrics (plastic, wood, concrete, etc.) and also a reasonable backward-compatible value for X-Plane 10 content. The roughness channel is intentionally encoded to have the highest gloss value in X-Plane 11 match the most reflective material in X-Plane 10. (Since X-Plane 10 specular reflections were all highly glossy, this means that at least plastics and matte materials “just work” in X-Plane 11.)

X-Plane 11’s treatment of the albedo color (day texture) changes as base reflectance increases:

  • The albedo is used to tint specular reflections. While this is not strictly physically correct, it provides an affordable way to create tinted metallic reflections.
  • Because base reflection is increasing, the diffuse color becomes darker due to energy conservation.

Glass Effects vs Decals

The alpha channel of the albedo (day texture) is used to create translucent rendering, e.g. the mesh being drawn is blended with the mesh behind it to create a mixture of both colors. There are two physical interpretations of this alpha effect:

  • The top mesh is “translucent”, e.g. like tinted glass; the color taken from behind the mesh represents light transferred through the top mesh (translucency).
  • The top mesh does not always exist in the alpha-clear parts of the texture, e.g. like the holes in a fence. The top texture acts like a ‘decal’ over what is behind it. In this situation, partial alpha represents a blend of both materials as if there is a pattern of holes in the top mesh so small that both the presence and absence of the material happen in a single pixel. (Think of zooming out with a chain-link fence – the result is translucency.)

In practice, authors use one effect (alpha blending) for both physical cases (translucency and decals). The meaning of alpha matters for physical correctness.

When alpha means ‘decal’, clear alpha removes all lighting effects from the mesh. This is the correct simulation of the mesh not existing.

When alpha means ‘glass’, clear alpha removes the diffuse but not specular component of lighting effects from the mesh. This is the correct simulation of light passing through the boundary layer from ‘stuff behind the mesh’, rather than being absorbed.

X-Plane 11’s default interpretation is the ‘decal’ interpretation, which:

  • Matches X-Plane 10.
  • Is HDR/deferred rendering compatible.
  • Preserves decal behavior on surfaces like runway pavement.

Authors have the option in X-Plane 11 to use glass alpha as long as:

  1. The object is attached to an aircraft and
  2. The aircraft’s lighting mode is marked as “glass”.

In this situation, authors can put the BLEND_GLASS directive into an object header; this will cause alpha to make the diffuse channel translucent while keeping specular effects, for reflections on clear glass.

24 Comments

Scenery System Version History

X-Plane 8.00 (11/6/04)

This is the initial version available on DVD.

  • First version to read X-Plane DSF files and use the new library system and packaging.
  • OBJ7 cockpit texture commands added for 3-d cockpit objects with working panels.

X-Plane 8.01 (11/10/04)

This is a demo download of X-Plane 8.00.

  • Checkbox added to disable DSF loading, so users can use ENV or DSF scenery without moving files.

X-Plane 8.03 (12/30/04)

This is the first major bug-fix update to the original X-Plane. Besides a number of enhancements to the scenery system to improve the look of the new scenery, it also fixes a number of big performance-killing bugs. Note: this build was originally called X-Plane 8.02 but was accidentally released without a beta label. It has been renamed to 8.03 to prevent confusion about what build is most recent.

  • On two texture unit machines, X-Plane will load only the base layer of composite terrain types when there is a border texture. Previously borders would not be visible because X-Plane would run out of texture units, so this change effectively prefers borders to composite textures.
  • Object Version 2 support restored to the sim. This is a legacy format and not recommended for new development, but is supported by 802 for scenery migration.
  • Libraries may reference multiple objects or facades for one virtual path, providing for variation on an object to be provided by an add-on library.
  • Facades can have night lighting textures via the TEXTURE_LIT command.
  • Facades can have real textured roofs instead of a solid color.
  • Composite textures may be used in any terrain, not just terrain that was composite in the default artwork.
  • BUMPY and WET commands added to the terrain type file format to allow for customized terrain surfaces.

X-Plane 8.04 – 8.06 (2/2/05)

This is an additonal bug-fix release that also integrates a number of systems changes.

  • Load order preference has changed: in 8.04 ENV files in the custom scenery folder are preferred to DSFs in the default scenery folder.

X-Plane 8.10-8.11 (3/19/05)

This feature release mostly focuses on systems features but also has a few scenery features to support global scenery.

  • The sim/require_object property is recognized to force objects in a DSF to be shown at low rendering details.
  • Terrain files can control clamping vs. wrapping and other properties.

X-Plane 8.15 (6/19/05)

This feature release also focuses on systems, but does have a few fixes to ENV handling.

  • ENVs draw taxiway lines.
  • Bug Fix: ENV water-land physics properties now match V7.
  • Bug Fix: Tall objects with hard surfaces now track correctly.
  • Bug Fix: No more occasional “NaN” errors with ENVs.

X-Plane 8.20 (11/15/05)

This feature release provides a bunch of new scenery features and the new OBJ8-based object engine.

  • New .ter file commands for more control of projection, wrapping and composite borders.
  • New .net command to keep the number of texture repetitions even – useful for bridges.
  • New .net command for more carefully controlling polygon offset – also useful for bridges.
  • New .bch file format for beach textures around waterboddies.
  • New OBJ8 file format with animation, per vertex normals, blending control.
  • Bug fixes to the OBJ8 engine: poylgon offset and materials now work correctly.
  • Scenery Engine Improvements: async texture loading, faster ENV processing, compressed textures, better rendering of road network intersections.

X-Plane 8.30 (1/15/06)

This is mainly a performance-tuning relase, but with a few new scenery features–overlays are the important one.

  • Sim support for Overlay DSFs.
  • Datarefs allow a plugin to tell which object is being drawn.
  • Asynchronous 3-d clutter instantiation.
  • Bug fixes for culling and speed improvements.

X-Plane 8.40 (4/13/06)

The main purpose of this release was to get X-Plane working on the Intel Macintoshes.

  • Library system regionalization added.
  • Object-location datarefs allow for animating multiple instances of one object.

X-Plane 8.50 (7/18/06)

This release features the new apt.dat system as well as other OBJ extensions.

  • New apt.dat 850 file format support.
  • New DSF polygon types for draped polygons, painted lines and strings of lights.
  • OBJ8 supports control over blending, hard surfaces and draw order.
  • New show/hide OBJ8 animation commands.
  • OBJ8 supports a new light system.
  • .net road files support cars and hard pavement.
  • Facades support hard surfaces and blending control.
  • Default ships and other default scenery re-implemented as library objects.
  • Library regions may be defined with PNG files.

X-Plane 8.60 (11/28/06)

A few new features for custom scenery packages, and some bug fixes.

  • .pol overlay polygons can have texture coordinates, for overlay orthophotos.
  • .pol files can have clamped textures using new commands.
  • .For files can prevent trees from being placed over water.
  • New EXPORT_BACKUP library command lets DSFs use objects from other packages optionally.
  • Better memory management for overlays in long flights.
  • Bug fix: Facade walls are now randomized.

X-Plane 8.64 (11/1/07)

  • Various low-level bug fixes for the scenery system.
  • Better alignment of OBJs.

X-Plane 9.00 (11/24/07)

New major version, which supports all v8 scenery features plus new ones. The rendering engine no longer pauses on scenery load, uses shaders more heavily, and has increased forest capacity.

  • OBJ file format supports key frames.
  • New OBJ command to use part of the panel texture for VRAM savings.
  • Road .net files extended to support trains.
  • Road networks are legal in DSF overlays.
  • New .ter commands to hide terrain repetition using pixel shaders.
  • Improvements to .pol placement in overlays
  • Improved forest exclusion zones
  • It is possible to fly under hard surfaces.

X-Plane 9.20 (10/4/08)

Feature Release with internationalization support, new aircraft and systems code.

  • OBJ supports manipulators.
  • Texture Paging Implemented for .ter and .pol files.
  • Texture engine heavily threaded.

X-Plane 9.30 (Beta 1 2/4/09)

New OBJ features.

  • OBJ supports variable LIT texture, no draw, solid walls.
  • OBJ hard surfaces can be animated.
  • Draped orthophotos with bezier curves now work.
  • DSFs can contain multiple LOD patches.

X-Plane 9.40 (12/4/09)

New OBJ features, better multi-thread support

  • Most 3-d Scenery Processes run on up to 8 or more cores
  • Normal/Specular maps
  • Parameterized Lights

X-Plane 9.50 (4/15/09)

Performance improvements for large orthophoto sceneries.

  • Parameterized light list extended to cover all aspects of airplanes.
Comments Off on Scenery System Version History

Scenery System for MSFS Developers

Differences of Approach

Perhaps the most important structural difference between the X-Plane and MSFS scenery systems is that MSFS integrates and processes scenery data while the sim runs, while X-Plane scenery is pre-processed. Some examples:

  • With MSFS, you can specify a water polygon as part of scenery – this data will be merged with land-class data when scenery is loaded. In X-Plane, you specify a water polygon when you build a mesh file; that data has already been merged by the time your .dsf file is ready for distribution.
  • With MSFS, land-class, orthophoto, and DEM data are combined when the sim runs to create the final mesh. With X-Plane, this data is combined when you create your finished DSF scenery file.
  • With MSFS, objects are placed on terrain while you fly (auto-gen); with X-Plane, objects are placed on terrain when the DSF file is built (pre-gen).

The X-Plane approach has strengths and weaknesses and a few big implications for scenery developers:

  • Overall, scenery add-ons must be more monolithic for X-Plane than for MSFS – see integrated mesh vs. layers below. There may be categories of MSFS scenery that cannot be created as ship-alone products on X-Plane. For example, you cannot create scenery that only improves land class data without also providing a mesh in X-Plane.
  • In some cases, processing time for scenery data is a non-issue for X-Plane. For example, you can input very complex coastlines to X-Plane’s scenery tool; that expensive polygon processing is done during scenery creation and a finished mesh is created.

See Anatomy of the X-Plane Scenery System for the various types of add-ons that can be created.

Comparison of Architecture

Irregular Mesh vs. Dynamic Mesh

Irregular_mesh1
Irregular_mesh2

X-Plane’s terrain meshes are pre-defined in a DSF file – they are not created by X-Plane from raster elevation data. For this reason, any water-tight mesh can be used in X-Plane. We say that X-Plane uses an irregular mesh because the Laminar-provided mesh-creation tools create irregular meshes and the default scenery that ships with X-Plane uses irregular meshes, but it might be more correct to say that we use a mesh of any form.

X-Plane uses an irregular mesh because it can provide superior accuracy for a given vertex count, relative to a regular grid. With an irregular mesh:

  • Mesh triangles edges can be placed along any polygonal border. This means that polygonal water bodies and orthophotos efficiently shape the mesh.
  • Mesh triangles can fit the contours of terrain.
  • We can reduce mesh triangles where they aren’t adding value (e.g. flat locations).

X-Plane has support for detail-removing LOD in version 8 and later (that is, you can provide alternate meshes in a scenery single DSF file and X-Plane will pick between them based on view distance). The scenery tools, as of this writing, have relatively limited support for mesh LOD.

Texture Use

Mesh textures in X-Plane are used directly as part of the mesh – the mesh is more like a big model in that regard. (Compare to MSFS, where the final terrain texture for an area may be built up and pre-mixed from multiple layers.) This means that the performance of a mesh scenery may be improved by careful texture planning. A small number of large textures will outperform a large number of small textures, by reducing batch count to the graphics card.

X-Plane can “page” textures, that is, load lower and higher resolution versions as the user flies. This feature is only available for .pol and .ter textures, that is, base mesh imagery and overlay imagery – it is not available for 3-d models. Paging is done on multiple cores, so flight can be very smooth even with a lot of imagery on a multi-core machine.

For best texture performance, use .dds files – this saves time calculating mipmaps, provides higher compression quality (pre-compressing using a slow offline algorithm reduces artifacts) and improves paging speed.

Integrated Mesh Tiles Vs. Layers

An X-Plane base mesh covers a 1×1 degree “square” of the world (they’re actually not square when viewed in 3-d). The entire mesh for this degree must come from one file, and that mesh must be “integrated” – that is, it contains all land-use, orthophoto, and elevation data, as well as polygonal features like water.

For this reason, you cannot combine an orthophoto add-on and a mesh add-on for the same area in X-Plane; for base meshes you must combine any land-use/orthophoto customizations with mesh improvements.

It is possible to make “overlay” scenery, and overlays can “drape” orthophotos over the mesh. However, the performance of “draped” orthophotos is significantly lower than base mesh orthophotos; for a large area a base mesh is a must for good framerate. Draped orthophotos are targeted at localized modeling, e.g. to customize the surface area of an airport.

Pre-Generation Vs. Auto-Generation

X-Plane does not have auto-gen as it exists in MSFS. With X-Plane scenery, all model, road and vegetation placements (sometimes collectively called ‘clutter’) have their locations specifically defined in a scenery file. Scenery files might have hundreds of thousands of model placements.

Clutter in X-Plane is defined by an abstract placement and an art asset. That is, while you must specifically provide lat/lon coordinates for all houses in your scenery files, you can refer to a single separate model for the house – you do not have to copy the house’s geometry into the scenery file.

It is possible to replace, augment, or customize the actual models used in this process. All art assets go through a library system, which lets third parties utilize X-Plane built-in art assets by reference, or let third parties augment X-Plane’s built-in art assets.

Land-Class vs. Terrain

X-Plane’s scenery system does not distinguish between land-class and orthophotos as a way of covering the mesh. Instead, any given part of the mesh is covered with a “terrain” (defined by a .ter file); the terrain definition will specify the texture res for repeating textures, physical properties, etc.

X-Plane can support both land-class and orthophoto-style texturing. For land-class textures, the terrain file specifies a texture size and orientation and that they should wrap around to form repeating tiles. For orthophoto-style texures, you can specify the coordinate placement of the texture on the terrain in your scenery file.

See Also

Anatomy of the X-Plane Scenery System provides a road map to the various components of the X-Plane scenery system; this can help you locate the useful parts of the scenery system.

Leave a comment

Performance Tuning and Scenery

Textures

Textures play a huge role in determining X-Plane frame rate. The harsh decision to use only one or two textures per airplane and only one texture per object was based on the enormous performance benefits to restricting objects and planes to one texture each.

(Think of each texture X-Plane uses as a crayon you use to color your scenery. But the box of crayons is in the other room, so each time you have to change crayons, it takes a long time. The one-texture-per object rule guarantees that X-Plane won’t be “changing crayons” all the time.)

Pack Textures

Video card memory is at a premium in X-Plane; this is obvious, but don’t waste space in your textures. If you can resize your image to be smaller in Photoshop without losing (much) quality, consider making the texture smaller. If you look at some of the textures Sergio Santagada has done for X-Plane, you will see that every pixel is utilized, and every image is reduced until each detail is one pixel. This helps maximize video card memory.

Use Fewer Large Textures

Use fewer large textures rather than lots of small ones. For example, use one large texture for many objects, allocating the texture space as needed. This both improves frame rate and gives you the flexibility to use non-power-of-2 rectangles within the one larger texture.

Use Textures for Nearby Objects

If you have so many textures that you will need multiple large bitmap files, combine objects that are nearby in your scenery onto one texture. This way if only some of your objects are visible, they will be more likely to all come from the same texture.

Use Alpha Only When Needed

If your texture does not have any transparent parts, make sure to save it without an alpha channel as a PNG file. X-Plane will enable alpha processing if the alpha channel is  detected, even if the entire texture is opaque.

Make sure pixels that are supposed to be transparent are 100% transparent. It is faster on older video cards to render pixels that are totally transparent than to render pixels that are, say, 90% transparent. Also, translucent pixels may cause Z-buffer problems.

Terrain

The rule to use fewer larger textures applies doubly to terrain. In the old scenery system, it was best to use a 1024×1024 bitmap and apply the texture over multiple quads. Similar optimizations will help newer versions of X-Plane.

Objects

The overall rules for textures apply to objects as well, especially regarding sharing of textures. Here are some additional things that will help object performance.

Optimal Size for Objects

Probably the biggest factor in object performance is the number of objects vs. the number of polygons in the objects. Here you face a trade-off. There is a certain overhead for drawing an object at all, so making 1000 objects, each with one quad, will be a lot slower than making 1 object with 1000 quads. On the other hand, X-Plane chooses to draw or not draw an object based on whether any of the object is visible. So if your object is very very large, the whole object will be drawn even if only a tiny portion of it is on screen.

Please remember, these are only guidelines – use these guidelines when you have
flexibility as to how you build your objects, but do not bend over backward to hit these numbers. They are meant only to give you a sense of X-Plane’s ideal performance range.

The ideal object dimensions are no larger than 1000 meters on a side – 500 meters on a side is good. Larger than 1000 meters and you will be drawing the object even when it is almost entirely not on screen. 500 meters is the granularity of X-Plane’s rough culling pass.

Ideally an object should have as many polygons as possible – there is no upper limit to the number of polygons; better to have all of your polygons in one object than split between multiple objects. But it can be a problem to have an object with too few polygons. Objects with less than 24 vertices are not efficient in X-Plane. Do not add polygons just to get above this minimum, but if you have objects with a very small number of polygons, consider merging a few objects together.

  • If an object models one entity, do not break it up for the sake of frame rate; it is very difficult to place multiple objects near each other and get precise alignment. For example, if you have a suspension bridge, use one object rather than three. (If you use three objects, getting the sections to line up will be impossible.
  • If you have a number of objects near each other that always use the same texture and are not repeated, consider merging them into one bigger object, to get closer to the optimal size. For example, a series of trees or taxiway lines in an airport could be merged into larger chunks to hit optimal object size.
  • By the same logic as above, consider breaking up collections of objects if they are too big (e.g. too large on screen.)
  • If you are going to employ level of detail (explained in detail below), make sure you use separate objects, as level of detail decisions are done per object.

One other warning: If an object is heavily repeated, you may not want to merge it because this effectively means more memory usage. X-Plane’s object memory usage is primarily a function of the number of commands in the total set of OBJ files you use. The individual placements of an object are very cheap, but the OBJs themselves can be expensive. If you have 1000 house OBJs, each different, each used once, this is a lot more memory than 1000 placements of a single house object. So you may not want to make a single object with 100 houses if you were using one house object over and over…you will effectively be increasing memory usage.

For New Objects

Definitely take a look at the OBJ Overview document; it contains a ton of OBJ8 specific advice. One note in particular: if you view the bottom of your OBJ8 file (skip all of the IDX entries) to the commands section, the number of TRI commands is a good indication of how well optimized your object is. If you have a ton of commands after the IDX section, your object is probably not optimized.

Object Command Ordering

X-Plane does some minimal reordering of the commands in your object, but for the most part the commands in your object are executed in order. You will get best performance if:

  • all of the commands of the same type are together when possible. (E.g. all of the TRI commands are back to back.
  • all of the polygon commands (triangles, quads, etc.) are together. Keep the lines together. Keep the light commands together.

This may be impractical for authors and is mentioned primarily for programmers who develop software that creates OBJ files.

Note: the motivation for not optimizing polygons in OBJ files is partially to keep load times down (by having this done at scenery creation time) and partially to give authors total control over render order within an object. This allows an author to create an object with translucency without Z-buffer problems.

Level of Detail

Level of detail control is one of your most powerful tools to optimize object performance. The level of detail OBJ command lets you specify more than one version of your object for different distances, and also puts a hard limit on how far away your object will be drawn. LOD improves frame rate by reducing the amount of work X-Plane has to do in rendering objects.

If your object does not contain LOD commands, X-Plane will pick a maximum distance for your object based on its dimensions. X-Plane’s guess is just a guess and will either be too low (causing your object to disappear) or too high (causing your object to be drawn needlessly), so consider putting LOD commands on all objects, even if they only have one version.

Multiple representations of your object take time to create, so do an estimate of which objects are worth creating multiple versions of. Some examples:

  • A skyscraper that is placed in the scenery once that contains 50 polygons. 50 polygons x 1 object is not a lot of polygons – creating a second version of the skyscraper is probably not worth it.
  • The statue of liberty, as the centerpiece of a scenery package, modeled with 30,000 polygons. In this case, the one object does cost a lot, and may be visible from a long way away due to its large size. This is a case where a second LOD (with, say, 1000 or less polygons) could be worth it.
  • A house used everywhere with 10 polygons. This is a dubious case – even though the house is used a lot, at best you will only save a few polygons, and the reduced LOD object will be below X-Plane’s efficient sizes. Experimentation will show whether this is a win, but it wouldn’t be the first object to optimize.
  • A jetway, used 100 times on an airport, with 350 polygons. This is a huge win. This one object causes 35,000 polygons to be drawn, and all 100 objects are probably visible on final approach. Creating a reduced LOD version to be used 500 meters away with only 50 polygons will cut almost 30,000 polygons off of X-Plane’s load without much noticeable degradation.

Even with single representations, good LOD choices are important for frame rate. Taxiway signs, for example, should have low LOD levels because many of them are visible when overflying an airport, but they are very small and disappear from view rapidly.

Avoid hard quads

The hard quad command is more expensive than the regular quad command. Avoid using it unless the polygon absolutely has to be hard.

Facades

Unlike objects, each individual placement of a facade takes up additional memory. In other words, using 2 facade definitions once each takes only a tiny bit more memory than using one facade definition twice. Polygon memory for objects is saved once for the .OBJ file. Polygon memory for facades has to be created once for each instance of the facade because each facade is slightly different in shape. X-Plane has no mechanism for recognizing and pooling same-sized facades.

Avoid excess stretching

The biggest danger to performance from facades is to extrude a facade into a footprint that is much larger than the facade’s ideal size, or to add more floors than the facade’s ideal height.

When X-Plane “extrudes” a facade to make a building in your scenery, it looks at your panel and floor split points and takes as many or as few panels and floors as is needed to meet the height and wall length requirements specified by the DSF file. X-Plane combines adjacent panels, and only adds more polygons to cut out parts of the texture or to duplicate parts of the facade.

Image:perftune_facade.gif

In the above picture, a facade is shown in its original form with cutlines and then in three instantiations. The quads X-Plane creates are shown by separating the facade into its component quads. In the first case, the facade is smaller than its ideal size, so four quads are produced. In the second case, the facade is the exact size of the texture, so only one quad is produced. In the third case, the quad has been stretched. Two quad are needed vertically, but many facades are needed horizontally because the facade is so much wider than the texture. This facade is horizontally overextended.

Avoid overextending facades either horizontally or vertically; at most a facade
instantiation should be no larger than twice its ideal size either horizontally or vertically. Make sure your facade definitions match the way they are used in the DSF. For example, if you have a facade that is used 100 times and is overextended to form 10 polygons horizontally and 10 polygons vertically, you will have 40000 polygons where you should have had 1600 polygons.

Leave a comment

Panels For MSFS Developers

Terminology

X-Plane has two viewing modes for panels: a forward 2-d view that shows the 2-d panel and a 3-d view that shows the 3-d cockpit (which corresponds to the virtual cockpit in MSFS). Unlike MSFS, X-Plane does not provide multiple 2-d panel views – the 2-d side views may not contain working 2-d panels. X-Plane does not provide native support for popup panels, but it is possible to create them using a plugin or other tricks.

X-Plane’s panel consists of a background image (where alpha creates the transparent windshield) and a gray-scale or RGB overlay image that applies shadowing and some 2-d spot lighting to the panel. While MSFS has “gauges” X-Plane has “instruments” – the individual unit of placement.

Instrument Differences

The MSFS panel is created using an XML file; gauges can also be coded in C++ and can be in the form of *.dll or MSFS specific *.gau format.

X-Plane panels reside inside the ACF file in binary format (but can be exported as text from Plane-Maker); most panel editing is done using Plane-Maker’s near-WYSIWYG user interface.

X-Plane provides hundreds of types of instruments built in:

  • Pre-made instruments model existing real world instruments; X-Plane ships with a complete set of real world instruments for VFR and IFR flight. Limited customization is possible by replacing bitmaps, and tuning a few parameters.
  • Generic instruments provide basic “mechanism”, e.g. a needle that rotates, a button that toggles, etc. The generic instruments have a large number of customized parameters and visualize data from a “dataref” – that is, a sim variable from X-Plane itself or a plugin.

Therefore the closest thing to building gauges using the XML file is to build a panel out of multiple generic instruments. Typically a modern panel might be built primarily from generic instruments, but use the pre-built instruments for the moving map and a few other cases.

Custom Gauge DLL Vs. Plugin

While MSFS allows a custom gauge to be built via a DLL (where the gauge provides a bitmap of its 2-d image), X-Plane has a slightly more generic mechanism:

  • An airplane can contain one or more plugins.
  • Each plugin has full access to the X-Plane plugin SDK API – this includes building menus, custom UI and windows, creating and modifying sim variables, and drawing using OpenGL.
  • Often the generic instruments can be customized by feeding a dataref from your plugin into the generic instrument – that is, the generic instrument rotates the needle (and X-Plane does the drawing) but the animation is keyed to output from your plugin.
  • A plugin can also draw directly onto the panel – this happens on a panel-wide basis, not on a per-instrument basis. (This is how a complex custom nav display might be built.)

X-Plane does not provide a general mechanism to let an author “place” a custom plugin-drawn instrument into a panel using Plane-Maker; typically custom instrumentation is specific to a single plane. Where users have tried to build add-on instruments via plugins, they have had to create ad-hoc mechanisms to place those instruments.

The Virtual/3-d Cockpit

X-Plane’s 3-d cockpit environment is actually a rendering of the entire airplane in 3-d; all of the 3-d modeling work you do for airplane will be visible in the 3-d cockpit, allowing for the user to exit the VC and do a walk-around of the airplane. (See “Camera Restriction” below.)

Therefore the virtual cockpit is is simply modeled in 3-d using OBJ files, which contain meshes. Standard animation is used for instruments like steam-gauge airspeed indicators; this is similar to MSFS where a 3-d animation can be driven off of an animation source. Like MSFS, using “real animated 3-d” is often the fastest path for mechanical instruments.

X-Plane does have one “special” object (the “cockpit object”) that is intended particularly for VC work; it allows a 2-d panel to be UV mapped onto some 3-d surfaces, similar to using a material to indicate a 2-d panel mapping in MSFS. This work-flow is largely the same – you would create a snapshot of the “unwrapped” set of 2-d gauges (Plane-Maker can make this snapshot) and then UV map using it. The precise way to indicate “panel texture” depends on the 3-d editor you use.

Like MSFS, X-Plane provides a separate 2-d panel for the purpose of providing a material/texture for the 3-d virtual cockpit; therefore you can tightly pack this texture even if you want to ship a 2-d panel as well. In X-Plane, 2-d panels scroll and are often 2048 x 2048; it is important for performance to tightly pack the panel that is used in the 3-d cockpit.

Mouse-click interaction in the 3-d cockpit in X-Plane is annotated directly on the 3-d mesh; you mark a sub-section of the mesh with a “manipulator” describing what you want to have happen and the gesture. Typical manipulations include drags in 2-d or in arbitrary 3-d space, clicks, etc. Manipulations typically change an X-Plane dataref or run an X-Plane command (similar to an MSFS sim event) to affect the flight model.

Besides direct 3-d manipulation, you can mark any part of the 3-d mesh that has a panel texture mapped to it as “panel clickable” – this causes 3-d clicks to be passed through to the underlying 2-d panel, where the click operates as expected.

Things X-Plane Doesn’t Have Yet

Arbitrary Transforms

X-Plane can show and hide instruments but it cannot arbitrarily rotate or move them; there may be some XML transformations that are not yet possible in X-Plane. In many cases, a pre-built instrument will exist, and you can simply retexture it.

Things MSFS Doesn’t Have

Gradual Lighting Control

For any 3-d model in X-Plane, you can tie the level of the emissive (_LIT) texture using ATTR_lit_level, which arbitrarily scales the texture using a dataref. This has application for more realistic baked lighting, but can also be used to create gradual light faders in the 3-d cockpit or even to create instruments. (For example, the gear light LEDs can be made to appear by tying their lighting level to the gear status.)

Camera Restriction

You can restrict the movement of the camera in the 3-d cockpit by tagging a mesh as solid to the camera; this will stop your user from walking through the walls of the VC.

Use a hidden, simplified, manifold mesh to restrict the camera; the camera restriction will react better and use less CPU power with the simplified mesh.

You can use animations in your camera-restricting mesh. For example, if you animate the doors of your fuselage in the camera-restricting mesh, a user can exit the airplane only when the door is open.

See the default Cessna 172 in X-Plane for an example of this.

Leave a comment

Normal Maps

Definitions

A normal map is a texture that defines which way light bounces off a surface, on a per-pixel basis. Normal maps encode the direction of light reflections using RGB colors.

A bump map is a texture that defines the height of bumps on a surface, on a per-pixel basis. Bump maps encode the height as a gray-scale image.

X-Plane does not use bump maps; it only uses normal maps. See the Creating Normal Maps section below for information on creating normal maps from bump maps.

A Specular Level Map (or shininess map) is a texture that defines which parts of a surface are shiny, on a per-pixel basis. (Specular maps are similar to ATTR_shiny_rat in their effect.) . Specular levels are a non-PBR X-Plane 10 concept.

A Gloss Map defines which parts of a texture are smooth, and replace specular level maps in X-Plane 11.

A “UV” map is the mapping of texture coordinates onto your model–that is, it is the shape of how your textures are applied to the mesh. X-Plane supports only one UV map per OBJ – that UV map is used for all textures: the day time (albedo), night LIT (emissive) and normal map textures.

Format

X-Plane 10 uses combined normal and specular level maps in a single texture. The RGB of the texture are used for the normal map, and the alpha channel is used for the specular level.

X-Plane’s normal maps are “tangent space” normal maps. That means that a “flat” (blue) normal map leaves the original surface unperturbed.

Creating Normal Maps

NormalMappr

NormalMappr is a free program for OS X that converts bump-maps to tangent-space normal maps. You open a PNG file, adjust a few parameters, and then save the results. You can apply it to a custom-drawn bump map (drawn in gray-scale using PhotoShop) or simply apply it to your RGB textures.

//shamyl.zakariya.net/apps/NormalMappr.zip

Converting Normal Maps From FS X Aircraft

FSX and X-Plane do not use the same normal map format. There are three key differences:

  • In FS X, the red, green and blue channels have been moved around a bit to reduce texture compression artifacts.
  • In X-Plane, normal maps should be uncompressed, in PNG files, not compressed in DDS files.
  • In X-Plane, the alpha channel can optionally be used as a specular map.

This tutorial explains how FSX normal maps are created. To use the normal map in X-Plane, you need the original light blue normal map from before the changes (“saving in FSX format” are made).

Generally since X-Plane normal maps are uncompressed, you will get higher image quality by going back to the original materials, rather than trying to re-convert the DXT-compressed normal map.

Using Normal Maps

Normal maps may be used in objects. To use a normal map in an object you must include a line

TEXTURE_NORMAL <filename>

Normal maps must be PNGs (not DDS). The normal map does not have to be the same size as the day or lit textures, but it does have to be a power of 2. It should be a 24-bit RGB + 8-bit alpha texture.

In order for the specular level map to work, you must use ATTR_shiny_rat. X-Plane multiplies the shiny_rat and specular level from the normal map, so it is best to use ATTR_shiny_rat 1.0 when using normal maps.

Normal maps can be used in the draped texture of an object or in other art assets as follows:

TEXTURE_NORMAL <ratio> <filename>

Where ratio scales the normal map relative to the UV map of the parent art asset. The intent of this is to allow for high frequency repeating normal maps that add texture at a rate different from a low frequency albedo.

Warnings and Problems

A few special precautions when making normal maps:

Normals Must Be The Correct Length

In a normal map, the RGB colors represent a “vector” – that is, a direction that light bounces off a surface. The vector must be of length 1. In practical terms, this means that the colors must balance in a certain ratio.

If the colors in the RGB channel do not balance to create a “normalized” vector, X-Plane’s lighting will not function correctly. Therefore it is important that you not modify the RGB channel with a paint program; instead use a program designed to create normal maps.

RGB Behind 0% Alpha

When using a normal map, you may have areas with 0% shininess. This is represented by 0% alpha. Some graphic programs (including some versions of GIMP and PhotoShop) will replace the RGB color behind a 0% alpha (transparent) area with white.

From the above comment, the normal vector must be normalized – since white is not a legal normal map value, these white areas will have strange lighting errors.

Be sure to use a program that can apply an alpha channel without destroying the RGB colors, like Graphics Converter.

Normal Maps Must Not Be Flipped

Normal maps have a “front” and a “back”. The front must face the viewer. If your UV map flips the normal map horizontally or vertically (flipping both is fine, since this is like a 180 degree rotation) then the normal map will not work correctly.

Basically, if you could put writing into your main texture and the writing would not look mirrored, then your UV map (the way your texture is applied to your object) is fine for normal mapping. If the text looks mirrored, the normal map will be reversed.

(Note: it can be very hard to detect incorrect lighting with a mirrored normal map; I suggest using a temporary texture with writing to confirm that your UV map is okay.)

Compatibility

  • Normal mapping is available in X-Plane 940 and later.
  • Normal mapping requires a graphics card with programmable pixel shaders – that is, a DX9 or later compatible card.
  • Normal mapping is only visible if the user enables per-pixel lighting.
  • Normal maps may be ignored at the lowest graphics settings for performance.

Technical

X-Plane uses tangent space normal maps with a specular level in the alpha channel:

r = dx, -1,1 mapped 0.255
g = dy, -1,1 mapped 0.255
b = dz,  0,1 mapped 0.255
applied where dz = N, dx = dS, dy = dT

Further Reference

//wiki.blender.org/index.php/Doc:Manual/Textures/Maps/Bump_and_Normal_Maps

Comments Off on Normal Maps

Non-Monotone Key Frames

What are Non-Monotone Key Frames

Non-Monotone key frames are key frames where the key frame table is not in order. Here are some examples:

N1     ANGLE
0		50
50		270
100	230

This key frame table makes the angle of the needle increase as N1 goes up, but then the needle will reverse and go back down a bit. In this case, “angle” is non-monotone.

In this table for a a rotary;

enum   image
0		0
1		2
2		1
4		3
3		4

Both the input and output are non-monotone.

When Would I Want Non-Monotone Key Frames?

Generally you’ll want non-monotone key frames under two cases:

  1. If an instrument has to move forward and backward in response to data (e.g. the N1 needle example above).
  2. If you need to remap the enumerated values for a rotary (e..g the rotary example).

When Are Non-Monotone Key Frames Allowed?

  1. The value (but not dataref) key frame column can be non-monotone as long as the instrument reads but does not write the dataref. So non-monotone output can be used for a needle as long as it is not draggable, for example.
  2. Rotaries may have non-monotone key frames for both input and output, as long as values are matched _exactly_ without interpolation.

Previewing Non-Monotone Key Frames in Plane-Maker

Plane-maker recognizes that if you have out-of-order non-monotone key framing tables then you are probably intending to use a dataref that EXACTLY hits the key frame, like an int dataref that passes in enums. (You would use this to re-order the mapping between enums and rotary positions.)

In this case Plane-Maker will snap-round the simulated dataref to exact key frames so that you can see a sane preview of the dataref.

If you have done this but the dataref in x-plane is NOT rounded to key frames, you will then see wrong interpolation in x-plane, since we can’t cleanly interpolate non-monotone functions!!

Comments Off on Non-Monotone Key Frames

Named Lights for Scenery

Named lights are lighting billboards that are designed and implemented by Laminar Research and built into X-Plane. You can add a named light to your aircraft or scenery by using the LIGHT_NAMED command in an object.

The behavior of named lights cannot be customized – each named light comes with preset behavior, such as blinking or changing colors.

Named lights are affected by animation – that is, a named light is hidden if inside an ATTR_hide command, and the directionality of a named light is affected by both the orientation of the object/aircraft and any rotation/translation animations that the named light is inside.

Lights.txt

You can locate the master list of named lights in the file Resources/bitmaps/world/lites/lights.txt. Do not edit this text file! This file will be updated by the X-Plane updater and should be considered part of the sim, not for third party modification. If you need a new named light, send feature requests to LR. The file can be useful for checking for the existence of a particular named light in an older version of X-Plane.

List of Named Lights

Lights for Boats and Ships

ship_nav_left ship_nav_right ship_mast_obs ship_mast_grn ship_nav_tail ship_mast_powered carrier_datum carrier_waveoff carrier_meatball1 carrier_meatball2 carrier_meatball3 carrier_meatball4 carrier_meatball5 carrier_mast_strobe carrier_deck_blue_s carrier_deck_blue_w carrier_deck_blue_n carrier_deck_blue_e carrier_pitch_lights carrier_foul_line_red carrier_foul_line_white carrier_center_white carrier_edge_white carrier_thresh_white frigate_SGSI_lo frigate_SGSI_on frigate_SGSI_hi frigate_deck_green oilrig_deck_blue

Lights for Towns

town_light_60 town_light_90 town_light_150 town_light_180 town_light_220 town_light_280 town_light_330 town_light_350 town_light_omni town_tiny_light_60 town_tiny_light_90 town_tiny_light_150 town_tiny_light_180 town_tiny_light_220 town_tiny_light_280 town_tiny_light_330 town_tiny_light_350 town_tiny_light_omni

Lights for Obstacles

obs_strobe_day obs_strobe_night obs_red_day obs_red_night hospital_helipad_blue

Comments Off on Named Lights for Scenery

Manipulators

A manipulation is an action the user can take by clicking on your object. (That is, the user “manipulates” your OBJ with the mouse.) Manipulations can only be used on cockpit objects!

Types of Manipulators

There are six types of manipulators supported in X-Plane 920 and later:

  • None
  • Panel Click
  • Drag-Axis
  • 2-d Drag
  • Command
  • Command-Axis
  • Opaque

No Manipulation

Triangles are ignored when clicking. This is the default, and is usually used for anything that is not clickable. This manipulation does not require any CPU resources, so when possible, you want to leave your meshes non-manipulatable. This is the only legal manipulation for non-cockpit objects.

The none manipulation is set using either

ATTR_no_cockpit
ATTR_manip_none

The none-type manipulation will show no tool tips, and uses the arrow (default) cursor.

Panel Click Manipulation

A click on the triangles is mapped through to the 2-d panel based on the panel texture’s mapping. This manipulation can only be specified for objects that are textured by the panel texture (or a panel texture region). Panel click manipulation is set using one of

ATTR_cockpit
ATTR_cockpit_region <region number>

Panel click manipulations show the tooltips and cursors of the 2-d panel.

Drag-Axis Manipulation

As the user drags along an axis in 3-d object-space, a dataref value is increased or decreased. The length of the axis defines how much mouse travel (in meters of object space) is required to completely change the dataref across a range defined by a pair of parameters. The drag-axis manipulator takes the form:

ATTR_manip_drag_axis <cursor> <x> <y> <z> <value1> < value2> <dataref> <tooltip>

Here, x, y and z define the length and direction of the drag axis, and value1 and value2 define the range of values over which the manipulator runs. If the mouse is dragged beyond either of these limits, the manipulator is clamped: the value of the dataref will remain the same until the mouse is again dragged or clicked within range. The current value is retained after the mouse is released, and determines the position of the manipulator’s drag-axis relative to the next mouse click. For example, if a manipulator is currently set to a value midway between it’s minimum and maximum values, then the mouse will automatically find itself halfway along that manipulator’s drag-axis when next it clicks on it.

Drag-axis manipulation is subject to object animation. The orientation of the manipulator’s drag-axis relative to the animated mesh to which it is attached is the same each time the mouse is clicked on it. For example, if a drag-axis manipulator on an animated throttle lever has an axis perpendicular to the lever shaft when clicked in the ‘idle’ position, that axis will still be perpendicular to the lever shaft when clicked in the ‘open’ position. However, for the duration of any given drag, the orientation of the drag-axis relative to the aircraft remains constant. So if the drag-axis of the previously-described manipulator happens to be perfectly horizontal at the moment the mouse is clicked on it, it will remain perfectly horizontal and ‘locked-in’ until the mouse is released, even though the visible throttle lever has been animated to a new position. This behaviour is more intuitive in practice than it may appear on paper!

2-d Drag Manipulation

The 2-d drag manipulator effectively combines two manipulators into one, allowing two datarefs to be modified simultaneously by dragging the mouse along a pair of perpendicular axes. To minimise input ambiguity, the axes are defined in 2-d screen space, not object space, and their respective orientations are fixed. The first dataref is modified by dragging the mouse horizontally across the screen and the second by dragging vertically. This type of manipulator would typically be used to control a yoke or joystick and takes the form:

 ATTR_manip_drag_xy <cursor> <x> <y> <ref1 value1> <ref1 value2> <ref2 value1> <ref2 value2> <dataref1> <dataref2> <tooltip>.

Here, x defines the distance the mouse must be dragged across the screen from left to right in order to modify the output of dataref1 from ref1 value1 to ref1 value2. Similarly, y defines the distance the mouse must be dragged up the screen in order to vary the output of dataref2 from ref2 value1 to ref2 value2.

In contrast to the drag-axis manipulator, the axis orientations of the 2-d drag manipulator are not subject to object animation. The x-axis is always horizontal and the y-axis is always vertical. However, the location of the manipulator’s click-region does follow any animation of it’s mesh.

The following example shows a 2-d drag manipulator configured to control a steering yoke. The x-axis controls roll (an 80-pixel drag), and the y-axis controls pitch (a 50-pixel drag). Note: since it is more intuitive to drag down rather than up the screen in order to increase pitch, the vertical axis has been assigned a negative value):

 ATTR_manip_drag_xy  four_arrows  80  -50  -1  1  -1 1  sim/cockpit2/controls/yoke_roll_ratio  sim/cockpit2/controls/yoke_pitch_ratio  I am a tooltip.

It is not obligatory for a 2-d drag manipulator to address two datarefs. A single dataref may be manipulated in 2-d screen-space by entering a value of 0 for each of the redundant numeric parameters and null for the dataref name of the unassigned axis.

Command Manipulation

A command manipulation invokes an X-Plane command when the mouse is clicked on it. The command continues to be invoked until the mouse is released. It takes the form:

 ATTR_manip_command <cursor> <command> <tooltip>

Command-Axis Manipulation

Dragging along a specified object-space axis actuates one of a pair of commands, subject to the direction of the drag. The command continues to be invoked (CommandContinue phase) until such time as the mouse is either released or else dragged back along the axis to the neutral position. Dragging right through the neutral position to the opposite end of the axis invokes the second command. The neutral position is centred on the location of the original mouse click and occupies 40% of the overall length of the axis Typical applications would be nudge-wheels and three-position toggle switches. The command-axis manipulator takes the form:

 ATTR_manip_command_axis <cursor> <x> <y> <z> <command1> <command2> <tooltip>

The x, y, and z parameters define the orientation and length in meters of the drag-axis. Dragging in the positive direction triggers command 1 and in the negative direction, command 2. The following example shows a command_axis manipulator configured as a pitch trim nudge-wheel/switch:

 ATTR_manip_command_axis up_down  0.00  0.00  -0.01 sim/flight_controls/pitch_trim_down  sim/flight_controls/pitch_trim_up I am also a tooltip.

The axis values in the above example would be appropriate for a standard-sized toggle switch mounted on a horizontal console panel. Dragging the mouse approximately 2mm towards the nose of the aircraft triggers pitch_trim_down, and dragging it 2mm towards the tail triggers pitch_trim_up (since the X-Plane acf z-axis runs positive nose to tail).

Opaque Manipulation

This sets the manipulation to ‘no-op’ (no operation). Unlike “none” manipulation, opaque manipulation “swallows” the mouse, preventing it from clicking on other manipulators that may lie behind it. It would typically be used to act as a safety-guard over a switch.

Dataref “Button” Manipulators

These manipulators change a dataref when the mouse is clicked or held, creating button-like functionality. There are five sub-flavors. The push-button, radio button, and toggle manipulators are meant to provide button-like behavior for a mesh. The delta and wrap manipulators are meant to be used to create invisible “hot spots” over a mesh.

Push-Button Manipulator

The push-button manipulator sets a dataref to a “down” value when the mouse is clicked, then back to an “up” value when the mouse button is released.

Radio Button Manipulator

The radio button manpiulator sets a dataref to a value each time it is clicked.

(It is considered to be a “radio button” because a set of these manipulators, sharing one dataref but using differing values, can create radio-button-like behavior.)

Toggle Manipulator

The toggle manipulator switches a dataref between one of two values each time it is clicked.

Delta Manipulator

The dataref is increased (or decreased) when the button is clicked (and/or held down). If the dataref exceeds its limit range, it is clamped to that limit.

Wrapping Manipulator

The dataref is increased (or decreased) when the button is clicked (and/or held down). If the dataref exceeds its limit range, it wraps around to the other end of the range.

Manipulator Properties

These properties apply to some or all of the manipulators except for:

  • None and opaque manipulators (which have no real action).
  • Panel manipulator (which gets its properties from the panel).

Cursor

All manipulators let you specify the cursor that appears when the mouse is over the manipulator. (The panel manipulator takes its cursor from the underlying panel.) The OBJ8 specification lists all possible cursor choices.

3-D Axis

The axis and command-axis manipulators allow a drag in 3-d; they require the specification of an axis.

  • The axis is a 3-d axis, so it is specified as a length in X, Y, and Z (in meters).
  • This axis is affected by animation; if the manipulator is inside a rotation, the axis will rotate.
  • The axis manipulators imply an “increasing” and “decreasing” direction; the values specify the increasing direction.

EXAMPLE: for an axis of X = 1, Y = 1, Z = 0, as you drag to the upper right (in object coordinates) the dataref will increase.

The axis’s position in the 3-d cockpit is set based on the current value of the dataref when the user clicks. For example, if the dataref for the axis manipulator is the throttles and the throttles are at maximum value, the entire axis will be in the direction to decrease the throttles. If the throttles are at 50%, the mid-point of the axis will be at the click point. In other words, axis positioning is relative based on the dataref.

(For the command-axis, the axis center is always the anchor point.)

2-D Axis

The 2-d drag axis is a special case: it allows a drag in “screen space” – that is, the axes is always up-down and left-right no matter what the pilot head position. Thus the axes are lengths in pixels. A positive “x” means that a drag to the right increases the first dataref. A positive “y’ means a drag up increases the first dataref.

Datarefs and Values

For the axis and axis-2 manipulators, one or two datarefs is required, as well as low and high values. The low and high values “scale” the axis. For example, for a throttle, a low and high value of 0.0 and 1.0 would tell the manipulator what throttle values correspond with the end of the axis.

(In other words, the axis specifies the size in the 3-d cockpit of the drag, and the dataref values specify the size in terms of the actual dataref movement.)

Commands

A command can be specified for either the command manipulator (the command is invoked while the mouse button is held down) or the command-axis dataref (the command is invoked while the drag is to the left or right of the axis).

Tooltips

All manipulators let you specify a tooltip. When the mouse lingers over the manipulator region and the user enables “instrument explanations”, this tooltip will be shown. It provides a way to provide custom panel instructions. Tooltips may not have return characters. (For the panel manipulator, the tool tip is taken from the underlying 2-d manipulator.)

Setups For Typical Switches and Elements

Here are some typical setups for making 3-d animated switches and other cockpit parts.

Terms

  • Rotary: any part with rotational movement.
  • Momentary: any part that returns to its original position when released.
  • 2-way,3-way,n-way, continuous: how many distinct positions a part can take. A dimmer is continuous; an on-off switch is 2-way.

Non-Momentary Parts

These parts retain their original position after being clicked.

2-way parts

Datarefs: use the “toggle” manipulator – the on and off values match the two possible values for the underlying dataref.

Command: if a “toggle” command (e.g. sim/flight_controls/landing_gear_toggle) exists, you can use a command manipulator. You cannot use a “set to X” command like sim/flight_controls/landing_gear_up.

N-way switch

Use the axis manipulator along the axis the user can drag. Important: to get “N”-way action, be sure the underlying dataref is of type “integer” so the switch “snaps” to each position.

N-way rotary

Use the 2-d axis manipulator, but only use the X axis. This will allow a horizontal drag to turn the rotary. To get “N”-way action, be sure the underlying dataref is of type “integer” so the switch “snaps” to each position.

Radio Buttons

Radio buttons can take on N positions, by having any one button pressed in. Set each button to have a manipulator of type “radio button”. All buttons should have the same datarefs but different values.

Continuous Switch

Use the axis manipulator along the axis the user can drag. The underlying dataref should be of type “float”.

Continuous Rotary

Use the 2-d axis manipulator, but only use the X axis. The dataref should be of type “float”.

Momentary Parts

These parts snap back when done.

2-way momentary

Dataref: use the “push button” manipulator with appropriate on and off dataref values. Command: if the action is a “hold-it-down” command (like sim/starters/engage_starter_1) you can use a command manipulator.

3-way momentary

Use the command-axis manipulator, with one command for each direction.

Comments Off on Manipulators

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.
Comments Off on Managing Translucency