World Wide Guide | Knowledge BankKukushkin's Notebook | Design Fundamentals


Creating night effects

One of the challenges during scenery design is creating night effects. By default, the scenery in FS5 fades to black when the darkness comes. This is very realistic for wild areas. In populated areas, however, many objects remain visible during the night. Not only do they remain visible, but their appearance often drastically changes because of the different type of illumination. Also, many sources of light appear that are invisible during the day, like streetlights.

FS5 creates some night effects itself by providing night illumination for high-level objects like runways, roads, taxiways and default buildings (the realism of the latter is a question of taste). Also, many urban textures used to display synth scenery contain pixels that remain lit at night. While the intentions behind these pixels were good, they flicker when viewed from distance and look very unrealistic.

Sceneries should include night effects

These night effects are not sufficient for a good day/night scenery. Thus, the scenery should take care of other night effects itself.

The easiest way of defining an object that remains visible at night is to use a color that remains lit.

This is sufficient for some light sources, like runway end lights. The main requirement for such light sources is to have exactly the same behaviour during the day and night.

However, the purpose of most light sources is to lighten up the ground during dark hours, so they do not meet this requirement. Light-reflecting objects also do not come in question, because almost all constant colors do not change their intensity during the daytime, thus producing a very unrealistic look.

An exception is the color 16 F0. During the daytime, it acts as a regular fading color. However, it remains lit during dark hours. Thus, it can be used for 3-D objects that appear in a good quality during the day and remain visible at night. However, only completely white objects can be implemented this way and even they look unrealistic at night.

All this means it is impossible to make a good day/night scenery by simply choosing the right colors. The scenery must check the time of day and change the way it is displayed accordingly.

Checking for time of day

The time of day can be determined by testing the variable 028C [FSASM: vTimeOfDay]. This variable can have 3 possible values: 1 means day, 2 means either dusk or dawn (there is no way to distinguish between these two), 4 means night. A typical code for testing this variable looks like this:

SurfaceColor( .. .. ) ; Set daytime color
IfVarAnd( :Draw_it 028C 6 ) ; Jump if neither dusk/dawn nor night
SurfaceColor( .. .. ) ; Either dusk/dawn or night -> set the night color
:Draw_it ; Draw the surface using the color selected

It is very convenient that different bits are used to identify different times of day. This allows testing multiple bits in one IfVarAnd() instruction. IfVarAnd() performs a bitwise AND between its argument and the value of the variable specified. It then performs the jump if the result is equal 0.

Most nighttime light sources look like dots from a remote distance. Because it is very unlikely that the aircraft gets very close to one of them, they are normally drawn as dots regardless of the distance.

Dots and DotLines

Single dots can be drawn using Dot() or DotPt() instructions. Much cheaper in terms of execution speed and code size is the DotLine() instruction. It allows drawing multiple dots in a row. A DotLine() that draws 25 dots requires 40% less time for each dot and has 90% less code size than 25 consecutive Dot() instructions. Cities from above look like LOTS of lights at night. Lights on big roads are required, but not sufficient for a realistic night view. For this reason, a good urban day/night scenery should have many light sources, best implemented using DotLine()s, that appear only at night. Drawing dotted lines is very cheap in terms of processing time, so many night lights would not decrease the frame rate significantly. Not all night lights are orange, other non-fading colors can be used as well.

Other considerations for night effects

Surfaces visible at night can be displayed either using non-fading solid colors or a texture made of non-fading pixels. Using the dithering technique described in "How to select colors", it is possible to simulate more solid colors than actually available. However, texture bitmaps should never be dithered, because dithered textures appear in a very bad quality when displayed in 3D.

One should be careful when using textures to implement night effects. Because of the way texture mapping is performed, a "flickering" effects can occur. So textures used for night effects should either contain (almost) only non-fading pixels, or be displayed at a big scale factor so that each pixel would be guaranteed to be visible.

Also, palette entries used for the instrument panel should not be used. While they normally appear as different grades of orange, they turn back into black when instrument lights are disabled. The appearance of the scenery should normally not depend from the instrument lights status.


Last updated 11 October 1996 by Gene Kraybill.