Wednesday, March 04, 2009

Back-Lighting For All Instruments

X-Plane 930 beta 4 will be out real soon, and it has a somewhat significant new instrument feature: all instruments (not just generic instruments) can have additive lighting.

But wait - what is additive lighting?  Additive lighting is the basic equation X-Plane uses for "lit" stuff.  Basically it says that the _LIT texture is added to the daytime texture to simulate the effect of an object that reflects sun light and emits its own light.  Here's a more detailed description.

It used to be that the _LIT textures for instrument overlays were used instead of the daytime ones at night.  Generic instruments introduced a new lighting mode, "back-lit", where the LIT texture is added to the daytime texture.  This lets you make an instrument that has a light behind it to illuminate the markings at night.

In particular, when an instrument is back-lit, the amount of LIT texture added in is a function of the instrument light levels (the pilot can turn this up and down) while the amount of day time texture is a function of the sun and spot light shining on the area.

Originally I did not want to extend the legacy instruments to support back-lit lighting.  What finally made me change my mind was the amount of detail in some of the standard mechanical instruments.  As an exercise, I converted the six pack and nav instruments of Max's default Cessna to generic instruments.  

The conversion required a lot of new (and very weird) datarefs, some esoteric extensions to the generic needle instrument, and it lacked some of the finesse of Austin's built-in instruments. All of these problems stem from one limitation: the animation action of generic instruments cannot be nested.

(Of course there is a practical consideration too - for an author with legacy instruments, rebuilding with generics takes time. Typically it took about 4-6 generics to model each built-in instrument in the six pack. The conversion only took me about eight hours, but I have access to the source code of the built-in instruments, a luxury authors would not be able to leverage.)

So in the long term, I am at least investigating the notion of nested animations and movements for generic instruments; I think that this would be the final flexibility needed to model just about anything with generic instruments.

But for the short term, you can back-light your built-in instruments; just set the lighting mode to "additive" and create the LIT textures.


Alejandro Garcia said...

This sounds really promising, Ben. Will this work in 3D pits too?

Benjamin Supnik said...

Yes - they do work in the 3-d pit.

The only feature that isn't available in 3-d (in concert with other new features) is the 2-d spot lights. (Use the 3-d spot lights instead.)

Alejandro Garcia said...

Acording to some of your posts, we can't expect to see this for sceneries right soon, really? If yes, do you have any idea of a framerate loss according to what happens in the cockpits? I talk about adding this to a very small area around the plane, maybe 1 mille around

Benjamin Supnik said...

Alejandro: additive lighting (which is what back-lit instruments are) has been available for scenery since X-Plane 6 - it's the _LIT texture. Or are you referring to the 3-d spot lights? Those aren't available for scenery.