MS Default "Pink" FX Emissive Texture Lightmapping
(Click on Picture for full size image)
One of my pet peeves in most models being released lately is the poor panel lighting in the Virtual Cockpit. Now, I do realize that up until about a year ago, very few modelers knew how to create beautiful and cool panel lighting on their models, and those few weren't willing to "share" their techniques. Fair enough, I respect those who want to keep their "competitive edge" and don't begrudge them their hard efforts and desire to be unique! :)
However, after several months of hard work, lots of trial-and-error, and a few "hint's" from fellow modelers in the AVSIM.COM "Aircraft and Panel Design Forum," I've perfected a technique which I feel provides the absolute best gauge backlighting in the VC that is currently possible, and is fully compliant with Microsoft's SDK. Over the next few pages I'll step through the process in detail, and I promise you that if you follow this "formula" exactly, you too will be able to produce absolutely stunning VC lighting!
At the time of this writing, this technique will only work with GMax models. I'm working with Louis Sinclair (the author of FSDS2) to extend this wonderful technique to the FSDS2 modeling program.
Also, please note that this technique means that the VC gauge backlighting is tied to the landing lights electrical circuit. Therefore, they will only be on when the landing lights are on! According to the SDK, adding an alpha channel to the lightmask image and using a "white" alpha should move the effect to the "running lights" (Nav lights)... However, I've never been able to get this to work reliably across all sytem platforms & video cards. Therefore, some additional 'fudging' might be needed to move control of the actual landing lights to another circuit. For the Socata, I simply tagged the part in GMax to only be "on" when the gear is extended.
-BEFORE WE BEGIN-
It is crucial that you decide early in the modeling process what you want to achieve with your panel and aircraft, because unless you do, you may wind up having to redo major portions of your model to recognize your goals. One of my primary goals has been to make the transition from the 2d panel to the 3d panel as "seamless" as possible. To that end, I've determined that the best way to accomplish that goal is to BUILD THE VC COCKPIT FIRST! Now, this may seem to some to be a bit backwards, but bear with me while I explain the rationale behind this thought process.
Many 2d panel designs suffer from what I call "skewed perspective," that is they do not accurately reflect what the pilot will normally see in his/her field of vision while seated and facing forward through the windscreen. To minimize this design flaw, building the VC first will allow you to move the "camera" into position and snap a "picture" of the VC from the proper perspective! This will give you a "template" from which you can then develop the actual 2d panel. Obviously, there will be a bit of give-and-take involved during this process, and compromises may need to be made, but the end result will be worthwhile.
So, without further ado, let us proceed to build a simple VC panel, using my Socata TB20GT as an example. I'm only going to detail the actual construction of the VC gauge panel for the pilot's side (P1), because all the other ones are done the same way. If you can successfully complete this tutorial, the same steps will allow you to complete the rest of your project! :)
-STEP ONE: "STRATEGIC PLANNING"-
Decide how you are going to lay out your cockpit, and how you are going to "sub-divide" your VC cockpit's gauge displays. Simple aircraft, such as a small Cessna or Piper, have one, relatively flat panel, and are fairly easy to lay out. Here is a picture of how I determined the sub-panel layout for the Socata TB20GT:
Note that I have separated the entire VC into eight separate sub-panels, as illustrated above. We are going to work on developing the P1 panel only, but I wanted to show how pre-planning your strategy can make your job flow smoother, and with fewer mistakes! :)
-STEP TWO: "BUILDING THE P1 PROJECTION SCREEN"
Let's load up GMax and create a small polygon for our P1 "projection screen." FS2k2 has a special way to display gauges in the VC that depend on us providing a planar surface on which to apply a texture name... that's right, just a special texture name! The $ prefix is reserved in FS2k2 to signal the sim to auto-generate a transparent (0,0,0) texture dynamically at runtime.
It is important to mention that the shape of the gauge planar does not have to be any particular shape or size. What is crucial however, is that the texture applied to the part be perfectly square, always 8 bit, and always in a "power of two;" i.e. 256x256, 512,512, 1024x1024, and so forth. Failure to adhere to this will result in endless frustration! Early on I spent a full week in panic mode because I failed to notice that my texture was 512x511 pixels... :(
The chief "problem" that occurs with this method is that when the lights are on, the entire surface of the gauge poly loses transparency and becomes "black." The simple fix for this problem is OBVIOUS in retrospect: where there is no surface, there is no black showing! :)
There are several ways to overcome this problem, and this an excellent example of why you need to keep this in mind during the "Strategic Planning" part of VC development:
1) apply a base texture to the poly via the panel.cfg
entry (explained below)
2) make the gauge poly the exact size and shape of the actual gauge being used (note the compass polygon)
3) move the gauge poly behind the physical panel
To eliminate confusion, throughout the process I've chosen to use a consistent filenaming convention. Note that I've named the polygon "P1_screen," and that every texture will use the same "P1" for the root of the name.
Next, apply a "UVW Mapping" to the polygon. Note that although the polygon is rectangular, the UVW Map is square! (Note: I've zoomed the rollout in this picture for clarity...)
-STEP THREE: "CREATING & APPLYING TEXTURES"
Next, create a square texture 256x256 pixels in your paint program and name it $P1.bmp It must be only an 8 bit image, and may actually be any color you want. I prefer black, but usually label the texture with the name in red to make it easier to identify in GMax, and also to make sure that the orientation is correct! :)
256x256, 8bit, Indexed Color .BMP file
While in your paint program, you may as well create the basic "lightmask" at the same time. Simply spray paint the entire image white or gray, and label it as before. We'll be reworking this at a later time, but for now this will do fine. As with the $dummy.bmp file, we simply need something with a filename that we can assign in GMax's Material Editor! Note that the filename is the same, but the $ prefix has been omitted, and the _L suffix added. This is crucial to success!
256x256, 8bit, Indexed Color .BMP file
Now, back in GMax, use the Material Editor to create a new "material," and select the $P1.bmp for the Diffuse Color slot.
Now, pay attention closely, because here
is revealed the "secret" to VC gauge backlighting!!! (Finally, you sigh!)
Apply the P1_L.BMP texture in the Material Editor, in the "Self-Illumination" slot! Leave the "Amount" for the P1_L.BMP set at 100, because we will be editing this texture later anyway, so we can set our desired lighting levels at that time.
Here is a screenshot of the same thing with the rest of the VC "parts" showing... Notice that the "projection panel poly" is sized to fit inside the beveled housing created for the cockpit panel assembly. Note also that the other VC sub-panels have already been textured with their respective $dummy.bmp files.
Now, let's compile our .mdl using only the single panel that we've created, and check it out in FS2k2! In order to see it though, you will need to set up a complete "dummy aircraft" in FS2k2, unless you've already got one that you're working on. It is beyond the scope of this tutorial to cover all the details of how to do that; and besides, presumably you already know how! :)
NOTE: If you are using "MiddleMan," be sure you check off the box labeled "Use Lightmaps," and NOT the one labeled "Use Nightmaps!" "Nightmaps" are seldom used on anything except static .bgl models; checking this box WILL cause your VC panel to disappear! :(
-STEP FOUR: "SETTING UP THE PANEL.CFG FILE"
What may be new though is the [Vcockpitxx] section of the panel.cfg file. Here is a short example:
size_mm=512,512 <---Even though we created a 256x256 texture, we can use 512x512 here!
pixel_size=1024,1024 <---I've used 1024x1024 here for higher resolution gauges!
texture=$P1 <---This tells FS2k2 to generate a dummy texture of size 1024x1024
gauge02=mooney_bravo!Turn Coordinator, 80,154,111,111
I use FS Panel Studio to create/edit panels. Although it will allow you to "edit" a VC panel, it will not allow you to create one! Consequently, you must first "hand edit" your panel.cfg in notepad/wordpad to create the necessary [Vcockpitxx] entry. You do not need to specify any gauges at this time, but only the "header information" that's in bold type above.
Now, having place some gauges on the VC panel, let's fire up FS2k2 and have a look!
Oops! We have a problem! Gauges are just "hanging in space!" :( We need to provide a background for these gauges! Now, there are several ways to do this, but rather than go into all of the various methods, let's use one which I've determined to be the BEST way to do this. The chief reasons why I use this particular method is because whenever the lights are turned on, that nice, transparent polygon will turn a very UGLY, solid BLACK in the sim, and - almost as important - we can use another "trick" later to provide some additional cool lighting effects on the background texture we're going to apply.
Let's modify our panel.cfg to include the following line shown in red. This is a simple texture that will provide a "cover" for the transparent gauge poly, and will mask the UGLY BLACK that would otherwise mar our splendid panel!:
gauge02=mooney_bravo!Turn Coordinator, 80,154,111,111
This is a view of the background image in Photoshop. Note that the image size is precisely 512x512 in size. FS2k2 will automatically scale the image for you, so you don't have to generate HUGE texture files to achive good results!
Here is what the VC looks like in FS2k2 now that we've applied a background texture. Wow! What a difference!:
-STEP FIVE: "LIGHTING UP THE PANEL!"
At last, we're finally at the point where we're going to "light up the panel!" Place the P1_L.BMP file in your test aircraft's \texture folder (yes, I said \texture folder, not the \panel folder!!!), and fire up FS2k2 at night. You should see this:
Well crap! It's lighted alright, but what the heck, the whole panel is lighted!!! Why, even the red label is upside down and backwards!!!
You made me read this stupid tutorial just to see this!!! <grrr!>
-STEP SIX: "DON'T PANIC! WE CAN FIX THIS!"
As you can see, we could have achived this by simply using the "emissive color properties" of GMax without all the fol-de-rol of creating a special "lightmask" texture. However, I've done it this way to illustrate a MAJOR POINT: i.e., that FS2k2 inverts the P1_L.bmp file and turns it "inside out!" So, knowing that, the following procedure will make more sense... :)
Let's load up the panel in trusty FS Panel Studio and snap a "picture" of our basic panel, so we can use it as a "template" in our paint program on which to do our "magic." While the Vcockpit01 is displayed in FSPS, make sure that the "black background" is full screen, and press the PrintScreen key to capture the image.
Crop the image to an exact square, and size to 256x256 pixels. Create a new "layer" in which to apply the white/grey highlighting, where you wish to illuminate the gauges. Notice that by using this method, you can precisely specify how much light to allow, and even apply graduated shading to achieve a "realistic, unevening lighting" effect that real gauges have! Notice how I used "pure white" on the clock, HSI and Attitude Indicators, since these are normally quite brightly lighted. The other gauges are "whiter" towards the outer edges, which is typical of rim mounted, backlighted gauges. If you wish to create a "Post Lighting" effect, simply use a "fanned spray" lightmask. Adobe Photoshop has some really cool "lighting effects" in the Filter section, but you may have to fudge up your own method depending on your paint program:
The next step is to erase the background image, leaving only the highlighted areas on a pure black (0,0,0) background. Rotate the image 180º and then flip it horzontially, then save it as an 8bit Indexed .bmp file:
-STEP SEVEN: "THE MAGIC MOMENT!"
If you have followed this tutorial faithfully so far,
you should now see the following in FS2k2 when you load up your test aircraft's
Well! Doesn't that look great! Hmmm... the gauges are nicely backlighted, but the PANEL is very, very dark...
-STEP EIGHT: "ICING THE CAKE!"
Let's load the P1_L.bmp file back into our paint program and add a gentle "floodlight" to the lightmask! Since Photoshop won't allow me to add a light effect filter to a transparent background, I converted the image back to RGB (24bit), moved the previously highlighted areas to a new layer, 'painted' the background pure white, and then applied my Render/Lights/Filter, using a soft omni effect with the point source located under the glareshield (to simulate a soft flourescent light source). Merging the two layers back together and converting back to 8bit, Indexed Color produced the following results in FS2k2:
Here again is the complete VC panel for the Socata TB20GT (please excuse the "old" picture, but this was before I added the "gentle lighting effect" outlined above, and I'm too tired to redo the picture!):
I hope that this little tutorial will prove helpful to any modeler who wants to add that "something special" to their project. Is there more that could be done? Absolutely! You are limited only by time, energy and imagination... :)
Is this better than using that nasty, old fx lighting method? I'll leave that to you to decide. I think that it's worth the time and effort to make the VC environment as well-lighted as possible, and to that end I've taken the time to write this tutorial.
There are many, many other "tricks" that may be used, such as the internal lighting of the gauges themselves, but I'll leave that for a future tutorial! Stay tuned, and have fun!
Fr. Bill Leaming, SSG