Friday, August 21, 2009

Normal Maps in X-Plane 940

X-Plane 940 now supports normal maps on OBJ models (both scenery and airplane). I'll get more formal docs up once the rest of my office is moved and unpacked but here's the details for now:

The normal maps are in "blender" format see here. The alpha channel is optional; if it is present, it serves to modulate the level* of specularity. Opaque means full specularity, transparent means none. You can use this feature to make some parts of an object shiny and some dull on a per-pixel level.

Shininess level is modulated by both ATTR_shiny_rat and the alpha channel, so you need ATTR_shiny_rat 1.0 and an opaque alpha channel (or no alpha channel) to see full specularity.

Normal maps are only available for objects and only appear if pixel shaders are on and per-pixel lighting is enabled.

Normal maps should be PNG format, not DDS - they will not be texture compressed because S3TC compression tends to kill them. (There are some modern formats for normal map compression supported by the newer cards but we don't use them yet.)

* Specular level: most serious 3-d programs let you control both the specular exponent, which controls how "tight" the specular hilights are, and the specular level, which controls how bright they are. X-Plane only lets you control specular level; if specular hilights exist, they are always as the maximum exponent for the sharpest specular hilights.


Steve said...

This is really, really cool, Ben. But it seems Blender centric. Pardon my 3D app ignorance, but does this mean that normal maps will only be available to those that use Blender, vs. using AC3D?

Benjamin Supnik said...

It is blender centric, but only because ac3d doesn't have normal map support at all, so it made sense to pick a format that was both reasonably well thought out and already supported by an app.

The capability will be available to ac3d as well, but you may not have a real-time preview of the bump map. Eventually I will add exporter support for it. In the meantime you can easily add your normal map with a single-line edit to the OBJ file.

(My expectation is: the normal map doesn't change the process of modeling since it shares texture coordinates with the main and lit textures.)

Think of it like this: you can use a LIT texture even though you might model using only the day texture. This works because they share texture coordinates. It's the same idea for normal maps.

Steve said...

Got it. Then the AC3D-centric workflow stays unchanged as it is now. Work up the model, apply it's "painted" UV map. Once that's happy, one adds the appropriate line to the exported .obj file, realizing subsequent exports will remove it should there be a need for a tweak. One then uses the same UV map file to create a "normal" map. This can only be tested by saving the map at various points in its development to the appropriate aircraft directory and reloading the aircraft in X-Plane.

Anonymous said...

Normal maps... Brilliant!

This is going to allow devs to create some beautiful looking aircraft.

And scenery objects can have them too? That's something that FSX can't do.