What Are Conditionals For

A user asked me whether we would ever have a conditional directive in the OBJ format to let an author vary the look of the object based on weather. My answer:

Definitely not - this is definitely not the intention of conditionals!

The goal of conditionals is to allow authors to cope with multiple "rendering modes" of the engine, where:

  • The look of the sim is radically different between the rendering modes and
  • The performance cost of working around the lower rendering mode is expensive.

So for example, when shadows are off, you have to use some ATTR state change to drop a fake shadow on an object. This kills instancing, so when shadows are on (and the sim needs more performance), leaving that double shadow is not only ugly, but slow.

The conditional works by fully "stripping" those commands for shadowing from the object, then re-analyzing it.

So the win of conditionals is that you do not pay for what you don't use, because everything is done on load - it's like shipping two highly optimized objects.

But the down-side is: conditionals require scenery to reload, which is slow, disruptive and annyoing. This is why we would never use them for something that is dynamically changing in the sim, like weather or time of day.

We do want to have weather effects, but our approach is going to be very different: to have a "weather map" texture on the object (same UV as the object) indicating what sections of the texture will receive changes to their material due to weather effects. This will allow the object to look progressively more wet over time without a reload as the rain falls.


  • Facebook
  • Reddit
  • Twitter
  • LinkedIn

About Ben Supnik

Ben is a software engineer who works on X-Plane; he spends most of his days drinking coffee and swearing at the computer -- sometimes at the same time.
This entry was posted in Development, File Formats, Scenery. Bookmark the permalink.

15 Responses to What Are Conditionals For

  1. Santiago Butnaru says:

    Hi Ben,

    thank you for the explanation and the information about the (tentative) weather effects plans.

    I have two questions:

    1. In this post http://developer.x-plane.com/2016/02/third-party-cars-should-really-be-instanced/ you wrote:

    "Draped geometry is instancing-friendly, but don’t use it for vehicles."

    I haven't been able to use draped geometry while keeping it instancing-friendly, no matter if it was cars or any other object, could you please clarify that?

    2. the "weather map" you plan to use sounds similar in concept to the "decals map" you use now for ground detail, those maps are loaded to the vram or are they relatively "free"?

    One final comment....the spoilers in almost if not all aircraft I'be seen in x-plane have relatively no real effect, I mean, they will slow you down, so they can create drag but what happens to lift? in real life if you try to take off with spoilers deployed it will probably end in a crash, right now in xp you can make a whole flight with spoilers deployed and not even notice it.

    I would love to see a plane being "slammed" into the ground as soon as spoilers deploy after touchdown, off course the most important part of that view is all the aerodynamic sorcery going on behind it.

    Cheers!

    • Ben Supnik says:

      I don't know why your draped geometry would make it not instance friendly; if you think you see this, put a DEBUG directive in the object in question and send me BOTH a log output with the OBJ-loader debug output and the OBJ itself.

      2. They are loaded into VRAM - they cost as much VRAM as how big they are...this might be huge, or not - the res doesn't have to match the other layers.

      Re: spoilers, you'll have to discuss this directly with Austin.

      • Santiago Butnaru says:

        To know is not instancing I do the terrain/kill_cluster = 1 test and draped geometry doesn't disappear, that includes autogen draped geometry.

        I just sent you the files requested.

        Thanks!

        • Ben Supnik says:

          That's not becuase instancing isn't working - it's because the draped part of the geometry is replicated ("static" instancing). This is needed because each bit of draped geometry has to change to fit the terrain it's on top of in its own special way.

          • Santiago Butnaru says:

            Thats good to know, I thought that everything that was instanced should go away with that test. Is there any way to know if draped geometry is being instanced?

          • Ben Supnik says:

            Draped geometry is always static instanced - that is the -only- way it can work. Hardware instancing is only a concern for the rest of the object. If you kill objects and your object disappears, you hit the slow path. If you kill clusters and your object disappears, you hit the fast path. If you have ONLY draped geometry, that's fast too.

  2. Jorge Hidalgo says:

    Hi! Ben... I hope you are very well: With the last update my PC works much better gain 55% of FPS with my ATI R9 290, thanks.
    I have a small suggestion... I would like the temperature, the admoferic pressure, the wind speed, the height, etc., to be expressed in both systems... feet and meters, fahrenheit and centigrade, the inch of mercury and hectopascales, etc. Regards

    • there are handy drop-down selectors next to temperature and pressure settings that do just that.

      • Jorge Hidalgo says:

        Hello Philipp ... In the menu Weather --- Customize - Weather Mod - Match Real Word Conditions -> Systems can not be changed, I try to change in Weather Mod - Manually Configured - Change Fahrenheit Temperature to Degrees Celsius and returned to Weather Mod - Match Real Word Conditions, when it finishes downloading Weather, in it automatically changes me to Fahrenheit again, and I want it to show me the temperature in degrees Celsius, just as happens with the ... for the United States very well ... but for the rest of the Countries is not very good ... Thanks for your answer.

        • Jorge Hidalgo says:

          Sorry original message --- Hello Philipp … In the menu Weather — Customize = Weather Setting = Weather Mod – Match Real Word Conditions -> Systems can not be changed, I try to change in Weather Mod – Manually Configured – Change Fahrenheit Temperature to Degrees Celsius and returned to Weather Mod – Match Real Word Conditions, when it finishes downloading Weather, in it automatically changes me to Fahrenheit again, and I want it to show me the temperature in degrees Celsius, just as happens with the =Barometric Pressure=… for the United States very well … but for the rest of the Countries is not very good … Thanks for your answer.

  3. Stuart McGregor says:

    Just to say I quite like the fact there are less variables to play with in 11 and many thanks for the explanation behind the changes.

  4. Christophe says:

    Hi Ben, Philipp,

    "We do want to have weather effects, but our approach is going to be very different: to have a “weather map” texture on the object (same UV as the object) indicating what sections of the texture will receive changes to their material due to weather effects. This will allow the object to look progressively more wet over time without a reload as the rain falls."

    With the help of some shaders ?

    In the same idea, do you think it's possible to have seasons driven by shaders ?

    The idea is to have a solution to avoid 4 textures (spring, sun, fall, winter) simply because (1) it's dead static, (2) it weights too much on disk and obviously (3) it can't be applied to orthophotos... I thought about a shader that modify the colorimetry of the texture. (It's just an idea, I don't know how powerful the shaders are)

    Thanks.

  5. Christophe says:

    In the same idea, is it possible to enhance trees by having some simple objs where their textures are driven by shaders?

    When we see the huge step forward you made on v11, I think that the trees deserve a bit of love now 😉

  6. Kevin Ashton says:

    Hi Ben,

    Is it possible to make it so that if I file a flight plan, and then select "AI flies your plane" the AI respects that flight plan? That would be really awesome for demonstration purposes.

    Kevin

Comments are closed.