Monday, June 25, 2007

Don't use the panel texture in a non-cockpit object.

Panels and airplanes aren't really my thing. But we're using the OBJ engine more and more in aircraft, blurring the lines between scenery code and aircraft code.

In X-Plane you can actually use the panel texture in any object. Pleaes don't do this! There are two cases:

Airplane Objects

With X-Plane 860 you can attach many objects to an aircraft. But...you should only use the panel texture in the cockpit object.

The cockpit object is special! It is the only object that gets mouse-click tested. In the future we will decide how much of the 2-d panel to render to a texure (for the 3-d cockpit) based on the cockpit object. So...don't use the panel texture in your other aircraft objects. Put your panel-textured triangles in the panel object.

(You should do this anyway; switching to the panel texture creates a new batch*, so using it in a lot of separate objects is bad for framerate.)

Scenery Objects

Technically you can also use the panel texture in scenery objects. This is really just a big hack -- all of the issues with optimzation apply to this case, plus: how can you even know the layout of the panel texture in scenery? Don't do this!

* "Batch" is the technical term in the game development and authoring world for a set of triangles that can be drawn by the graphics card via single CPU command. While graphics cards can process tons and tons of triangles, the number of batches they can process is limited by CPU and bus speed, which advance much more slowly. Generally the number of batches is the limiting factor in X-Plane's framerate.

It's easy to see how many batches your OBJ8 contains: open the file and count the number of "TRIS" and "LINES" commands at the end. Ignoring lights, the sum of the TRIS and LINES commands is the number of batches! (HINT: fewer is better, and only one batch is great!)

4 comments:

Bertrand said...

One more thing about panel texture: a panel texture don't change its luminosity with sun.

Not really useful for many situations.

Benjamin Supnik said...

True - this is a design limitation. We'll redo this someday - we didn't put it in the original design to keep fps up and VRAM use low, but today's hardware can handle it.

DhruvK said...

If we're not allowed to use the panel texture in a non-cockpit object, does that imply that we should have only one obj per plane that can be mouse-clickable?

That's a little hard when you're building an airliner and need to not only have several mouse-clickable areas, but also need to be able to texture a rather vast amount of mesh. Cramming all the texturing for a cockpit of that complexity into one 1024 x 1024 texture's basically impossible. As a result, we're almost forced to split everything up.

Benjamin Supnik said...

Dhruv,

You are right - all of your clickabale parts need to be in ONE object.

But the whole cockpit does not need to be in one object.

Remember, you will always be stuck with only 1024x1024 of "active" texture...so merging all of the clickable parts doesn't represent a loss of active texture space.

And the "passive" parts of the panel don't have to be consolidated, so you can continue to split the cockpit to get more texture space.

(Did that make any sense?)