Thursday, May 04, 2006

Taking a Detached View

EDIT FROM 2/19/07: during X-Plane 850 when I was developing the new lighting system (particularly used for airports, but also for the rest of scenery) I brought up the subject of "detachment", a internal process by which the X-Plane rendering engine processes lights.

Simply put: detachment is virtually never a factor for scenery authors. Back when I wrote the article, it was possible for an author to make a few special optimizations if he or she knew about detachment. This is no longer true! The sim will correctly optimize all lighting cases as much as possible without any special help from the author.

So....the blog article in its original form follows and may be useful as an insight into how X-Plane works, but as an author, just remember: you don't need to do anything - just make nice OBJs.

I think I've confused just about everybody in the last few days - especially Sergio and Austin - with work on the new lighting system. One reason I'm so scrambled: the internal representation of lights in X-Plane is very different from the commands you can put in an OBJ8 file. So there's a whole set of terms and ideas that are important to how X-Plane works that I shouldn't have mentioned to anyone making OBJ8s because they won't even be part of the file format.

Then there's detachment. I think I can explain it simply like this: detachment is when X-Plane changes the order that lights are drawn inside an OBJ and the LOD ranges in which they are drawn to improve framerate.

X-Plane 840 does not do detachment. X-Plane 850 will probably not do detachment for objects made only with the old lighting commands. But 850 will do detachment for objects that use new (to 850) lighting commands, and this will allow those objects to render very quickly even with textured lights.

This picture is actually from X-Plane 8.03 I believe. It's a simple trick: edit the roads file to add street light objects along all roads. Make a street light object with a light command and then turn roads on and watch teh city at night appear.

The only problem is the frame-rate - this experiment brought 8.03 to a standstill.

The goal of detachment is to make textured lights in objects fast enough that this kind of scene can be rendered at reasonable framerates. I do not know if this will be possible, but detachment should certainly improve performance in cases like this.

2 comments:

flyboyqw said...

Is it a good idea to give each light a seperate texture instead of using one texture and coloring them yellow, red, green, etc? This enables adding a white center in the texture giving it a much brighter appearance. Here is a demo screenshot I made in OpenGL:

http://pilotpage.monosock.org/fileadmin/files/lights.jpg

Benjamin Supnik said...

Yes it is, and that's exactly what 850 will do; Sergio had the same idea. The problem with lights and computers is that the dynamic range of the monitor isn't bright enough to do a good center of the light - a white center compensates. To this end, the new light texture is 1024x1024 with 64 lights on it, to cover all of the combinations. In both the case of our lights and custom lights, this technique can be utilized. Hopefully the RFC for lights and objects will be up in a few days.

BTW the other alternative is HDL - high dynamic-range lighting...under this scheme, X-Plane renders to a special off-screen buffer that can represent ultra-bright and ultra-dark images. When the buffer is transferred to the screen, the ultra-bright colored light centers bleed out as white and potentially also create other lighting effects. We'll get there some day, but only the current generation of video cards can do this on hardware.