World
Wide Guide | Knowledge Bank |
Kukushkin's Notebook | Basics
of Simulation
FS5 uses texture
[*.R8] files for displaying all bitmaps that appear in the scenery (View
1 & 2 and Map windows). Texture files can have extensions that differ
from ".R8". Texture files are used with scenery [*.BGL] and aircraft [*.AIR]
files.
For example, a scenery that displays a textured ground polygon normally contains two commands for this operation: the first command instructs FS5 to load a specific texture file and the second one instructs FS5 to draw a polygon using the "current" texture. FS5 caches textures in the expanded memory, thus eliminating the need for accessing a disk file each time FS5 needs a specific texture. However, if a scenery attempts to load more textures that can fit into the EMS memory, the caching does not work very well. For such cases, FS5 has a "safety mechanism" that prevents loading more than one texture file per frame. While this mechanism prevents FS5 from a complete stop in case of a memory shortage, constant disk accesses can reduce the frame rate to an unacceptable level.
Each texture file contains an array of 256x256 pixels. If a bigger bitmap has to be displayed, it is split into multiple texture files and each texture is drawn separately. For example, the Meigs airport is displayed using two texture files. Each pixel is represented by a 8-bit value. This value serves as an index into a special table called 'palette'. The palette contains RGB values for 256 possible pixel values. It is used by the display card for converting pixel values into actual colors.
In FS5, palette entries are used as follows:
FS5 stores palettes in palette files [*.PAL]. Each palette file contains 256 RGB values, one for each palette entry. However, FS5 uses only a part of these entries for programming the actual palette. Other palette colors are calculated by FS5 directly. The default palette of FS5 is stored in the file FS5.PAL in the main TEXTURE directory. From this palette file, FS5 uses entries 0-115 and, if the scenery does not use any other palette, entries 192-255. While other entries in this file also reflect the palette FS5 uses, it is only a "coincidence". FS5 ignores them.
The scenery can instruct FS5 to load a custom palette file. From such files, FS5 only uses color entries 192-255. Because the display card can handle only one palette at a time, there is a small chance of a palette conflict between sceneries. Sceneries do an "area check" before loading a palette. The custom palette is loaded and textures drawn only if the viewpoint is inside a certain area. If such areas of two sceneries intersect, some textures may have incorrect colors.
Haze drivers of FS5.1 also require an accompanying haze file [*.HAZ] for each palette file. A haze file contains an array of 16x256 pixel values, 16 substitution values for each pixel value. When FS5 draws objects, it replaces each pixel with one of its substitution values according to the distance. Thus, the first substitution value is normally the original pixel value itself, and the last value represents a gray color. In most horizontal textured polygons, the intensity of the haze effect varies according to the distance to individual pixels. In all other primitives, it is determined by the distance to the reference point and does not vary inside the primitive. This often causes non-textured roads and rivers to 'show' through the haze when their reference points come close to the viewpoint.
Unlike custom palette files, FS5 always uses the entire haze file loaded together with a custom palette. The reason for this is that the default haze file FS5.HAZ contains some substitution values above 192. Because colors above 192 are redefined by the custom palette, a completely new substitution table is needed. Also, substitutions are ALWAYS performed in view windows -- even in the Map View. This theoretically allows the creation of very interesting palette effects by manipulating haze files. For example, it is possible to "remap" some pixel values to non-fading colors during certain periods of time, to change the sky color, etc. Note that such effects are only available when using haze drivers.
When displaying textures, FS5 sometimes uses a technique it calls 'image smoothing' to quasi-increase the resolution of the texture. The resolution in both directions is increased 4 times, and colors of additional pixels are obtained using interpolation. This creates an illusion of a smooth transition between texture pixels. Interpolated colors are displayed by mixing neighboring texture pixels in different proportions. For this reason, image smoothed textures appear to be a bit blurred. Image smoothing works only if the Image Smoothing check box in the Options/Preferences/Display/Scenery dialog is enabled. Also, the scenery must contain a command that enables image smoothing for texture mapping operations.