I think I have mentioned draping repeatedly, as well as Z thrash, without ever clearly explaining what either of these things are. I happen to have some pictures from recent work on draping, so here’s the basic situation.
What Is Thrash?
Warning to OpenGL purists: I’m going to play fast and loose with a number of OpenGL rules. Basically what I say here is the worst case. Sometimes things work out better than I describe, but if you don’t handle the worst case, you’re going to have problems some times. Nitpickers, consider yourself “on notice”.
When drawing 3-d polygons in OpenGL, if two polygons are coplanar, most of the time they will experience “Z thrash” – that is, the hidden surface removal hardware on the graphics card removes some parts of one polygon and some parts of the other, often removing different parts on each frame in a flickering pattern. The results look like this:
In this picture on the left, we see the raw result of coplanar airport polygons on top of the sandy desert terrain that is the airport surface area. As you can see, the graphics card has been a bit random in deciding whether the runways are “hidden” by the ground or not. If you could see the camera moving, you would see that the pattern of missing taxiways ‘flickers’ as the camera moves.
If there is an overall take-away point so far, it’s this: you can’t just layer coplanar triangles without getting a mess.
(What about moving the runway slightly higher than the pavement? This would have several problems. First, the amount we’d have to move them is horribly dependent on camera angle and video card Z-buffer performance. Second, we’d see the gap between layers; for markings that really do need to be coplanar, like a rubber mark on a taxiway, this would appear as a bug.)
The Cure is Worse Than the Disease
Fortunately if we have truly coplanar geometry, OpenGL gives us a weapon to fight this: polygon offset. Polygon offset is a cheat that tells the video card: “listen, if you ever have doubts about the runway and the ground, favor the runways by a little bit.” It’s a little bit like putting a spread on a football game: the ground would have to be closer than the runway by a margin before we stop seeing.
When we have coplanar geometry, we can use polygon offset to handicap the geometry we want on top. Problem solved, right? So why do I keep writing blog posts with titles like: The Sordid History of ATTR_poly_os or The road to hell is paved with ATTR_poly_os?
Polygon offset has three problems that can bite you:
- The amount of ‘margin’ you get depends on the camera angle. This can make for some truly bizarre effects. The only way to safely manage this is to carefully minimize the margin. (This is a problem for the programmer, not the artist.)
- Because the margin must be minimized, the geometry really has to be coplanar – small cheats can exceed the margin.
- The margin you give your top polygon applies to anything else that is nearby, which can cause even more weird artifacts. For example, if you polygon offset a taxiway, it can start appearing through the nose wheels of airplane. That’s another aspect that must be carefully controlled.
If there’s a take-away to polygon offset, it’s this: polygon offset can help fight Z-thrash, but it must be used in a very narrow set of cases, and it must be used very carefully.
In my next post I’ll describe how X-Plane uses draping to fight Z-thrash for sloped runways.
X-Farm has been canceled. Sorry.
However, there are some new MeshTool builds. Release candidate three fixes a crash on quit on Windows and fixes the SHAPEFILE_MASK command. Builds are here:
Speaking of Mesh scenery: Oahu’s out!
I didn’t think we’d be able to show this, but…
http://www.x-plane.com/blog/wp-content/uploads/2011/04/snout_view2.mov
Yes, X-Farm will have global lighting…
If there’s one thing I hear over and over from our users, it’s this:
Why are there so few farm animals in X-Plane? The deer on the runway are my favorite feature in the whole sim! Why aren’t there more animals in X-Plane? Please add more!!!
Now first, I’m going to let slip a little secret, because I know you guys are desperate for tidbits on X-Plane 10. The big feature in X-Plane 10 that is taking us so long to get right: moose! While the deer on the runway aren’t going to clock in at much more than 300 lbs, a fully loaded bull moose weighs about as much as a C152 at MTOW. (At least, according to Wikipedia…I’m not convinced a C152 that weighs as much as a moose can get off the ground.) Trust me, you don’t want to hit one of these things, even in a 747.
But that’s not the big news here. The big news here is a new simulator product we’ll be releasing this fall: X-Farm. X-Farm will be the first animal simulator to work entirely from first principles. X-Farm will use shoulder-blade-element-theory to calculate the forces on each part of each animal’s skeletal structure to simulate what the animal would do in the real world. Wanna put the head of an alpaca on a gorilla? Go for it! (Actually, that’s a terrible idea – Camelids spit.) Think Rover would look cute with 6 legs and a stinger? Our animal-modeling application Animal-Maker will let you fully customize your animals.
X-Farm will feature a completely rewritten Animal Traffic Control (ATC) module, with AI Animals that wander around the farm on their own, and herding dogs to chase after them. (The initial version will feature only 20 animals at a time, but we’ll be able to scale this number up over time; the animal AI is fully multi-core for great performance on your new Core i7.)
It’s too soon for me to give specific hardware guidelines, but I’m thinking a DirectX 11-class video card will be best for X-Farm; we’re putting a ton of new shader features into the core engine to support fur on the animals and grass for the fields. The facade system is greatly enhanced and can be used to build a variety of fences and paddocks to keep your animals where you want them.
Finally, I think we’ll eventually be able to get plugin support into X-Farm, so that you can customize the behavior of your animals and create custom animations. Hopefully Wade and I will have time to port XSquawkBox to X-Farm (new name: XSquawk), so that you can create flocks of birds and let them loose in your favorite VATSIM ARTCC. I hear ZBW loves that kind of thing.
*EDIT (By: Chris): I added some screenshots for all the impatient followers who just can’t wait another second to get some sneak previews of some farming. Obviously these are still rough drafts. I’m still working on getting the farmer to look as muscular and rugged as I really do. It’s close but not quite right just yet. Please do NOT ask for more screenshots. We have a pact here as developers that I’ll explain to you a bit since Ben already let the cat out of the bag about the product. Each time we get a request for more screenshots we do two things: 1) We drink from our glass of scotch 2) We go to our whiteboards and move the release date of the product out by one full week. We do this to be spiteful of course. We have so many products stocked up here just waiting for release but it’s more fun to watch the mania ensue. Coming Soon; Surgery Simulator “Demonstrate that steady hand as you remove the remote control that your dog swallowed from his upper intestinal tract”. We’re still working on the price of this one but let’s just say we’ll be doing a wallet-ectomy on you. Post Office Simulator “You get to live the life through Postal Employee Newman’s Eyes. ‘The mail never stops!’ Stack and sort bag after bag of mail trying to beat your best score.” and finally Department of Motor Vehicle simulator “Take a ticket and get back in line”. We’re hoping to release this one around fall of 2012 but that depends on how many screenshot requests we get. This one is very unique. You can play the worker at the counter handing out tickets. You also get to instruct people to get into the wrong line and then laugh at them as it takes them 45 mins to figure it out. There’s also a level where you have to put your “Next Agent Please” sign up as fast as you can. Beat your previous times. Play with your friends on multiplayer! Who gets to take their 4 hour break first?!
First, let me say that this post represents my opinions and my thoughts and does not reflect the official view of Laminar Research.
I’ll be the first to admit that the news and events that have “leaked” out regarding v10’s release date have created quite a bit of confusion, controversy and general discomfort amongst you guys; our fans/customers etc. I’m sorry to see the drama unfold in this manner. It’s certainly not intentional, it’s not a sign of v10 being delayed further and it’s certainly not a sign of v10 being canceled.
As i’ve said a dozen times already, v10 is very much alive and kicking. It consumes about 99% of all of our (the staff) time. It’s our #1 priority, it will remain our #1 priority and it has been for a long long time. There are many factors that contributed to the original delay of v10. I’m not going to go into internal details but I feel that it’s going to be a better product as a result. We’re not slacking off here. I don’t think there’s a single LR employee who’s put in anything less than a 40 hour work week in the past 3 years. I actually think the average is quite a bit higher and has been for some time.
One of the reasons for this tech blog is to give those of you interested an inside view into what it takes to write a flight simulator. It’s no simple task. In fact, in some ways it is rocket science!
I’m amazed by the amount of attention to detail that goes into XPlane’s development. Just as a quick example, I was recently working on some ATC code and wanted to get a list of the runways at a given airport that had full ILS approaches. I was expecting there to be some kind of database lookup in the simulator that would say “oh runways 06 and 33 have full ILS approaches”. That’s a pretty basic assumption. “It’ll take 2 seconds to wire up” I thought….but that’s not how it works. There is no magical database for ILS approaches. XPlane doesn’t know about approaches directly, it knows about antenna types and location, OBS and glide slope angles. What I mean is, the database says “there’s a localizer antenna facing 036 degrees magnetic at lat/lon x/y and there’s a glide slope at x/y with a 3.5 degree angle.” This made my job a little more difficult because i needed to then compute the geometry of the localizer, glideslope and runways to determine what runway would benefit from a signal in that direction (don’t forget about parallel runways!). That kind of realism is unparalleled. What it means is that if a localizer antenna is offset at an airport because of obstructions (like runway 15R at Boston), XPlane will model the approach angle perfectly just like in the real world and you’ll come in at a slight offset. This is not new, the sim’s always been like this but it’s a new discovery for me. I guess my point is, sometimes even tasks that seem simple on the surface can be a bit more time consuming because we care about realism and the world is not a simple thing to model accurately…and that’s why this blog exists. We like to share with our users how COOL all of this stuff can be.
Getting back on track here, this blog gives you guys an inside look into our world so you have some insight into what kind of moving parts are in there. Our conscious decision to open this kind of dialog with our fan-base is a great thing, but it also can sometimes lead to miscommunications. Sometimes, we might say something in an innocent manner and you might take it out of context and misinterpret what we meant. For that, I’m sorry and we’ll take the blame.
With that said, I must ask and beg and plea that we all think twice before jumping to conclusions, trying to read between the lines and make inferences from quick unofficial statements made in a forum, a blog, facebook etc. Please do not assume that if a 3rd party vendor makes their own prediction of when v10 will ship, that it’s evidence of an official ship date. Please do not assume that if Austin himself says “by the end of the year” that he literally means “the end of the year.” If it shipped tomorrow, that would technically also qualify as “by the end of the year”. And NO, it’s not shipping tomorrow either. I can’t say that I blame people for wanting to hang on our every word and analyze our statements down to the verbiage but as much as I understand it, please try not to continue doing it. Official news, announcement of official features and official dates will be clearly marked as official. You will not need to read between any lines or make any assumptions.
So if v10’s not necessarily shipping in August and if “by the end of the year” does not necessarily mean “the end of the year”, then when is it shipping? The answer is….I don’t know! And that’s why there hasn’t been any official news yet. We’re not thinking about official dates yet because the date is arbitrary to most of us. When we’re all done with the core features and when it seems stable, then it will be released.
And because every post is better with a picture….Here’s a quick visualization of the math behind computing some ILS antenna intersection
s. The green line represents the localizer antenna beam. It starts in the background at the localizer antenna’s location and extends outward at the “OBS” heading of the antenna (note that in this unusual case, the localizer is NOT down the centerline of the runway!). The blue line starts at the glide slope antenna and extends outward at some angle above the earth’s surface. Typically this angle is about 3 degrees. The red line just represents the runway end. The point of this visualization is to see if you were perfectly aligned with the localizer AND the glideslope when you crossed the runway, where would you be? The intersection of these three planes is that pink dot.
From fearless leader:
X-Plane 9.68 is here (in Beta) for Mac, Windows, and Linux!
Just some TEENY little tweaks and enhancements to make v9.xx perfect:
- new airport and NAVAID data
- fix for lighting in non-generic instruments with esys (rare bug)
- sound stays on when X-Plane is pushed to background on windows… as requested, and now in sync with Mac version for better consistency
- improvement in the situation saving and loading
Just run your installer (from X-Plane.com) with the BETA options turned ON to get it
Have at it and let me know how it goes!
austin
ps: X-Plane 10 is much, much, much slower in coming along than I planned.. but it is much, much better as well. It is slow because I have raised the bar ridiculously high for this release, simply because I CAN. SO, I am keeping v9 totally bug-free while v10 is developed, which I am hoping to have ready by the end of this year.
I am hoping to have v10 ready quite a bit sooner than that.
One user asked me about slow performance with an overlay scenery he created using GMaps. There are three things you need for fast orthophotos in X-Plane, and unfortunately his scenery is missing one.
Use DDS
I’ve written before about DDS. They key points here for orthophoto performance are:
- Since DDS is already compressed, the CPU has to do less work preparing the texture if it is going to be compressed.
- Since DDS is already pre-minified (meaning the smaller versions of the texture are already computed), if you are not running at ‘extreme’ resolution, the sim can simply load a lower res version. With png, X-Plane must load the full size version and scale it down on the CPU.
- Since DDS is already pre-minified, the sim doesn’t have to compute those minified versions of the texture on the CPU.
All of these things lead to much faster texture load times with DDS.
Use LOAD_CENTER
LOAD_CENTER is a directive that can be put in a .pol or .ter file to tell X-Plane at what location the texture needs to be at maximum resolution; X-Plane will reduce the resolution of the texture as you fly away from that point. LOAD_CENTER is important for orthophotos for a few reasons:
- It saves VRAM, since textures that are far away won’t be loaded at full resolution.
- When combined with DDS, it improves load time. Since some textures are loaded far away, they can be loaded at lower resolution, which (per above) is quick for a DDS file – less data, less load time.
Note that LOAD_CENTER causes X-Plane to reload the textures while you fly, so it requires at least one extra core to work well. It’s really important to use DDS with LOAD_CENTER; otherwise that reload time can get expensive.
Use a base mesh, not draped .pol overlays.
This is probably the most important thing: if you want to cover a lot of area with orthophotos, you need to rebuild the base mesh using .ter files, not cover it with .pol files. There are a few problems with using .pol files:
- Draped polygons are only ‘built’ for areas relatively near the airplane. So even under ideal circumstances, they are going to disappear in the far view. This way of using them (only when near the airplane) is a memory savings based on their intended use: for small surface areas like airports.
- Similarly, since the draped polygons are being built and destroyed as you fly, the amount of extra CPU work while flying is quite a bit higher with .pol files than with a base mesh (which only has to page the actual terrain). So a computer that might be fine paging .ter files can get behind in its work for .pol files. (Authors often use .pol files because they are easy to work with – specify a rectangle and X-Plane does the cutting and slicing…well, that work is happening while you fly, burning up CPU power that could be used to page the orthophotos.)
- Since .pol files cover the base mesh, you pay for your mesh twice – once when X-Plane draws the base mesh and once when it covers over it with polygons. This means twice the VRAM used to draw a frame and twice the fill rate.
If you want high performance orthophotos over an area any larger than an airport or down-town, please use .ter files!
Comments should work again – sorry about that. The anti-spam captcha plugin had a directory permissions problem. We need that anti-spam protection though – without it WordPress is a magnet for spam-bots.
This is a view of the underlying vector data for the current KBOS taxiway layout. It is floating above the ground because the data hasn’t been “draped” onto the layout yet. There are two copies because the data has been debugged once for each DSF tile that the airport spans; when the actual paint is put down, only one copy of the lines will end up on either DSF, so we don’t have double triangles.
These four buildings are facade-scrapers, a new feature in X-Plane 10.
X-Plane 8 and 9 support facades. A facade is a building definition that is extruded to an arbitrary shape and height specified in a DSF. Facades allow us to build custom-shaped buildings that fit a precise footprint. The walls are created by cutting and repeating a grid texture of windows.
With a facade-scraper, two objects are placed in the center of the facade to form a tower. The facade base itself can exactly fit a city block, while the OBJ pair gives us a tower with architectural detail.
This is a wire-frame view; the facade itself is wire frame, and the ground is wire-frame, revealing the two objects. The base of the facade sits on the ground, but the tower can move up and down, with excess underground. This allows us to customize the height of the building to precisely meet the DSF height.
(This facade is a test case that I built out of Alex’s Chrysler building; the UV mapping on the base is pretty rough since I was just creating test files.)