This post is the first in a series to follow-up on my 2012 GPU Pro 3 article about atmospheric scattering . What I showed there was a full single-scattering solution for a planetary atmosphere running in a pixel shader, dynamic and in real time, without pre-computation or simplifying assumptions. The key to this achievement was a novel and efficient way to evaluate the Chapman function , hence the title. In the time since then I have improved on the algorithm and extended it to include aspects of multiple scattering. The latter causes horizontal diffusion (twilight situations) and vertical diffusion (deep atmospheres), and neither can be ignored for a general atmosphere renderer in a space game, for example.
I have written a Shadertoy that reflects the current state of affairs. It’s a mini flight simulator that also features clouds, and other rendering goodies. A WebGL2 capable browser is needed to run it. Under Windows, the ANGLE/Direct3D translator may take a long time to compile it (up to a minute is nothing unusual, but it runs fast afterwards). When successfully compiled it should look like this:
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.
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.
This post is a follow-up to my 2006 ShaderX5 article  about normal mapping without a pre-computed tangent basis. In the time since then I have refined this technique with lessons learned in real life. For those unfamiliar with the topic, the motivation was to construct the tangent frame on the fly in the pixel shader, which ironically is the exact opposite of the motivation from :
Since it is not 1997 anymore, doing the tangent space on-the-fly has some potential benefits, such as reduced complexity of asset tools, per-vertex bandwidth and storage, attribute interpolators, transform work for skinned meshes and last but not least, the possibility to apply normal maps to any procedurally generated texture coordinates or non-linear deformations. Continue reading
(EDIT: This article is a more in-depth writeup of an algorithm that I developed around 2005, and first posted to Martin Baker’s Euclidean Space website. That time was the height of the Intel NetBurst architecture, which was notorious for its deep pipeline and high branch misprediction penalty. Hence the motivation to develop a branch-free matrix to quaternion conversion routine. What follows is the complete derivation and analysis of this idea.)
The original routine to convert a matrix to a quaternion was given by Ken Shoemake  and is very branchy. There is a way to eliminate these branches and arrive at a completely branch-free and highly parallelizable code. The trade off is the introduction of 3 additional square roots. Jump to the analysis section and the end of this article, or continue fist with the math bits.
It is good to see how physically based shading is finally gaining momentum in real time graphics and games. This is something I have been advocating for a long time. Developers are spreading the word. I was especially surprised to learn about Call of Duty: Black Ops joining the club . Even a slick 60Hz-shooter with no cycles to spare can afford to do PBS today!
This leads me to the topic of this post, the normalization of the Blinn-Phong specular highlight. Why am I writing about it? It came to my mind recently with the current batch of publications from people adopting physically based shading models. This got me checking the maths again and I compiled a list with normalization factors for different shading models, given here in this post. I would also like to elaborate a little on the model that I wrote about in ShaderX7 . Be aware this post is a large brain dump.