article_type: Tips & Tricks

Creating Generic Instruments

The Rotary

  • The rotary can be used as a single image layer, but with dynamic lighting. Set it to no click, one image.
  • Rotary can be used behind an image to get “dynamic lighting” onto a background. (But – don’t make it too large – spot lights affect overlays UNIFORMLY. Burns VRAM. No shadows!)
  • Rotaries can be used with rheostats – set the rheostat to no -1 layer on top of the rotary with no click, customize hot spots. Same trick works with triggers.
  • Put a rotary (no click 1 phase) as a face plate over a pointer, but set the pointer itself to clip, to ensure that if the pointer exceeds its “masks” bounds it disappears.
  • Key frames must be continuous EXCEPT for rotaries – use to re-arrange enums. See Non-Monotone Key Frames.
  • Rotary key frame output < 0 means it disappears. Use for annunciators. Don’t need transparent frame. Save VRAM.
  • Rotary key frame > digits WRAPS. USe for repeating animation like trim wheel.

Using Rotaries With Plugins

You can use a rotary as a way to get “mouse clicks” in a plugin:

  • Set the rotary mode to “momentary”.
  • Create a custom dataref handler.
  • Your dataref’s “set” handler will be called once on a down click and once on an up click. The down click will have a value of the number of frames – 1, and the up will have a value of 0.

There is one complication with this method: if you are using the “get” function from your rotary to make the light flash, then you may not receive “set” messages, because the sim won’t write back to your dataref the same value you returned. (Thus if you use “1” for “lit”, you won’t get down-clicks in a 2-phase rotary.)

The solution: rotaries will modulo their number of frames. So for a two-phase rotary, return 2 & 3 from your plugin, instead of 0 and 1. The graphics will look the same, but you will still get writes of “0” and “1” on click.

Driving The Same Dataref With Multiple Rotaries

You can use multiple “push-button” rotaries to set the same dataref between two values. For example, say you want to have (3) push-buttons on your panel and they all set the dataref between zero and another value as follows:

  • Push-button #1 to drive the dataref to either 0 or 1,
  • Push-button #2 to drive the dataref to either 0 or 2
  • Push-button #3 to drive the dataref to either 0 or 3.

You would set the gen_rotary properties to Positions = “2” and Rotary Type = “Push Button”. Your graphic image should be designed with two (2) phases.

You should then set-up the key frame table as follows:

For Button #1:

Dataref Value ––––––––—–––– Image Number

          0                            0
          2                            0
          3                            0
          1                            1

For Button #2:

Dataref Value ––––––––—–––– Image Number

          0                            0
          1                            0
          3                            0
          2                            1

For Button #3:

Dataref Value ––––––––—–––– Image Number

          0                            0
          1                            0
          2                            0
          3                            1

When a button is pushed, X-Plane looks for Image #1 in the key frame table (the highest image for a 2-phase image) for that button and notes what the dataref should be set to by the associated “Dataref Value”. At the same time all other buttons with that dataref are set to zero.

All of the enum values for the dataref must be individually listed in the keyframe table (you cannot set up a range). The last key frame needs to be the “1” frame.

Glass vs. Translucent Glass

X-Plane has two modes of glass instrument lighting. Both take the light levels from an instrument light level rheostat and light the instruments overlays, ignoring spot lighting. The difference is in how they fade:

  • Glass instruments are opaque except for their alpha channel, drawing over what is behind them. As they get dark, they fade to black. Thus they can be used to form masks as well as glass instruments, but they will only appear to blend in over a pure-black background.
  • Translucent Glass Instruments draw additively – the alpha channel is not needed and has no effect. As they get “dark” they become more translucent – that is, they add less. They cannot be used for masks, but they will draw over any background, allowing for screen backgrounds that are not pure black.

Needles

  • Generic needles can be offset – save VRAM!
  • Needle can act as a heading bug, via offset and drag.

Rheostats

  • Rheostats can have overlays – save VRAM.
  • Set rheo step 2 to 0 to get incremental movement.

Pie

  • You can customize the colors of the pie – the-2 overlay image has 3 color swatches for the “green”, “yellow” and “red” tinges, which are chosen based on the dataref range. So you can pick any color for your pie.
  • If you ned more than 3 colors, make two overlapping pies and use show-hide to switch between pies at certain dataref ranges.
  • You can make a pie that is a thin line rather than thick by putting a black pie in front of the white pie, but give the black pie a smaller radius. After 930 you can simply use the offset parameter.

Groups

After X-Plane 930 groups can be hidden using filters. This can be used in a few ways:

  • If you need more filters (E.g. hide an instrument based on a number of conditions) simply put the instrument into a group – now you can filter the instrument or the group.
  • You can hide non-generic instruments by putting them inside a group.

Pointer Instead of Rolling For Tapes

gen_rolling is meant for a mechanical drum style instrument but it will not work if a large section of the “drum” is visible…thus while it seems that it should be usable as a tape, it is not. (The instrument does not work as a tape because not enough “extra” texture is provided at the top and bottom).

After 940 you can use a vertical pointer with a wrapping key frame table to make a looping tape.

Misc

  • Key frame tables can be clamped by doubling an output value, e.g. (-1,0) (0,0) (1,1) (2,1)
  • You can also clamp one side of a key frame table and wrap the other side. To do this you’ll need to repeat a value. For example: (0,0) (0,0) (100,100) will make a key frame table from 0->100 that can be wrapped at the top but will clamp at the bottom.
Comments Off on Creating Generic Instruments

Additive Lighting

Additive Lighting Equation

X-Plane’s “lighting” equation is fundamentally this:

albedo texture * external light level + emissive texture * internal light level

To define these components:

  • The albedo texture is the “daytime” texture, used for an OBJ, airplane fuselage, or instrument. Typically it does not have a suffix. It contains an image of the object at its brightest during the day.
  • The emissive texture is the “_LIT” texture, used for an OBJ, airplane fuselage, or instrument. The emissive texture typically contains the image of the parts of the object that emit light (e.g. light bulbs, neon signs).
  • The external lighting level is the sum of all light falling on the object/instrument, etc. This usually includes the effects of the sun, and sometimes also landing lights or in-cockpit spot lights.
  • The internal light level is the attenuation of the brightness the object/instrument is emitting. For example, the LED digits on a radio might have their brightness turned down by the user.

Additive Lighting in the Scenery System

Additive lighting has been available in the scenery system for a very long time via emissive textures.

  • For older scenery file formats, X-Plane will automatically look for a texture with the suffix _LIT and use it as an emissive texture.
  • For newer scenery file formats, there is typically a texture command (like TEXTURE_LIT) to define the name of the emissive lighting texture.
  • Mostly the internal light level for emissive textures is determined by X-Plane. In 930, OBJ authors can override this light level using ATTR_light_level.

Additive Lighting for Instruments

In older versions of X-Plane, additive lighting was not available for instruments.

  • Starting with X-Plane 920, generic instruments can use additive lighting – set the lighting mode for the instrument to “back-lit” and provide _LIT versions of the overlay textures. (The -1 overlay would be XXX_LIT-1.png, for example.)
  • Starting with 930, any instrument can have additive lgihting – set the lighting mode to “Additive” for non-generic instruments.
  • The panel background cannot use additive lighting – use generic instrument overlays to build emissive panel parts where needed. (For example, to make the labels for an overhead panel be emissive, you need to build them using a generic instrument overlay, like a rotary, rather than putting them in the background of the panel.)
  • To get additive lighting in the 3-d cockpit, use ATTR_cockpit_region, not ATTR_cockpit!

Emissive Textures and Alpha Channel

The emissive texture (typically called _LIT or _LIT-1, etc.) usually does not need an alpha channel. Since the texture is added to the albedo (daytime) texture, a black pixel will have no effect. Thus no alpha channel is needed – black is the “alpha” of a LIT texture.

If there is an alpha channel for an emissive texture, how it is interpreted depends on context:

  • For objects, if an emissive texture has alpha, the alpha is added as well. This means that an object can become less transparent when the LIT texture is visible.
  • For airplanes, the alpha channel is ignored.
  • For instruments, the alpha channel is not allowed – Plane-Maker will flag this as an error!

A tip on creating _LIT textures

Typically, your regular texture should have alpha while your _LIT texture should not. This would, for instance, be the case for an aircraft fuselage with transparent windows that is lit up the logo lights at night. The regular texture should use alpha to make windows transparent, while the _LIT texture should represent any lit parts of the fuselage over an opaque black background.

When creating emissive _LIT versions of your object textures, it’s important to know whether your textures have alpha channels or not. What’s a little confusing is that it’s possible for your _LIT texture too look perfectly opaque and still have an alpha channel which could cause undesired effects in X-Plane. How to avoid this depends on what graphics software you are using to create your textures.

To remove an alpha channel in Photoshop, you should select “Flatten image” in the layers toolbox before saving your _LIT texture. The result should be a single layer called Background. There is also a variety of image tools and graphics converters that allow you to save images with or without alpha.

Comments Off on Additive Lighting

Command Line Options

This article describes the existing command-line options supported by X-Plane; it is essentially an extract of X-Plane’s command line help. You can find instructions on using command line options here.

Command Line Options exist to control program behavior beyond the default settings.

X-Plane can take a number of command-line flags, in the form of –flag or–flag=value. While OpenGL options are available for all X-Plane-related applications; the frame-rate test is only for X-Plane itself.

–help or -h Prints the message listing all command-line options, then quits.

Sound related Options

–no_sound Runs without initializing sound – can help identify a problem with sound hardware.

Options to Disable Video Hardware Acceleration

Normally X-Plane uses all available hardware capabilities to maximize the frame rate, these options force X-Plane not to use some aspects of hardware acceleration. This impacts frame rate, but can sometimes allow you to work around driver bugs.

–no_vbos Disable the use of vertex buffer objects, as defined by GL_ARB_vertex_buffer_object. VBOs are used to accelerate all aspects of X-Plane drawing.

–no_fbos Disable the use of framebuffer obects, even if the hardware supports them.

–no_pbos Disable the use of pixelbuffer obects, even if the hardware supports them.

–no_sprites Disables the use of point sprites, as defined by GL_ARB_point_sprite. Point sprites are used to accelerate runway lights, among other things.

–no_pixel_counters Disable pixel counters, as defined by GL_ARB_occlusion_query. Pixel counters are used to calculate sun glare, among other things.

–no_aniso_filtering Disable anisotropic filtering of textures, as defined by GL_EXT_texture_filter_anisotropic. Anisotropic filtering is used to make runways look better.

–no_hw_mipmap Disable hardware accelerated mipmap-creation, as defined by GL_SGIS_generate_mipmap. X-Plane will still use mipmapping, but it will create the mipmap images on the CPU instead of the GPU.

–no_fshaders Disable the use of fragment shaders, even on hardware that reports having them.

–no_vshaders Disable the use of vertex shaders, even on hardware that reports having them.

–no_glsl Disable the use of GLSL, even on hardware theat supports it.

–no_threaded_ogl Disable the use of OpenGL via multiple threads.

Options To Enable Incompatible Video Hardware Acceleration

X-Plane will in a few cases intentionally disable hardware acceleration to work around known driver compatibility bugs. You can force X-Plane to use the feature anyway (if the card supports it) with these options, but they may cause the sim to crash.

–use_vbos Forces the use of VBOs, even on drivers where we at one point found them to be unstable.

–use_sprites Forces the use of point sprites, even on drivers where they cause bugs.

–use_fshaders Force the use of fragment shaders, even if they would not normally be used.

–use_vshaders Force the use of vertex shaders, even if they would not be used.

–use_glsl Force the use of GLSL even on cards where we would avoid it due to driver compatibility problems.

–force_run X-Plane will not run on a machine that does not appear to have some minimum requirements, like at least two texture units. This will allow X-Plane to run no matter what the hardware looks like. Please note that most of the time if X-Plane out-right refuses to run, it will probably crash later if –force_run is used.

Frame Rate Options Logging

–fps_test=n This runs X-Plane in frame-rate test mode. The number indicates a frame rate test number, which is 3 digits indicating a combination of camera angle, scenery complexity, and weather settings. X-Plane will run for 90 seconds and quit, outputting 3 framerates to the Log.txt file for panel view, no-panel view, and paused no-panel view. This can be used to get repeatable performance measurements without changing preferences. (The preferences file is ignored when the framerate test is in effect.)

–require_fps=n When used after –fps_test this puts X-Plane into a pass-fail mode. The sim will run only one 30 second test with the flight model paused. The sim will then exit with 0 if the measured fps is higher than N or 1 if the fps is lower. This can be used to create a shell script that will automatically detect whether X-Plane performance is as expected.

Comments Off on Command Line Options

FAQs for data designers

Where are all the elements of an ILS positioned?

X-Plane requires all ILS components to be placed in their correct, real-world locations.

The localizer aerial is positioned beyond the far end of the runway it serves, pointing back down the runway towards approaching aeroplanes. This ensures that an aeroplane can have localizer guidance on the final stages of its flare to land (after it has crossed the runway threshold, or as it begins its missed approach). The localizer is almost always perfectly aligned with the runway it serves … but sometimes they are slightly offset, usually to provide terrain clearance on the approach. If so, the localizer position will be moved so that it still points across the touch down zone of the runway. You can see an example of this at KBOS.

The glideslope aerial is positioned to one side of the touch down zone, usually perpendicular to the touch down zone markings on the runway, close to the VASI / PAPI location. It operates on a frequency paired to the localizer frequency.

Marker beacons are becoming rarer, but are positioned along the final approach path. The outer marker is usually at the Final Approach Fix, usually 4NM to 7NM from the runway threshold, and is sometimes paired with short range NDB (called a Locator Outer Marker or LOM). The middle marker is closer to the runway, usually at point at which an aeroplane flying the glideslope should be at the Decision Height (DH) for the approach, typically about 3,500 feet out from the runway threshold. The inner marker is very close to the threshold, and is rare – they are used for Category 3 approaches to very low DHs.

How will my custom scenery affect the “master” airport data?

X-Plane scenery packs are loaded in priority order; in order to ensure that you see your payware or custom scenery, it must be higher priority than the global airports.

Scenery packs in “Custom Scenery” are loaded in the order of scenery_packs.ini (a text file in the Custom Scenery folder). Custom scenery packs at the top of the .ini file are loaded first and override packs below them. The scenery_packs.ini file lets users disable and re-prioritize scenery packs without having to rename anything.

Any time X-Plane runs and finds a scenery pack not in the .ini, it adds it to the top of the file; therefore when you install new scenery, it starts at the highest priority level. Usually this is what you want.

The airports from the X-Plane Airport Gateway are in a scenery pack called “Global Airports” in your custom scenery – this pack should be higher priority than any base meshes but lower priority than any custom airports.

Can I use custom nav-aid or fix data in a custom scenery package?

No. Any earth_nav.dat or earth_fix.dat files in a custom scenery package are ignored by X-Plane.

It is not possible to uniquely identify a nav-aid by its ID or frequency, so it would not be possible for X-Plane to match nav-aid information in a custom scenery package against the matching data in the ‘master’ earth_nav.dat file. (This process does work for airports because the airport ICAO codes are guaranteed to be unique.) In addition, the purpose of the custom nav-aid data may be to correct the ID or frequency of a ‘bad’ nav-aid, making making the suppression of the ‘bad’ master data impossible. Similarly, fix names are not unique at a global level.

So, changes to nav-aids must be made in the ‘master’ earth_nav.dat file and fixes must be changed in the earth_fix.dat file. Send any corrected data to be included in the master database via the bug reporter on the Airport Scenery Gateway.

My airport does not have an ICAO or FAA code. What should I use in X-Plane?

Within the USA, almost every airport has either an ICAO or FAA airport code. But in many other countries, smaller, disused or private airports do not have any kind of published code. But, X-Plane requires a unique code for every airport.

The way we traditionally solved this was by allowing airport authors to invent an identifier similar in style to the ICAO codes used in that region. So, for instance, since German civil airports follow the pattern EDxx, someone might have invented ED01. This causes a problem if ED01 gets assigned to another airport in the real world. As of X-Plane 10.40, we’re moving to prefixing these fictitious identifiers with an X. So, German civil airports that have real ICAO identifiers follow the pattern EDxx, while German airports with only made-up identifiers follow the pattern XEDxx.

If you need a new airport identifier created for either an airport with a long official identifier, or an airport with no identifier in the real world, just file a “New Airport Code Request” on the Airport Scenery Gateway bug reporter and we’ll get you taken care of.

Comments Off on FAQs for data designers

Resources for Data Designers

Tools

World Editor (WED) is a free, open source tool for airport scenery creation.

The Aviation Formulary is a treasure trove of useful formulae used in aviation, usually explained in easy-to-understand terms.

A good text editor is often useful, to review and search the data files, such as Notepad++ for Windows. Amongst other features, it will convert files between Windows, Mac and Linux formats.

‘Real-world’ aviation data sources

X-Plane relies upon publicly-available, freely-available data sources. We cannot reverse-engineer proprietary databases and use that data. Of course, it is hard to find high-quality, global data that meet these criteria.

There are many sources of ‘real world’ aviation data, and each country often has its own process for maintaining and publishing its data. Some make their data freely available, but others regard this data as a valuable asset to which a high price is associated! Within the USA, data is available by subscription for a nominal fee from the FAA’s National Flight Database (NFD).

Common sources of data are AirNav.com and World Aero Data. The National Aeronautical Charting Office (NACO) gives free access to all US airport and instrument approach charts (other sources offering the same data include AOPA, if you are a member). Many countries offer some kind on on-line access to their aviation data and/or charts – for example, the UK NATS site has detailed colour charts of all UK aerodromes.

Google Earth, Google Maps, Live Search Maps and TerraServer all have a role to play in airport design. Depending upon the imagery available, these tools can provide detailed aerial views of many airports. Ortho-rectification of the images is usually good, but remember to switch off any features that try to show 3D terrain (this can distort the images).

Google Earth can be used to obtain latitude/longitude positions for many features (remember to set the format of the lat/lon to decimal degrees in the Tools/Options menu).
The ‘birds eye’ view on Live Search Maps offers extremely detailed imagery – good enough in many cases so that taxiway signs can be read. But coverage is limited.

‘Real-world’ concepts

The US FAA has published standards for the design of airports:
FAA Aeronautical Information Manual (a very important resource for any aviator).
FAA AC on airport design (a large PDF file).

Magnetic variation: All X-Plane data that contains directional/heading information is defined as a true headings. But published data for localizers almost is always expressed on charts as a magnetic heading, so these need to be converted to a true heading for our data files to ensure correct alignment in X-Plane. But … one ‘gotcha’ is that localizers (and other nav-aids) can be edited within X-Plane itself (on the map screen), and here the bearing is shown as magnetic (on the assumption that users may be trying to build an ILS based upon a real-world chart). The data will be automatically converted to a true heading when X-Plane saves the data.

Global data: X-Plane’s data coverage is global. Different countries often have different standards for the definition and use of their aviation data.

Many pilots who fly only within the USA believe that altimeters should always be switched from a local barometric setting to a standard setting (29.92 inches or 1013 hPa) when climbing through 18,000 feet (the Transition Altitude). But in many countries the TA is much lower, and may even vary within a country (it is usually printed on airport diagrams and approach charts). For example, the TA is at 3,000 feet over much of England, so it is normal for a VFR pilot to cruise at FL40.

The UK and some other countries uses different types of runway markings – these are available in X-Plane, but must be explicitly selected in WED.

Taxiway signs and painted markings are generally consistent around the world, but stylistic difference do exist.

Double check the units of measure: Many countries use a complex mix of metric and imperial units in aviation. The USA generally uses imperial units (but uses the Celsius scale for temperatures). Many other countries use metric units for all measurements, except for elevations (which are – usually – in feet). So, it’s easy to look at an airport diagram and to forget to convert a measurement to the appropriate units for X-Plane. For example, X-Plane now requires all distances (such as displaced thresholds, blastpads) to be defined in metres in its data files, though elevations are still defined in feet.

Comments Off on Resources for Data Designers

Upgrades to Aircraft for X-Plane 10.40

X-Plane 10.40 fixes a few bugs where:

  • The bug fix applies once you save your aircraft with Plane-Maker version 10.40 or newer; older planes will maintain compatibility with the old and buggy behavior.
  • You may need to edit your aircraft when running under the new non-buggy code (by re-saving your aircraft).

In other words, these are bugs that were fixed, where aircraft may have been relying on the buggy behavior.  We strongly recommend you re-save your aircraft and re-check these items.

High Altitude Fuel Consumption for Jets

This applies only to jet aircraft: X-Plane 10.36 and older incorrectly interpolated between the 50% and 100% N1 fuel flow SFC numbers. If your 100% and 50% N1 SFC numbers are not the same, the new, correct interpolation will change your fuel consumption at high altitudes.

  • If your 50% SFC is higher than your 100% SFC, you will see lower fuel consumption.
  • If your 50% SFC is lower than your 100% SFC (this is not usual) then you will see higher fuel consumption.

Billboard Light Sizes

Before X-Plane 10.40, the size of lighting billboards for named and param lights was fixed in pixels. This meant that as a user increased screen size, the lights looked smaller, relative to the scene, and everything looked dark.

X-Plane 10.40 changes this behavior to keep lights consistent relative to the screen.  When you save your aircraft for X-Plane 10.40, this will apply to your aircraft too.

You may have to make your lights smaller – the larger the screen where you authored your lights, the larger the increase in size you will see relative to X-Plane 10.36.

Once you have re-tuned your light sizes, their appearance in X-Plane 10.40 will be consistent for all users.

Check Engine Oil Pressure

X-Plane 10.36 and earlier incorrectly failed to feather the prop on low oil pressure for twin props. Once your aircraft is saved in 10.40 this logic will work; if you set the oil pressure to be too low in your aircraft, you may find the prop spontaneously feathering itself. Fix this by changing the red line oil pressure in Plane-Maker.

Comments Off on Upgrades to Aircraft for X-Plane 10.40

Calculating Rendering Load

Types of Rendering Primitives

The X-Plane renderer’s “low level” component is responsible for scenery drawn to the screen; it is considered low level because the more abstract scenery descriptions from DSF tiles are held in memory and then converted into low level primitives for drawing when they come into the local area of flight.

There are three kinds of low level primitives:

  • Patches are static sets of triangles or lines that are not repeated and exist at a specific world location.
  • Objects are statically placed instances of OBJ files, in other words, repeated meshes with possible attributes and animation.
  • Vehicles are OBJ instances that continually change their position.

While a little bit more book-keeping is needed for vehicles, for the purpose of budgeting they can be treated as static OBJ instances; the cost of moving them is very low relative to the rendering load.

Rendering Primitive, DSFs and apt.dat

This is how DSF primitives and apt.dat primitives map to low level primitives:

  • DSF Mesh -> Patches. (These are the only patches that always exist no matter where the plane flies.)
  • DSF Object -> Object Instance.
  • DSF Forest-> Patches.
  • DSF Facade -> Patches.
  • DSF Beach -> Patches.
  • DSF Draped Lines -> Patches.
  • DSF Draped Polygons -> Patches.
  • DSF Object Strings -> Object Instances.
  • DSF Road Network -> Patches, vehicles and object instances.
  • Apt.dat pavement -> Patches.
  • Apt.dat marking lines -> Patches.
  • Apt.dat lights and fixtures -> Objects.

Most of the dynamic scenery in the sim (balloons, boats, birds) also become object instances.

Special Processing for Objects

The billboarded lights from objects are sometimes stripped from the objects, consolidated, and converted to patches. Most of the objects used for runway lights have been carefully built to make them candidates for this process.

An object with no content (e.g. no LODs or only empty LODs after light stripping) will be discarded from the scene graph.

What this means is that when the low-quality airport-light objects are used (e.g. “high detailed runway environment” is not on) then all of the lights are stripped and turned to patches, and no object instances are generated. This means that the low-quality rendering load of O’Hare is at most about 10,000 patch vertices and 0 object instances.

Hardware Budget

Graphics cards are pipelined – that is, different parts of the hardware perform different tasks in parallel; the pipeline runs as fast as the slowest stage. So your framerate will be limited by the resource you run out of first.

This list does not mention uses of budget that tend not to matter. For example, objects consume video memory bandwidth, but video memory busses are so much faster than the rate at which the sim can draw objects that you’d never max this out.

CPU Use/Batches

Every time X-Plane has to draw a set of triangles, the CPU gets involved. The amount of work the CPU does depends on how much state change there is between batches.

Batches are used up by having a larger number of individual textures (each texture swap is a new batch), having more objects (each object is at least one batch), and having more attributes in objects (each attribute change is a new batch).

Patches also create batches, but because state is shared between patches, the cost of rendering a lot of similar patches is not as large as rendering a lot of objects.

Graphics Bus Bandwidth

All data needed to render the scene that isn’t already in video memory has to travel over the graphics bus. Frame-rate can be limited if the graphics bus is maxed out.

The biggest consumer of bus bandwidth is patches, because they reside in system memory. Graphics bus bandwidth is also consumed when the working set exceeds video memory (see below).

Video Memory

Video memory is RAM on the graphics chip. Because it is connected directly to the GPU by a high performance custom memory bus, data can be fetched much faster from video memory.

Usage of video memory is controlled by the video driver; X-Plane requests that a set of objects be cached in video memory and the card does its best to store as many of them in video memory as possible; the rest are stored in system memory and transferred as needed.

X-Plane requests video-memory caching of the mesh vertices for all objects and all textures.

Dynamic textures (textures rendered by X-Plane) are particularly notable; not only do they take video memory, but if they have to be removed from video memory they have to be transferred over the bus (consuming bus bandwidth). So dynamic textures can be considered to be significantly more video memory expensive. Examples include a very large panel texture used in a 3-d cockpit.

Working Set

The working set is the set of all data that X-Plane needs to render a single frame. Every bit of data in the working set must either be cached in VRAM or transferred over the graphics bus. Thus you could say that:

framerate = graphics bus bandwidth / (working set - video memory)

In other words, once the working set exceeds video memory, framerate will start to go down, but less so if the graphics bus is fast. This equation isn’t perfectly obvious because X-Plane will not attempt to cache mesh vertex data, even if video memory is free.

Working set becomes larger when more textures are visible on screen, more objects are visible on screen, more patches are visible on screen, etc. Careful LOD to fully remove objects can reduce working set, as can arranging textures so that shared textures are used for a set of nearby objects.

Video Memory Bandwidth

While video memory is exceedingly fast, it is still possible for the video card to have trouble fetching texture data. This typically only happens when a very large texture is being drawn over a very large number of pixels, and the drawing mode is very inexpensive (e.g. no shaders, no blending, etc.). It is also possible to consume extra video memory bandwidth by hacking X-Plane’s settings using the nvidia control panel (e.g. turning texture LOD bias way up).

Video memory bandwidth is effectively only consumed by textures.

Shader Ops and Raster Ops

Shader Ops are operations performed by pixel shaders; more complex shading algorithms (like the reflective water or volumetric fog) consume more shader ops, as do drawing more pixels.

Raster Ops are operations committing pixels to the screen. Drawing one texture over another (E.g. with overlay polygons) can consume a lot of raster ops, as well as shader ops, since we’re filling in the same memory over and over.

Measuring CPU and Bus Usage

CPU and bus usage can be measured by looking at specific dataref editor statistics. From the dataref editor, pick “show stats”; the sections below indicate what stats to look at. Use the filter function to view groups of stats easily.

terrain/num_layers

tells the total number of “layers” (that is, groups of stuff with unique graphics state) drawn per frame – higher numbers indicate the use of more expensive batches and more CPU time.

Patch Vertex Throughput

Patches are the direct contributor to vertex throughput, which consumes bus bandwidth. Of all patch sources, forests are usually the one that maxes out the graphics bus, because it’s possible to create hundreds of thousands of trees with a simple polygon and .for file.

xdl/num_xdl_vert

shows the number of patch vertices rendered per frame.

Patch CPU Load

The terrain patch stats show how the CPU is being used to draw patches.

terrain/num_patch_draw

tells the number of patches being drawn, adding (relatively inexpensive) batches.

terrain/num_patch_test

tells the number of patches that are visibility tested, consuming CPU.

terrain/num_patch_buckets

tells the number of steps taken over the quad-tree containing all patches, consuming CPU.

The water stats are rather poorly named; when reflective water is on, the sim has to make an initial pass over all visible water patches to figure out how to position the water reflection plane. This usually isn’t very expensive compared to the rest of drawing, but could be if you had a really huge number of water patches.

terrain/num_water_bucket

tells the number of steps taken over the quad-tree containing information about water location, consuming CPU.

terrain/num_water_draw

tells how many water patches were evaluated, consuming CPU.

terrain/num_water_test

tells how many water patches were visibility-tested, consuming CPU.

Object Throughput and Batching

Static object instances and vehicles are captured through the following stats:

terrain/num_car_buckets

– the number of steps through the scene graph for cars.

terrain/num_car_draw

– the number of cars drawn.

terrain/num_car_test

– the number of car visibility tests.

terrain/num_object_buckets

– the number of steps through the scene graph for objects.

terrain/num_object_draw

– the number of drawn static objects.

terrain/num_object_test

– the number of object visibility tests.

These stats apply to all objects drawn from any source in the sim.

object/num_batches

– the number of batches caused by all object drawing.

object/num_cmds

– the number of commands executed by all objects.

object/num_lines

– the number of lines drawn for all objects.

object/num_mouse_tri

– the number of triangles evaluated for mouse-click testing for the cockpit object.

object/num_objs

– the total number of objects drawn (static, vehicles, dynamic scenery, and airplane-attached).

object/num_objs_change

– number of non-sequential drawn objects.

object/num_tris

– number of tris drawn for all objects.

object/pln_obj_count

– number of objects drawn that are attached to airplanes.

Identifying Limiting Bottlenecks

A few tips on identifying limitations due to CPU and bandwidth:

  • If X-Plane is not fully utilizing one core, it is probably not bottlenecked on CPU use. (But the sim could be bottlenecked on both CPU and later on raster ops.)
  • If drawing fewer objects improves frame-rate when the objects in question are very small (e.g. an aerial view) and texture res is set conservatively, then you are probably batch-limited and CPU limited.
  • If you are not drawing objects and pixel shaders and FSAA are off and you don’t appear to be batch-limited, you could be bus limited.

Identifying Back-End Bottlenecks (Raster Ops, etc.)

X-Plane can be bottlenecked on back-end operations, e.g. Raster Ops and Shader Ops.

  • If decreasing the sim’s screen size improves framerate, the sim may be bottlenecked on raster ops or shader ops.
  • If turning down the sim’s anti-aliasing settings improves framerate, the sim may be bottlenecked on raster ops or shader ops.
  • If turning off shaders improves framerate (compared to shaders with no volumetric fog or water reflections), you may be bottlenecked on shader ops.

There are a few specific authoring techniques that can bottleneck back-end ops:

  • Over-drawing the terrain using overlay polygons consumes a lot of fill, since the sim must pixels and then draw over them again.
  • Overlapping a lot of pavement in an airport can also consume fill rate.

Use Mesh Tool, not overlay polygons to add orthophotos to the sim.

Don’t overlap pavement in apt.dat files.

What Isn’t Counted

The statistics above do not count three major sources of slow-down:

  1. The 2-d panel.
  2. Non-object airplane geometry (e.g. geometry modeled by PlaneMaker).
  3. Clouds and weather drawing.

To get a clean estimate, use a forward-no-HUD view on a clear day to eliminate these other consumers of resources.

Comments Off on Calculating Rendering Load

Propeller Beta & Reverse Models

Everybody always asks, and few ever understand, how the propeller beta and reverse models work in X-Plane.

Everything here applies to single and multi-engine propeller planes in X-Plane, and also applies to REAL KingAirs and Lancair Evolutions and the like (planes with PT-6 engines) because they work mostly the same way. To simulate non-PT-6 airplanes, use the info in this document to see how X-Plane works, and then tweak the inputs into Plane-Maker as needed to suit your propeller-driving engine.

So let’s start with the REAL airplane description, and then move on to entering data into Plane-Maker after that.

Real Airplanes

The Red Knob: the Condition Lever

If this is all the way forward, then you are at FLIGHT idle. This dumps enough fuel into the engine, even at IDLE throttle, to keep the flame from going out.

If this knob is about halfway back, then you are at GROUND idle. This is a lower idle speed, designed for the taxi-only operations, where a flame-out would not be catastrophic.

If this knob is all the way back, then you are at CUT-OFF: All fuel to the engine is cut, with predictable results.

The Blue Knob: Prop RPM

This knob does not control fuel to the engine, but instead commands the RPM that the prop WANTS to turn.

If the prop is turning SLOWER than the RPM commanded by the blue knob, then the prop will FLATTEN.

If the prop is turning FASTER than the RPM commanded by the blue knob, then the prop will INCREASE its pitch to slow down.

As long as there is enough power and/or airspeed through the prop disc, then the RPM that you have commanded with the blue knob will be followed by the prop.

Now, if the blue knob is all the way FORWARD, then the prop will adjust pitch to try to hold REDLINE RPM (maximum rpm for take-off or fast cruise). As you drag the blue knob AFT, you get progressively less and less commanded RPM, until you get the blue knob all the way aft, at which point the prop will FEATHER (if this is a feather-able prop–some are, some aren’t), where it goes to the feathered pitch of the prop, which will result in basically zero rpm.

The Black Knob: Throttle

And now, finally, the BLACK KNOB, which we commonly refer to as the ‘throttle’, but will also control the prop in certain cases, as we will show below.

When you are doing regular flying, you have the throttle at or forward of the idle stop. As long as the throttle is at or forwards of the idle stop, the propeller is in what is called ALPHA mode.

In ALPHA MODE, the propeller acts as described above, adjusting pitch to try to hold the RPM commanded by the blue knob (redline when all the way forward, minimum or feathered when all the way back). This means that it tries to hold the RPM commanded by the BLUE KNOB, and it does this by adjusting prop pitch as needed to hold that commanded RPM. This is how you taxi and fly.

Now, sometimes, as you taxi in a PT-6 turboprop, your taxi speed starts to build up too high for comfort even with the engine at IDLE!

This, perhaps, is not surprising when you have an engine of about 1,000 horsepower on a light airplane, and being a turbine, it even idles fast to keep the desired airflow running through the engine. (This is needed, interestingly, to keep the engine from overheating! If a PT-6 were to idle too slowly, then the blanket of air that isolates the flame of combustion from the engine wall would deteriorate, allowing the flame to touch the engine wall and melt the engine! So we actually have to idle fast in a PT-6 to keep the combustion flame from reaching the engine wall and destroying it!)

When taxiing, we have a hugely powerful engine running at a high idle, so even at ground idle, the taxi speed might be too fast for comfort.

In that case, you lift the black knob aft of the idle stop and drag it back.

As you do so, the engine stays at idle, and the farther you drag the handle aft, the more the prop pitch moves from flat pitch to beta pitch. This is beta.

If you keep moving the throttle back even FARTHER, then the prop pitch moves from BETA pitch to REVERSE pitch, and the throttle starts coming up as well! This is reverse.

NOTE: Beta and reverse only work if the blue knob is all the way forwards. For whatever reason, Pratt and Whitney just designed the system this way.

Here is a table diagram:
(NOTE: all transitions between the states should be smooth and continuous. There is no sudden jump anywhere.)

Throttle Position Prop Mode Fuel Flow
1 forward alpha mode max!
2 idle stop alpha mode ground or flight idle
3 beta beta pitch ground or flight idle
4 reverse reverse pitch full reverse fuel flow

Setting up Plane Maker

Now, on to Plane-Maker, which you can set up to perfectly match the PT-6 described above.

Go to the ENGINE tab in Plane-Maker.

For the critical altitude upper-left, enter the maximum altitude at which that maximum power is actually available.

PT-6’s are typically flat-rated, so you can enter some altitude above 0 here… most PT-6’s continue to give full power as they climb until they hit a temp-limit and then they lose power as they climb above that point. Whatever point you first have to drop below max torque at max RPM due to hitting a temp-limit–that is the critical altitude: The highest you can fly and still get full power.

Below that you see the box for the FADEC. Check it if you have it–some PT-6’s have that, some don’t.

Throttle available at max lever is the throttle available when the throttle is all the way forwards. This is usually 1.00, but if your Ng (called N1 in X-Plane) goes over 100% in the real plane, then enter a slightly higher number here.

Below that, you see your low and high idle adjustments: Simply adjust these ‘idle screws’ up or down a bit as needed to idle at just the right Ng, or torque, when you are at low or high idle.

Now, below that, you see “Go to BETA PITCH below this throttle lever position”. This is the position shown in line 2 in the throttle position map up above.
If you are dragging the throttle with the mouse or have a hardware throttle, then below this value for that device, we start going into BETA.

Now, below that, you see “Go to REVERSE below this throttle lever position”. This is the position shown in line 3 in the throttle position list up above.

If you are dragging the throttle with the mouse or have a hardware throttle, then below this value for that device, we start going into REVERSE, and the throttle starts coming up as well!

Now, below that, you see “throttle available at max reverse lever position”. This is simply the percentage of maximum throttle that is available when you pull the lever all the way back to the aft stop. It is the throttle available from the engine in line 4 above.

Now, here is something interesting: If you want your physical throttle handle to be set up like the throttle in a real KingAir or Evolution or the like, then you will use the values above to scale the throttle accordingly.

But here is where it gets bogus: In the REAL airplane, there is a GATE at the idle stop of the throttle that keeps you from going into beta by mistake: You have to lift a trigger to get over the gate and into beta to keep you from going into beta by mistake in flight. But you probably don’t have that gate on your physical throttle quadrant, or want to mess with trying to find that exact point when moving the throttle, or even operating the throttle with the mouse on the monitor. You probably want to just drag your throttle all the way back to go to idle, since that is the way any normal person would want to descend! So, in Plane-Maker, you could easily enter ZERO for the “Go to BETA PITCH below this throttle lever position” and “Go to REVERSE below this throttle lever position,” so X-Plane NEVER goes into beta or reverse when you drag the throttle all the way aft! This way, you can just slap the throttle back to the aft stop to go to idle. This is the way anyone would want to fly the airplane.

Then, to go into beta, hit the / key. To go into reverse, hit the ? key. (And hit again to toggle out). And, while in reverse, you can run the throttle right back up again to go farther into reverse! This way the ergonomics are not like the real airplane, but you can really control what is going on. If you want the ergonomics to be the same as the real plane, then enter the throttle positions as mentioned above… but you better not drag the throttle all the way back in flight, or you will go into beta and then reverse in flight! The REAL plane has a gate at the idle stop to stop this from happening!

In the main screen at right, for the maximum power box, enter the maximum continuous power allowed by the engine. This is the maximum power allowable at sea level (not maximum thermodynamic, which you would never use or you would wreck your gear-box!).

For the prop pitch numbers, the top is the feathered pitch of the blade, as you get with the blue knob all the way back… maybe 60 degrees.

Then the coarse pitch is the maximum the prop can open up in alpha mode… maybe 45 degrees.

The fine pitch is the flattest the prop can go in alpha mode… maybe 10 degrees.

The beta pitch is the flattest the prop can go in beta mode… maybe 0 degrees.

The reverse pitch is the flattest the prop can go in reverse mode… maybe -45 degrees.

So, that is how a real PT-6 works, and how to set it up in X-Plane.

Comments Off on Propeller Beta & Reverse Models

Power of 2 In Art Assets

When developing art assets for X-Plane (specifically, any image file that will be attached to an X-Plane object, facade, or terrain overlay), note that the image must use powers of 2 in its resolution.

This means that an image can have a width or height (in pixels) of:

2 128
4 256
8 512
16 1024
32 2048
64

Images used with objects and facades do not have to be square; a facade image could have a resolution of 512 x 1024, or 1024 x 2048, or 2048 x 512, and so on.

However, images used for polygon overlays (such as orthophotos) have the additional requirement of being square. Thus, orthophotos may have the following resolutions (in pixels):

  • 256 x 256
  • 512 x 512
  • 1024 x 1024
  • 2048 x 2048

The only images that can be used in X-Plane without a power-of-2 size are those used in the 2-D panel/instrument system.

Comments Off on Power of 2 In Art Assets

Art Controls for Aircraft Performance Tuning

This article contains a list (current to X-Plane 10.25r1) of art controls that can be used to analyze the performance of your custom aircraft.

Methodology

Before you attempt to improve the performance of aircraft, you need to understand what aspect of the aircraft is hurting performance.  There are two principles here:

  1. The CPU and GPU work independently; framerate will be limited by whichever of the CPU or GPU is doing more work.  Saving processing power on the processor doing less work will not improve framerate.  (In other words, if the CPU is maxed out, saving GPU time doesn’t help; if the GPU is maxed out, saving CPU time doesn’t help.)
  2. Different aspects of your aircraft will contribute differently to processor load.  It makes sense to focus on the most expensive parts of your aircraft first.  If the flight model uses 5% of the CPU and object drawing uses 50% of CPU, focus on object drawing, not the flight model.

GPU load is heavily affected by which graphics card a user has and rendering settings, you should look at your aircraft on a range of settings and preferably a range of hardware as well.  Users who run on small monitors without HDR are less likely to have GPU performance problems than users running with all rendering settings cranked on older machines with big external monitors.

Think in Milliseconds, not Frames-Per-Second

In order to correctly look at the ‘cost’ of code, look at the number of milliseconds (ms) it takes to render a single frame, not the framerate.  In X-Plane’s “frame times” data output you get two useful pieces of information:

  • “Frame time” is the time to draw the frame in ms.  You can look at the change in this number as you disable features to figure out the cost (in time) to compute each feature.  For example, if your frame time is 30 ms and lowers to 20 ms when you disable your plugin, your plugin is taking 10 ms per frame to do whatever it does.
  • CPU Load – this is a ratio of the frame time that the CPU is busy for.  If the number is near > 0.90 or so then you are probably limited by CPU time.  If the number is lower, the CPU is idle, waiting for the GPU.

For example, when viewing the 747 with spill lights on a very old video card, the CPU load might be 0.31 and the frame time is 0.033.  This means the frame took 33 ms to draw, but the CPU was only busy for 31% of that time (10 ms).  Thus the frame is GPU bound.

If the GPU is not maxed out, X-Plane does not provide a direct way to view its loading; you may be able to use a third party utility for this.

Measuring Cost By Disabling Features

With the above in mind, you can determine the cost of various parts of your aircraft by disabling them and looking at the change in CPU time and CPU loading factors. Features that decrease CPU time or frame time a lot are good candidates for optimization effort.

The list below is a set of art controls that can be used (via DataRefEditor) to disable parts of the work done to draw your aircraft.

Besides these art controls, you can use your own datarefs to remove the attached objects of your aircraft to measure their individual cost.

Art Control List (Current 10.25r1)

perf/disable_cockpit_readback.  This disables per-frame rendering of the panel texture. This saves the time of instruments on the panel texture, GPU overhead, and plugin time in the callbacks for the panel.  If using this improves fps, your panel is too expensive (either due to X-Plane instruments or plugin code.)

perf/kill_click_3d.  This disables per-frame checking of the mouse position against your manipulators.  If setting this improves framerate, you have too many triangles that contain manipulators; use simpler meshes for your manipulators.

perf/kill_cockpit_objects.  This disables all drawing of the airplane from inside the virtual cockpit.  When looking at 3-d cockpit performance, kill the entire 3-d cockpit to get a “baseline” (e.g. how fast the sim is without your airplane at all).  When you kill cockpit objects, the flight model, 3-d clicking, and cockpit readback are still running and must be separately disabled.

perf/kill_fm.  This disables the flight model.  When the sim is unpaused, you’ll see a fps gain as the CPU is freed up.  Usually the gain is quite small; there’s not much you can do to improve flight model CPU time yourself (other than turn down the number of flight model computations per frame in the operations and warnings screen).

perf/kill_instruments.  This disables the drawing of X-Plane’s instruments on the panel texture (or 2-d panel) but does not disable the background or plugin drawing.  You can use this to determine the cost of X-Plane instruments vs. custom nav displays.

perf/kill_panel_bkgnd.  This disables the panel background from drawing; the panel background is usually very cheap.

perf/kill_planes.  This disables the drawing of planes in exterior views.  Use this (with cockpit readback) to determine the speed of the sim without your aircraft.

perf/kill_prefill.  This disables cockpit pre-fill.  When pre-fill is disabled, GPU use goes up (since clouds behind the cockpit must be rendered) and CPU use goes down (because the aircraft objects do not need to be drawn multiple times).  Use this dataref to look at the effficiency trade-off of pre-fill.

 

Comments Off on Art Controls for Aircraft Performance Tuning