I just fixed a problem in DDSTool: DDSTool was calculating mipmaps in sRGB space instead of linear space. This was wrong, but didn’t make a huge difference when grinding day-time textures.

It does make a big difference for LIT textures though. Let me show you.

That’s a night LIT scene (at PHNL I think) with some new autogen from X-Plane 10.50. (To answer your question, some of the AG has LIT textures, but not 100% of objects do.)

In the lower left corner are thumbnails of the raw textures – what is interesting about them is that they show the smaller-sized images in the mipmap pyramid of the image. And you can see that in the old image, the small thumbnail of the buildings is almost completely black – the building light has been lost with down-sizing.

Note that the buildings are a little bit darker in the old grind on the left but the tiny thumbnail is much darker. That’s because making mipmaps is a recursive process – each next-smallest-size mipmap is processed from the previous image; by the time we get to a really small size image, if we have lost brightness, the effect has really built up.

The result was that in the old grinds, as you flew away from the buildings, they’d get darker. In the new grinds, they stay at consistent brightness.

What Changed: the Math

Here’s the funny thing about images in sRGB color space (which is what X-Plane uses) – the mid-point between black (0) and white (255) is not 127 or 128.  That’s too dark! The actual right color is 188 – pretty bright!

This happens because sRGB images are encoded in a non-linear manner for even perceptual spacing for humans, and our eyes are more sensitive at lower light levels. But the average between two pixels should be the average of the actual amount of light coming from the pixels.  The half-way point of sRGB is too dark because a lot of numeric space in sRGB is spent in the dark regions.

The problem is that lit textures are made up of a few really bright pixels and a lot of black; when averaged together the wrong way the smaller sized images end up too dark, making slushy, dark, munged night lit textures at small sizes.

The solution (in the new DDSTool code) is to convert the colors to linear space, down-size the image and convert them back. There’s no change to how you use the tool – the images just look better at small size.

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.

14 comments on “Brighter Night LIT Textures

  1. I’m still can’t get a dds file in Ubuntu 14.04LTS by typing “./DDSTool –png2dxt –gamma_22 *.png” ,even if my *.png is a simplest Greyscale test file. In summary I always have: “Unable to open png file (null)”. So I gave up on the idea of using the xptools_lin_15-3.

  2. One of the very special things I really like about XP, is that you let us look behind the technical scenes.
    Many thanks!

  3. Looking good. I know this might be a lot to ask but would it be possible to add water reflections off the ground if its raining in the PC version of XP10?

  4. Hi Ben,

    Thanks for the updates first of all, I like reading your perspective on what’s coming, and how. My question is a bit unrelated to the LIT textures and more regarding night lighting in general. Are there any plans in the future to address ground night lighting “popping” in when at high altitudes? I absolutely love what you did with the extended DSFs and it made flying airliners SO much more enjoyable, so I was just curious if something similar could be done with the 3D night lighting (autogen?). Keep up the great work =)

    1. We know that night light popping is a problem, but I do not know what the solution will be yet. Increasing the AG instantiation distance is quite expensive.

  5. Yeah, pretending sRGB is linear really destroys images once features shrink down to less than about a pixel. It’s closely related to the inequality of arithmetic and geometric means. The more variable the source pixels ending up in a destination pixel are, the darker the result gets. The worst case is an isolated point of light becoming ever smaller. If source pixels are similar enough (large features), not much changes.

  6. HI… This is an amazing news for night flying. Will you also create night bright city textures (without 3d lights) for night enjoyment at really high flight cruise level so that we can see big cities lights from 80/100 miles away in very clear sky conditions??? That would be a mega plus for night IFR flying!!! 🙂

      1. Ok no worries, but it would be nice to have that in the future… like you did with the “grey” city textures to make them visible from a very high cruise level and from distance. It would be really cool to have something like that for the night…. flying during the night at low level is amazing, but once you are at FL200 and up, everything seems so dark. To see lights you have to look perpendicularly down… even in clear skies… 🙂 Anyway, thanks for reply and keep up the good work! You are an amazing team and since I switched from FSX to xplane, I never went back!!!

Comments are closed.