I have found the cause of a rather serious bug in Plane-Maker: sometimes instruments disappear from the hierarchy (but are still visible in the main window).
The problem is that the cut-paste facility, when used with multiple-instrument selections, was corrupting the hierarchy information. Because of the way instrument hierarchies are managed, this corruption persists – even if it isn’t visible. So if you manage to ungroup everything, it looks okay until you work more, then the instruments disappear again!
This is a really bad bug of mine, particularly since a panel is such a time investment. Here is what we’ll be able to do in 930 to get around this:
- A new “flatten panel” command simply ungroups everything and completely cleans the hierarchy. All corruption of hierarchy is fixed with this command, finally exposing every instrument. From that point on, you can then re-group and things should be okay.
- I am fixing the cut-paste commands to not trash the hierarchy, and I am looking for any more hierarchy-corruption problems.
- 930 has export/import of instrument groups to text files. So another way around instrument corruption problems would be to export the panel to a text file, fix the grouping problems (which is a matter of moving the GROUP/END_GROUP lines) and then re-importing. If you do not have a selection, the entire panel is exported, including any hidden items in the hierarchy.
I believe that text-based panel import/export will also be useful for sharing individual instruments (or clusters of grouped generic instruments), archiving work, and making large-scale changes using search-and-replace.
These two issues have been discussed a lot in the forums, so I thought I’d mention them:
First, I finally found and nuked that star-burst pattern in the rain. It turns out that for some textures, compression was destroying the lower res
mip-maps, causing the geometry that the rain drops are drawn on to show up as that starburst pattern. It should be fixed for 930 beta 1.
Second, it turns out that the code that converts the 900-format generic instruments to 920-format generic instruments* was being run on the user’s airplane whenever a multiplayer airplane older than version 920 was being run. That could cause generic instruments to disappear, appear incorrectly, or just crash the sim, because the aircraft data in the user’s plane (once the user is flying) is already in 920 format…if you interpret it as 900 format again, you get non-sense.
I am fixing this for 930 beta 1; there may be other bugs relating to multiplayer and generics, so we’ll see if this fixes most of the problems, or others crop up. The panel system is essentially “global” (that is, there is one panel for the user in all of x-plane) but the instrument data is per-plane…so there is always a risk of code mistakes where the multiplayer planes affect the user’s panel.
When will 930 beta 1 be out? I don’t know. Hopefully pretty soon – when bug fixes make it into the blog, we’re usually in the push to get to beta. But I’m working on features on a few fronts, so it’s hard to say which ones will be done first.
* X-Plane 920 revised the ACF format from version 900. The file format for generic instruments was pretty much completely changed to accommodate new features like key frames. 920 has code that converts the 900 generic instruments into 920. For example, simple key frame tables are built out of the older offset-scale parameters per instrument.
I have recently started leaving pieces of email and notes on the Wiki. To see this mess, just view Category:Unfinished.
The problem is that often I don’t know what people don’t know but want to know. So when I get an email question whose answer is not already posted somewhere, I make a wiki page and dump the info.
This
stub is in response to some work I did this morning. In particular, lights in X-Plane often have visibility much larger than the objects they come with. This used to be true for the cars, but I broke the code in 921 and didn’t notice. In 921 headlights do persist beyond the car object’s visibility distance, but not by much. 930 will fix this, restoring the “string of lights” look on the roads at night.
I’ve also tuned the headlights to be visible from a wider viewing angle, to try to make them more noticeable from above. (In real life, the lights illuminate an area of the pavement, which is visible, but we don’t do this.)
If there is a scenery subject that is poorly or not-at-all documented, shoot me an email and I’ll stub out a Wiki page – it’s a first step to getting comprehensive documentation.
(Note that I have not added pages for tutorial steps like “how do I add a manipulator to my object” because I am doing the tools work for ac3d now … better to write a tutorial for manipulators the easy way with ac3d than to write one on the hard way – editing the OBJ – and changing it later. That is to say, I am trying to documetn tools, not temporary work-arounds!)
As of X-Plane 9, life was simple: ATTR_cockpit and ATTR_cockpit_region caused your triangles to be textured by the panel, and they could be clicked. ATTR_no_cockpit went back to regular texture and no clicking.
Well, it turns out that secretly ATTR_cockpit was two attributes jammed into one:
- Panel texture – that is, changing the texture from the object texture to the panel texture.
- Panel clickability – that is, mouse clicks are sent to the 2-d panel and act on those instruments.
With X-Plane 920 and the manipulator commands, this “clickability” aspect is revealed as a separate attribute, e.g. ATTR_manip_none sets no clickability, and ATTR_manip_command makes a command be run when the triangle is clicked. These attributes can be applied to any kind of texture – panel texture or object texture.
So how does ATTR_cockpit work in this context? Basically you can think of ATTR_cockpit as two “hidden” attributes:
ATTR_texture_panel
ATTR_manip_panel
and similarly, ATTR_no_cockpit is likeATTR_texture_object
ATTR_manip_none
With this you can actually get any number of combinations of attributes, but the code is sometimes unexpected. In particular: if you want a manipulator other than the panel or none, you have to specify it again. Example:# set command manip
ATTR_manip_command hand sim/operation/pause Pause
TRIS 0 3
ATTR_cockpit
# we now have to reset the cmd manipulator!
ATTR_manip_command hand sim/operation/pause Pause
TRIS 3 3
ATTR_no_cockpit
# we have to reset the cmd manipulator again!
ATTR_manip_command hand sim/operation/pause Pause
TRIS 6 3
Similarly, if you want the panel manipulator, you may have to reset the cockpit!ATTR_cockpit
TRIS 0 3
# now make the mesh not clickable
ATTR_manip_none
TRIS 3 3
# Mesh clickable again
ATTR_cockpit
TRIS 6 3
The good news is: this isn’t nearly as wasteful as it seems. X-Plane’s object attribute optimizer is smart enough that it will remove the unnecessary attributes in both cases. In the first one, what you end up with is one manipulator change (to the command manipulator), and the panel texture change is done without changing manipulator state at all. In the second case, you end up with the manipulator change, but the panel texture is kept loaded the whole time.
In other words, even though the double-attributes or duplicate attrbibutes might seem to be inefficient, the optimizer will fix them for you.
One reason you might care: the cost of panel texture is one-time – that is, you pay for the size of the panel texture once per frame. But the cost of manipulatable triangles is per-triangle! So having more is bad. With ATTR_manip_none, you can use the panel texture but not have it be clickable, which can be a big performance win.
930 will handle manipulatable triangles a lot faster than 920 — but that’s still not a good reason to have all of your triangles be clickable!
This article is still
unfinished, but I am trying to put together some info on how to detect performance problems like too many clickable triangles.
X-Plane 910 was an update to X-Plane 9 for our professional customers. But all of the new features that they got in 910, everyone got in 920. Here’s how it happened:
X-Plane 9 had a very long beta, and the end of that beta was mostly spent with a finished sim and me trying to fix the pixel shaders for five thousand flavors of video card, driver, and operating system. During this time, Austin started work on new systems modeling features for professional level sims. We branched the code, with my work going into 900 and his going into 910.
When he finished his systems code and I got the pixel shaders fixed and both were fixed, the two were combined into what became 920.
So that’s how we “lost” the 910 version number – some professional customers have the version number, but everyone got the features.
There are two ways to make 3-d instruments in your 3-d cockpit:
- Create 2-d instruments on a panel and use the “panel texture” (ATTR_cockpit or ATTR_cockpit_region in your OBJ) to show those 2-d instruments in the 3-d cockpit.
- Model the instruments in 3-d using animation.
So…which gives better framerate? Well, it turns out that they are actually almost the same…a few details:
- If your card can’t directly render-to-texture, there is an extra step for the panel texture. But that would be a weird case – all modern cards can render directly to textures unless you have hosed drivers.
- For very small amounts of geometry, there’s pretty much no difference between rotating a needle using the CPU and telling the GPU to do it by changing the coordinate system.
- The panel texture does put pressure on VRAM – if you’ve had to go to a 2048×2048 panel texture to have enough space, it’s going to hurt you.
Both approaches are actually quite inefficient – you get best vertex throughput on the card when you have at least 100 vertices per batch. But if a panel has 800 batches, you don’t necessarily want to do this – you’d pick up 80,000 vertices just trying to “utilize” the graphics card. That’s not a huge number, but it’s big enough to consider. Panels have enough moving parts that they’re going to push the CPU more than the GPU.
A number of authors like the 3-d approach because they are more comfortable with 3-d tools, and because it can look sharper (since there is no intermediate limiting texture resolution).
There is only one case where I would advise against the 3-d approach: if it takes a huge number of animation commands to accomplish what can be done in one generic, use the panel texture; the generic instruments are all coded cleanly and none of them take that much CPU power. But some of them produce effects that would be relatively difficult to reproduce with animation.
The X-Plane export plugin for AC3D doesn’t handle panel textures very well. The current plugin tries to identify cases where you have used your panel background as a texture – this queues it to generate ATTR_cockpit. This scheme has a number of problems:
- The search paths for the panel background are not up-to-date. The plugin doesn’t know about the new naming conventions or the cockpit_3d folder.
- The scheme doesn’t address panel regions at all – there is some support for them but it doesn’t work well.
- Most important: panel editing is not WYSIWYG. Since you are using the panel background as your texture, you can’t actually see where all the moving parts are! Doh!
That last point is perhaps the most important one, and it is why, for the next version of the plugin, I am introducing panel previews.
Basically a panel preview is a screenshot of your panel with the instruments on it, sitting in your cockpit_3d/-PANELS- folder. AC3D will recognize and use the panel preview when possible. This will solve problems (1) and (3) – there will be only one naming convention for previews, and they will be screenshots of the panel in action, so you can texture with a preview of the instruments.
Plane-Maker 930 will contain a facility to generate panel previews; if you are using X-Plane 920, you can generate the preview manually by taking a screenshot in X-Plane.
For panel regions, we will have one preview file for each region (e.g. Panel_preview0.png, panel_preview1.png). This addresses issue 2 – usage of the region previews will invoke ATTR_cockpit_region.
Finally, I am moving the panel sub-region information from the preferences to the .ac file (hopefully) so that it will be saved with your plane.
Hopefully this will make a work-flow which is much simpler. To make a 3-d cockpit you will simply pick “generate previews” in Plane-Maker, and then start using the previews as textures.
I really like what he’s done with the new page – see it for yourself here!
In a previous post I ranted about the hidden cost of adding new third-party-accessible features to X-Plane – that cost being the cost of supporting the APIs way into the future so that third party content doesn’t break.
Even trickier are accidental contracts – that is, unintentional behaviors that the sim exposes that third parties take advantage of. This can be particularly tricky for us because we might not even realize that the behaviors are happening.
In 921 we allowed the HUD to be visible in the 3-d cockpit for planes that use our “default” 3-d cockpit, like the 777. Ignoring that this was a truly silly feature to do, one of the side effects of the code change was that EFIS glass instruments now render correctly over transparent parts of the panel texture on some hardware. Javier immediately jumpedon this to build a 3-d HUD.
These EFIS glass instruments appearing in that region was totally unintentional, and this is about the last way I wanted to implement 3-d HUDs, but now that it’s in there, I have to ask: do I want to break Javier’s airplane, which a lot of users will like? Probably not!
Another accidental contract is the draw order of the cockpit objects. Basically due to a coincidence of how the code is structured, the external cockpit object is drawn before attached objects, but the internal cockpit object is drawn after. There is no good reason for this, but now that authors build airplanes based on this, we have to preserve it because changing draw order can break translucent geometry.
X-Plane is full of this kind of thing – and all of these hidden conventions make it tricky to restructure subsections of the code.
Sometimes you have to break a few eggs to make an omlette. Or at least, you have to consider whether breaking them is acceptable. Often I hit cases where the cost of supporting a legacy feature is somewhat painful.
One way to decide what to do is to change the feature early in beta, see who squawks, and then change it back if necessary. There are two I am looking at for 930.
Glass Instruments
It turns out that glass instruments fade to black, not to transparency. This is a little bit weird, because that means they will leave black footprints if they are on top of a non-black background. My guess is that most people use them on black screens and thus did not notice.
If people really need fade-to-black glass instruments, I’ll just create a new lighting type (glass-transparent), but if everyone can live with fading to transparent, it’s certainly the more useful case and probably what most people always wanted.
Separate Specular Hilights
For as long as I’ve been involved, X-Plane’s specular hilights are modulated by the object or airplane texture color. In other words, if you paint your airplane red, you get red hilights, and if you paint it black, you get no hilights at all.
This is not a very good way to do things for a few reasons:
- Under this scheme, you can’t make a shiny black object.
- Someday we will add gloss maps – but the glossy part of the gloss map will be defeated by the black texture.
So for 930, I am looking at not modulating specular hilights by texture. (This is called “separate specular hilights” in OpenGL lingo.) My guess is that they will look enough better in almost every case that people would rather have it this way.
Should specular hilights be white for a black object? Yes! A specular hilight is a simulated intense reflection from a very far away, very bright object (the sun). So it should take its color from the sun, not the object itself. To this end, I have also (finally) set the specular hilights to take on the daylight sun color, so that they get fainter and yellowish at dusk. This makes dusk and dawn look a little bit less strange.
(Nerd note: Technically, for the day texture to be an albedo texture, it shouldn’t affect specular hilights.)