I finally finished up an update to the OBJ8 specification, as well as the forest specification – see here for the documents. These specifications are mostly of interest only to developers who are working on scenery exporters.
The OBJ specification is very thick – here are some of the hilights of what’s new.
Global Lighting
In X-Plane 10, you create global spill lights by attaching a light to an object. (Thus, spill can come from any object-bearing part of the sim – an airplane, custom scenery, etc.)
One way to do this is with the existing named and parameterized lights – these features existed in version 9, but in version 10 there are some spill lights added to the light list.
What may be of more interest to custom authors is the new LIGHT_SPILL_CUSTOM command. This lets you build a completely customized spill light. You control its size, color, shape and direction. You can even optionally run the light through a dataref, giving a plugin custom control of the light.
Draping
In X-Plane 10, an object can contain geometry that is “draped” on the ground – that is, X-plane will subdivide, bend and modify part of your object mesh so it sits perfectly on the ground even if the ground is sloped. ATTR_draped makes this happen.
This feature is a much better alternative to using ATTR_poly_os to make marks on the ground. Draping produces objects with better performance, and the geometry always sits on the ground with no artifacts.
As an added bonus, you can optionally use a second, different texture for the draped part of your object from your regular object. (Internally the draped geometry actually becomes something like a .pol file – this is why it can have its own texture.)
Draped geometry makes it much easier to make airport markings. If you want a parking spot, simply draw it on a quad, make it draped, and drop it into place with WED. Tom uses this heavily in our airport library.
Draped geometry also makes it easier to have ground markings that match the object they come with. For example, if you want a house and the house comes with a driveway texture, you can make the driveway texture a draped quad and when you place the object, the draped driveway is always in the right place.
Global Attributes and Instancing
In X-Plane 10, it is possible to set a few key attributes (blending and shininess, among others) globally for the entire OBJ, rather than using an ATTR_ to change part of the object.
These global attributes make hardware instancing possible. In hardware instancing, X-Plane draws many objects with a single instruction to the CPU. In order for this to happen, X-Plane must be able to draw the entire object without needing CPU intervention mid-object. This means an instanced object has to be free of animation, attributes, and a few other features.
The global attributes let you set things like shininess and still have a single-call draw object, ready for instancing. Alex uses these heavily in the urban autogen, and it really helps performance.
My fear is that global attributes are going to be a source of confusion for authors. When should you use them? How do you add them? This is my thinking:
Modeling program exporters should allow an author to identify an object as “for instancing” or not.
Authors should check “for instancing” for any object that is heavily repeated. (A car or a single tree or a static airplane, for example.)
The modeling program can then try to prefer global attributes for instancing objects but not for regular ones, which should come very close to optimal behavior.
Conditionals
Conditionals are simple logic statements that include or ignore parts of an art file based on the rendering settings. In particular, they let you change an OBJ based on whether HDR is on or shadows are on. For example:
IF GLOBAL_LIGHTING
TEXTURE_LIT my_airplane_hdr_LIT.png
ELSE
TEXTURE_LIT my_airplane_LIT.png
ENDIF
In this example, which LIT texture the OBJ uses will depend on HDR.
Because the conditionals can be used anywhere in the OBJ, you can change any aspect of the OBJ to customize for HDR. You can replace a texture, remove lights, add more geometry, etc.
I don’t know how heavily people will use conditionals, but they give authors the option to make one file tuned for both HDR and non-HDR, shadows and non-shadows.
I think the two most common uses of conditionals will be:
Providing alternative LIT textures when HDR is on or off. Note that only one texture is ever loaded (when the HDR rendering setting is changed, X-Plane unloads one and reloads the other) so this does not increase VRAM.
Removing drop shadows that are baked into a model when shadows are on.
That second case would look like:
IF NOT GLOBAL_SHADOWS
ATTR_draped
# This is the shadow geometry
TRIS 300 6
ATTR_no_draped
ENDIF
When global shadowing is turned on, the entire set of draped geometry disappears, removing baked vs. real shaodw conflicts.
X-Plane 10.04 went final yesterday – as always there’s one bug that gets by you. In our case, “solid” cockpits (cockpits that constrain the camera so you can’t move through walls) are inoperative.
At this point it looks like we will do a tiny micro-patch to make 10.05 that fixes this and puts some new strings into the app. Honestly if we didn’t have string changes, I’d probably wait for the next real patch for the cockpit fix, but I believe that it is a low risk change if we must cut the app anyway. The main goal of 10.05 is to get the language just right in some of the dialog boxes for the next set of DVD masters.
The amount of change from 10.04 to 10.05 will be very tiny – comparable to 10.04 rc2 to 10.04 rc3 – literally one or two lines of code changed total.
In the meantime we are working in parallel on the next big patch.
Work on 64 bits is underway – I do not believe it will be available in the next big patch, and we have not specified any date (soon or far away). Simply put, I am staying out of the business of release dates for work like this. Our internal estimates have huge margins of error, due to the many unknowns of the process, and I don’t think we make anyone happy by saying when the feature will be available and then being wrong.
Who Will Use 64 Bits
When X-Plane or the installer checks for updates, it sends an identifier (called a “user agent”) to the server. This is a standard part of HTTP and all web browsers and web-communicating programs do this; our servers (we use Apache, like most of the universe) keep a log of the “user agents” calling in, which can tell you what web browsers and other programs are requesting web pages.
Here is an example of two user agent strings from a real access to our web page:
Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:10.0.2) Gecko/20100101 Firefox/10.0.2
As you can see, Safari and Firefox are both identifying what version they are and what operating system they are running on. This means the website owner can tell how many people are viewing with older browsers or tablets/mobile phones, and optimize the layout of the site accordingly.
Here’s what X-Plane looks like when it calls up our web server:
X-Plane 10.04r3-3-IBM6.1_64
For as long as we have had auto-check-for-update, X-Plane has include the operating system in its user agent string, just like web browsers do. This means that we can tell the approximate operating system split by looking at the user agent strings on the server.
With X-Plane 10.04 we have moved to the more complete string you see above – in particular, it includes whether the version of Windows is a 32 or 64 bit edition. (The above string comes from Windows 7 64-bit. Why Windows 7 is versioned 6.1 is beyond me. The extra “3” is an indication that the user has a full global edition of the sim – this is a paying user running on Windows 7 64-bit.
So I can tell you that at least for users who have updated to 10.04r3:
The platform split for full copies of X-Plane remains about 63% Windows, 32% Mac, 5% Linux.
Among full-copy Windows users, about 85% are on a 64 bit Os – that is a surprise to me, but a good one – it means a lot of users will be able to utilize the 64-bit port. (Among demo users it’s about 75% 64-bit.)
Uh, What Do You Guys Do With This Information?
Not much. We didn’t actually set out to do a hardware survey – rather we put a user agent string into the installer when we first wrote it, because it’s required by the protocol. Apache logs user agents by default, so it was only after running the installer a while that we realized that we could “mine” the log for platform information.
We do not:
Try to correlate these user agent logs with customer information in any way.
Archive the logs permanently – as anyone who admins a web server knows, the logs get very big, so the server keeps a few weeks of records, then throws them out. Our only change from the default Apache config is to cut down the retention time because our server gets a lot of traffic.
Send any personally identifying information in the user agent string or otherwise. The server logs incoming IP addresses, but this is not part of our installer – all web servers know the IP address of the incoming requests; logging them at least temporarily is necessary to be able to identify the source of a web attack should one occur.
Among other things, I am working on more file format documentation for X-Plane 10. Most of the tools you need for scenery are right there in X-Plane 10.0r1, because our art team needed them.
But there is one feature that slid by: a global shadow disable for an object or art asset. I am adding this directive (it will be called “NO_SHADOW”) to a bunch of places in the scenery system. Typical use would be to completely exclude geometry from shadowing, which will also improve performance (less work for X-Plane to do). The directive will be available in 10.05.
There is one exception: you can disable shadowing in an airplane by disabling the “shadow” check box in 10.04, and “glass” tagged objects from v9 planes are not shadowed.
A quick OpenGL note for plugin authors: if your plugin uses OpenGL to draw (e.g. for a plugin in an airplane that draws a custom glass display) you should:
In debug mode: always check the OpenGL error state (using glGetError) at the end of each draw callback that you handle. X-Plane will not leave OpenGL errors around, so any error is yours. (To verify that it’s not another plugin, just add a glGetError at the beginning of the callback.)
In release mode: never check the OpenGL error state, as it can slow down the driver.
An OpenGL error often implies that an OpenGL command did not complete as expected (because a param is bad, etc.) and this can mean that you are not cleaning up OpenGL state for X-Plane!
(And of course you should always use XPLMSetErrorCallback in debug mode to catch plugin errors. Set a break point in your callback to see exactly where the error occurred.)
First: X-Plane 10.04 rc3 is live – please grab it – make sure to check “get betas” to get this patch! (If you are already using 10.04 betas, simply go to the About box to update.) Because this is a release candidate (we think it’s good to go but we’re not sure) you must still check “get betas” – that check box should really be “get crazy experimental stuff that is not yet officially released to the world.”
I think we are reaching the point where we can slow down the rate of patches just a bit. Like past X-Plane releases, the first patches came out fast and furious, because we wanted to get critical bug fixes to as many users as possible. We are now reaching a point where we can slow down and get more done between each beta, which I think will mean better rate of improvement for the sim overall.
Of course, if we get a really huge bug fix (e.g. an ATI performance boost or a fix for NVidia start hangs) we’ll cut a tiny patch off of 10.04 immediately; our source control system lets us do an incremental update very easily.
So with the next patch we will be able to work on some bigger bugs:
I think the next patch won’t be a full 64-bit patch, but it will contain a lot of the ground-work to get 64-bit working. We’ve already started on this code; by splitting it over two patches we can more rapidly deal with any kind of incompatibility introduced by the newer code. (Our goal is of course to make sure that any machine running 10.04 can run the 32-bit version of X-Plane when we support both bit depths.)
Austin received a lot of feedback about the UI while we were in Mallorca, and he has already started this work, although I am not sure what will be released when.
I will be digging into “Galloping Gertie” (our internal name for the many weird shapes the roads take when the road-placement code goes haywire). This is going to require some pretty major work to the road generation code, but of course it’s a critical fix.
While the volume of complaints about performance have gone down, there are still one or two performance tuning changes I want to get into the sim.
There are only about four things I work on when I am in the office: performance, fixing bugs, developer tools, and the installer. Hopefully with 10.04 installer work is done for a while and I can get one major area off my plate. This should leave more time for developer tools and documents, which I try to leave a fixed amount of time for every week.
One question that people have asked me about the X-Plane developer’s conference in Mallorca: what did you guys do there (besides drink)?
The conference was attended by a number of MSFS third party developers, a few X-Plane third party developers, as well as Austin, myself, and Aerosoft management. So the audience was mostly technical people (developers) and mostly MSFS, not X-Plane developers.
The sessions covered two basic areas:
Boot-camp, e.g. Austin and I did our best to rapidly introduce the MSFS developers to the X-Plane-specific parts of development, e.g. you know how to model, but how does a model get into X-Plane. Most X-Plane third party developers already know this stuff, but for MSFS developers the question is: where did you guys move the furniture in this new room?
New features, e.g. we described a number of the new things X-Plane 10 can do that are new to both X-Plane 10 and flight simulation in general. Some of this stuff hasn’t made it out to the public yet, due to me not getting docs out fast enough. McPhat studios were present, and they had all sorts of nice looking camera equipment, so we may be able to get some video posted.
For me, the most useful aspect of the sessions was the interactive aspect. Being able to have artists with significant 3-d experience ask me questions about X-Plane in real time really helped me understand what parts of the scenery system are important to authors and which are not; I am working on a new set of documentation that should hopefully be much better tailored to artist’s needs.
The experience also has changed my view on the scenery tools. In my past work on WED and the ac3d exporter, the tools have provided a more or less direct wrapper around the capabilities of the scenery system. This has two problems:
In some cases this means more work for the author, because the tools don’t provide a layer of simplification, automation and abstraction around the low level system and
In some cases the tools make it possible (or even easy) for the author to make non-optimal scenery and models; the tools really should make it hard to do things the “wrong” (but legal) way.
For the upcoming US developer’s conference (in Columbia in April) the sign-ups so far look like a more mixed group, with some very experienced X-Plane people and some totally new developers coming over from the MSFS world. We will be tailoring the content to try to meet the needs of both audiences.
If you attend, bring your content. Austin and I are very happy to sit down with your add-on and X-Plane (perhaps with debugging) and take a look at performance.
I am back from Mallorca. I will try to post more info on X-Plane developer conferences soon, but for now I will only say: it was great to meet a bunch of developers and friends in person (indeed, one of the things I like most about flight simulation is that it brings people together, often from across continents) and any picture you see posted of me with copious quantities of beer or other alcohol are photoshopped.
We’ll be cutting an RC2 of X-Plane 10.04 pretty soon with a few minor changes – it should be ready in a day or two.
I am also looking at better memory error reporting for 10.05. The crash reports now show memory usage at the time of crash and it’s clear that almost all of the crash reports we now get are memory exhaustion. (Well, address space exhaustion, technically.)
I spent part of today looking at whether I could detect this case and put up a clean error message. It turns out it’s very hard. X-Plane uses multiple cores to load scenery, and as a result, we can run out of memory simultaneously on several cores. On my 8 core machine, it’s like having 8 race cars heading toward a brick wall at 200 mph and you only have one airbag. Often a second thread will run out of memory and explode while we’re coping with the first one.
Clearly the long term solution is 64-bit, something that we are working on. But I am hoping that for X-Plane 10.05 we can at least recover enough to put up a useful error message (e.g. “you ran out of memory”). This will help users easily differentiate when they have to turn down settings vs. when they have found a real bug.
And speaking of using up memory…Andras has posted HD meshes, and they look awesome!
Finally, one last note on ATI Windows performance – I know everyone is itchy for an update, but here’s the thing: we have NDAs with AMD, NVidia, Apple, and Intel. Therefore when we get information from them, I can’t post it here. So unfortunately whether a bug is not being looked at, being looked at, understood, being fixed, or already fixed and just waiting to make it into some kind of release, I have to say the same thing: very little. I know that that’s frustrating, but I think we’re better off having close relationships with these companies and being able to solve these problems. If there’s ever a chance to put a work-around in X-Plane, we do that.
So I can’t give you any new news on ATI Windows performance, and I am sorry about that. I can only say that it is my top priority.
I realized the other day that while Chris and I have discussed cities with a bunch of people, I left out the city plan from my series of “road map” blog posts a while back.
The picture on the right is downtown Seattle from the upcoming X-Plane 10.04 beta 7, which includes an update to the urban art assets: new facades, a bunch of lit textures, and careful library tuning by Propsman. (There’s also some clever use of spill lights next to the tall buildings.) This update is part of ongoing work to build out our new city autogen; this post will explain the road map for that work.
A Radical Approach to Cities
Before I describe some of what’s failing in the current city scheme, how it’s supposed to work, and what we’re doing to fix things, let me take a few paragraphs to describe the “big idea”. Cities in X-Plane 10 are completely different from X-Plane 9, and they’re completely different from any other flight simulator that I’m aware of.
Before X-Plane 10 there were three approaches to cities that I am aware of:
Land class tiles. You create repeatable square orthophoto textures of cities and put matching 3-d on top of them. What’s good about this technique is that it runs on really minimal hardware, it looks good without using a lot of resources, and it’s fairly easy to code. The down side is that you will not get accurate cities. There is no way to use additional data to put roads or buildings in their actual correct places. You will always get a plausible but non-accurate city, a “city in theory”. This is the technique X-Plane 6 and 7 used, and the technique FSX uses.
Vectors over land class tiles. You create repeatable square textures of city (just like above), but instead of attaching the 3-d to them, you build your 3-d off of real vector data. This is what X-Plane 8 and 9 did. What’s good about this technique is that it runs on modest hardware, and it puts your roads and buildings exactly where they should be. The down side is that the 3-d is completely misaligned with the textures underneath, creating a “stew” effect when viewed up close. (Some users consider this mismatch absolutely unacceptable; others seem to not care.) There’s no question that the texture mismatch is not plausible, but the shape of the city is accurate. This is the technique X-Plane 8 and 9 use.
Fully custom cities. If you can afford custom non-repeating orthophotos of the real city and you have the matching 3-d data, you simply build the city and everything matches up. This is the ideal way to build a city, but it assumes custom data for every city; this is great for custom scenery but not scalable to a global product. It is plausible and accurate but not global.
For X-Plane 10 we wanted a way to have it all: a city that was plausible (e.g. looks good and doesn’t have weird artifacts) but also accurate (e.g. shaped like the real city, using data that’s now available – we can know where every road is, and even some of the buildings) and for the default sim, our approach has to be global; we can’t simply build a custom city for every city on the planet. And when we looked at the technology out there, it looked like it was for the first time possible.
Here’s what we came up with: in X-Plane 10, the unit of autogen is not the landclass orthophoto tile (a 1 km x 1 km square of terrain whose entire interior is defined by the texture and 3-d). The landclass tile has wonderful properties, but it’s just too big to be accurate for a real city.
Instead X-Plane 10’s unit of autogen is the city block. Each city block is an individual autogen unit, and the autogen is capable of flexing and shaping itself to fit the demands of a real road grid based on real data. This means we can have plausible autogen with tons of detail while sitting inside the real road grid of a real city.
This approach is significantly harder than using landclass tiles. Each autogen primitive needs to be able to resize and contort itself to meet the demands of real world data while still looking like it was meant to be there. The road grid has to look really good even as it is built from vector data, because we can’t just bake the pictures of the roads into the terrain. The terrain has to contain no city details in the near view (because the autogen defines where there is city), and the autogen buildings have to have “skirts” of orthophoto that they drop down to put their driveways and other ground details in place.
Then the rendering engine has to somehow take all of these disparate parts and render them at high speed!
So Does It Work?
When the new system works, it really does work and we get plausible and accurate cities with good performance on a global scale. But this system is entirely new – because it is such a radical change ,we couldn’t recycle any art assets or code from previous versions of X-Plane and thus it is very new, and frankly a bit raw. So when it fails, the artifacts are sometimes quite spectacular.
As the system ships now, a few things tend to go wrong; I will describe what’s going on under the hood and what we expect to do to fix it.
Crazy, Deformed Roads. This is the most common reported bug. (Hint: please stop reporting this. I know about it already.) We feed extremely detailed road data from OpenStreetMap into X-Plane; unfortunately due to bugs in the code, sometimes when X-Plane analyzes an overpass, it can’t figure out how the roads should stack up, and it instead creates some kind of ridiculous bridge, e.g. a road that shoots straight up into the sky or a giant 1000-foot tall arch.
The good news is: this is just a bug in the rendering engine; when I fix the bug (which I hope to do for the 10.05 patch), the artifact should go away without the need to redo any DSFs.
I brought this bug on myself by insisting that the roads be draped on the terrain. X-Plane 9 placed roads at absolute altitudes in 3-d space, which was easy for X-Plane, but meant that roads weren’t easily used in an overlay. For X-Plane 10 I wanted to make it easier to work with roads directly; once the road bridging bugs are fixed, this should be doable.
The road system is already doing a number of things we are pretty happy about though:
Roads are made of bezier curves. Once we go 64 bit we’ll be able to crank up the smoothness factor for users who have a lot of RAM.
The road junctions are flexible – that’s how we get clean, real, custom-looking junctions out of raw vector data. Over time we can add more junction definitions to make nicer looking overpasses.
City roads drape on the ground, avoiding Z thrashing and some of the other ugly version 9 artifacts.
Where Are the Buildings? The second bug report we get is that cities don’t contain enough big buildings, or enough sky scrapers. Most commonly the problem is residential houses appearing downtown.
The problem here is that the new autogen requires new art assets; we couldn’t just reuse our substantial pile of buildings from X-Plane 9. So we’re building more buildings; what you see in the meantime is the existing art assets shoved into the wrong kind of library slots. Once we have more appropriate buildings for a given library slot, things should look better.
We have also discovered some cases where the placement of autogen in the DSF isn’t very good. This was the first global render where we built the new autogen and there are some clear cases where we can do better.
So when it comes to building placement, things should get better by putting more art assets in a net update; we’ll probably recut some major city DSFs to get even better use of that autogen. (One nice thing about cities: there aren’t that many of them. There are over 18,000 DSFs in the global scenery, but the top 100 cities world-wide..well, that’s probably about 100 DSFs.)
There are two aspects of the buildings that are already working right now:
There is a ton of detail. If you get in close to the autogen, you’ll see a scene similar to what you might get in a custom scenery pack.
It’s fast. You can max out the road and building density on today’s hardware and get 25-30 fps. Compare this to X-Plane 9 where even four years after the product shipped, “insane” objects is often not reachable.
I put Seattle from v9 on an i5 machine for testing and compared it to v10 with insane roads, insane autogen, moderate forests, and shaders. I got > 25 fps in v10 vs. approximately 5 fps in v9. We’re going to try to keep that kind of capacity for huge amounts of autogen with high performance as we add more building types.
One last note about autogen and buildings: in X-Plane 10 the autogen can optionally be “height sensitive” – in this case the buildings in the autogen block take on an AGL height based on the DFS. We only use this for appropriate autogen types. For example, a dense urban city block might be height sensitive (since the DFSs contain heights for skyscrapers) but a block of residential houses is not height sensitive – they’re always just little houses.
In most cases the height data is already in the DSF; once we get the right autogen art assets in place, they should start repsonding to the height data.
Green Terrain. The third bug report I hear about is green terrain – that is, a city is filled with nothing but a big green expanse. To understand this bug you have to understand how our autogen creates the look of the terrain.
Austin posted in one of his early rantsmanifestos that we would build the terrain from the ground up, with green grass for the ground and no cities if 3-d is not enabled. This is a massive simplification of what actually actually happens.
The terrain is a composite: the actual base terrain is indeed devoid of any recognizable city details – because they will come from overlays. The ground instead contains “natural turf” patterns that try to impart some detail while accepting overlays.
The road grid then puts down a layer on top of the ground, with sidewalks and the actual pavement.
On top of that, the autogen system puts down a ground tile for each building. (One autogen block consists of multiple tiles, and the tiles are moved around to fit the block shape.) The tiles are mostly transparent, but contain details that mask parts of the ground, such as sidewalks and driveways.
Thus the combination of three layers (ground, road and autogen ground tiles) composite together to form the kind of detail that you would normally get in an orthophoto.
So when we have green terrain, there are actually several problems conspiring to ruin this “composite orthophoto” effect:
If we don’t have the right autogen buildings (see above) we won’t have the right ground tiles. More buildings will help fix this.
It’s actually a bit tricky to build the ground terrain that can sit under the autogen; the only really complete climate we have supported right now is a northern climate (which works well in Seattle). So as we add more urban base terrains the bottom layer will start to work better.
When you turn down autogen density, some autogen city blocks disappear. This is a hold-over from version 9. What we want to do is keep the base tiles but remove the 3-d when you turn the rendering settings down. This will lighten the rendering road, but the 3-layer orthophotos will still look good. (Similarly, we’d like to reduce detail but keep all roads for lower road settings.)
In other words, once we have more buildings, more ground terrain, and a better way to turn down detail, the terrain should look more like a real city under a wide range of rendering settings.
(If you’ve really watched the sim carefully, you may have noticed that the ground textures actually crossfade from “just grass” to orthophoto-like as you get farther away from them.
What Next?
Everything listed above represents incremental improvement of our cities – more art assets, bug fixes, smarter LOD and rendering settings. But that’s just the beginning. I believe that what we have on our hands is a fairly big fundamental improvement in how cities are handled: we have a way to build cities that provides a huge amount of up-close detail while working from detailed data (and representing that data), and it can run at good fps on today’s hardware.
Down the road I think we’ll be able to integrate and utilize OSM data to get even more detail into our cities and further push the envelope for how much detail, realism and accuracy we can get into cities at a global scale.
X-Plane 10.04r1 is out – this is a release candidate. That means:
It’s not official yet. You have to check “get betas” to see this one.
We think it’s really pretty much done. If you haven’t tried the beta and have been going “I’ll wait until they’re closer to being finished with the beta run”, well, that time is now.
As has been mentioned, Austin and I will be in Mallorca for this, so we’ll go through bug reports against the release candidate when w get back. I look forward to seeing everyone who is coming to Mallorca, and for everyone else, hopefully this will be the first of multiple events and forums to further reach out to the developer community. I will do my best not to jump up and down and shout “Developers!” over and over like a sweaty drugged up maniac.