This is a brain-dump inspired by a thread on twitter about correct™ dither in sRGB, meaning, to choose the dither pattern in such a way as to preserve the physical brightness of the original pixels. This is in principle a solved problem, but the devil is in the details that are easily overlooked, especially when dithering to only a few quantization levels.
So, this topic came up on twitter:
I had previously spent some time to wrap my head around this exact problem, so I shot from the hip with some pseudo code that I used in Space Glider on Shadertoy. Code postings on twitter are never a good idea, so here is a cleaned up version wrapped up in a proper function:
In my previous rant about dynamic exposure in Elite Dangerous (which honestly applies to any other space game made to date), I made a rough calculation to predict the brightness of stars as they should realistically appear in photos taken in outer space. My prediction was, that,
- for an illumination of similar strength to that on earth,
- if the sunlit parts are properly exposed,
- and with an angular resolution of about 2 arc minutes per pixel,
then the pixel-value of a prominent star should be in the order of 1 to 3 (out of 255, in 8‑bit sRGB encoding). Since then I was curious to find some real world validation for that fact, and it seems I have now found it.
I am a backer of the upcoming Elite Dangerous game and have participated in their premium beta programme from the beginning, positively enjoying what was there at the early time. ‘Premium beta’ sounds like an oxymoron, paying a premium for an unfinished game, but it is nothing more than purchasing the same backer status as that from the Kickstarter campaign.
I came into contact with the original Elite during christmas in 1985. Compared with the progress I made back then in just two days, my recent performance in ED is lousy; I think my combat rating now would be ‘competent’.
But this will not be a gameplay review, instead I’m going to share thoughts that were inspired while playing ED, mostly about graphics and shading, things like dynamic range, surface materials, phase curves, ‘real’ photometry, and so on; so … after I loaded the game and jumped through hyperspace for the first time (actually the second time), I was greeted by this screen filling disk of hot plasma:
I have experimented recently with zone plates, which are the 2‑D equivalent of a chirp. Zone plates make for excellent test images to detect deficiencies in image processing algorithms or display and camera calibration. They have interesting properties: Each point on a zone plate corresponds to a unique instantaneous wave vector, and also like a gaussian a zone plate is its own Fourier transform. A quick image search (google, bing) turns up many results, but I found all of them more or less unusable, so I made my own.
Zone Plates Done Right
I made the following two 256×256 zone plates, which I am releasing into the public so they can be used by anyone freely.
Cosine zone plate
Sine zone plate
I vaguely remember someone making a comment in a discussion about sRGB, that ran along the lines of
So then, is sRGB like µ‑law encoding?
This comment was not about the color space itself but about the specific pixel formats nowadays branded as ‘sRGB’. In this case, the answer should be yes. And while the technical details are not exactly the same, that analogy with the µ‑law very much nails it.
When you think of sRGB pixel formats as nothing but a special encoding, it becomes clear that using such a format does not make you automatically “very picky of color reproduction”. This assumption was used by hardware vendors to rationalize the decision to limit the support of sRGB pixel formats to 8‑bit precision, because people “would never want” to have sRGB support for anything less. Not true!I’m going to make a case for this later. But first things first.