Slides of my FMX 2013 presentation on Physically Based Shading

I was kindly invited by Wolfgang from Confetti FX to speak at the FMX 2013 conference about physically based shading (within the scope of the Real Time Rendering day). Since I remembered the FMX as a conference for visual arts, I made the presentation intentionally non-technical, for fear of alienating the listeners. In retrospect, my guess was a bit too conservative, as there were quite a number of programmers in the audience.

Screen Shot 2013-04-24 at 14.53.58

Nevertheless, here are the slides for download (with all notes included). The Keynote format is the original and the Powerpoint format was exported from that and is a little broken, so you should use the Keynote version if you can read it.

Download “FMX 2013 Slides (Keynote format)” – Downloaded 2174 times – 8 MB

Download “FMX 2013 Slides (Powerpoint format)” – Downloaded 3586 times – 8 MB

Followup: Normal Mapping Without Precomputed Tangents

This post is a follow-up to my 2006 ShaderX5 article [4] 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 [2]:

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

Velvet Assassin on Mac (Patch)

I just got news that Velvet Assassin has been ported over to the Mac and is available on the App Store! However, I was not at all involved in the Mac port and I don’t know the developers who did—it came as a surprise to me as to anyone else in the former team. Here is a direct iTunes link:

Shader Bug on ATI graphic cards

Unfortunately there is a shader bug with ATI graphics chips.  It happened to me while trying it out on a 2011 iMac with an ATI Radeon HD 5670. I got reports from friends that this is not a problem of the Mac port itself but it happens on PC too. The problem is related to ATI chips with drivers that are newer than 2010 or so. Here is a screenshot:

Screen shot 2013-01-11 at 04.09.06

Continue reading

FlipCode is back

Kurt has taken steps to revive FlipCode.

Flipcode was a place to discuss gamedev + algorithms with a unique flair and an outstanding audience, something IMHO never matched. I, too, was a regular visitor, poster, and also contributed the odd article and an IOTD. Terrain engines bordering on 100k polys without HW T&L will be forever in the past, but the spirit will live on.

Branchless Matrix to Quaternion Conversion

(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 [1] and is very branchy, as is tests for 4 different cases. There is a way to eliminate these branches and arrive at a completely branch-free code and highly parallelizable code. The trade off is the introduction of 3 additional square roots. Jump the analysis section and the end of this article, or continue fist with the math bits.

Continue reading

OpenGL 4.3

I just got the news about the OpenGL 4.3 spec, which was released today, and is available at The spec document has been reorganized and cleared up considerably and is a lot easier to follow than the previous specifications. New features include (ordered by importance for my projects):

  • Queries for internal texture format parameters
  • Debug output callbacks
  • Compute shaders
  • Texture views
  • and others

I’m currently on a project where compatibility and scaleability is prime, so the first two features are very welcome as development aids to make the code run robustly on a variety of platforms. Compute shaders and texture views are of course cool, but require the newest hardware, so they are lower in my list.

A nice touch by Nvidia to make to expose the new functionality as extensions on older hardware.

Cloud rendering and the relativity of whiteness

Here are some philosophical and rendering-related questions that I took home from the last vacation. What’s the color of clouds? The standard answer would be, white.
What’s the color of snow? Again, white. Ok, then look at the following picture, where the snow seems considerably whiter. This is the case in almost all photos that I took.

There is an image on Wikipedia from the same general area on which the brightness difference between clouds vs snow is even more pronounced. If you look at the directly lit parts of the snow and consider it white (#ffffff), then the directly lit parts of the clouds are at most 50% grey (#bbbbbb). Is that an evidence of air pollution? Unlikely! (At least not in Tyrol).

Continue reading

GPU Pro 3 has arrived

I found my copy of the book in the mail today. I was a little surprised by the moderate size—other volumes of this series were just that: volumes! I think this one is about half the size than the previous tomes. By the way, this post is a shameless plug because there is an article written by me in it. Thanks go to Wolfgang Engel, the series editor, and Christopher Oat, my section editor, and CRC press for making it possible! I will post some comments on the other articles when I read them through.

I found one very good and comprehensive article on data driven engine design by Donald Revie. The ideas presented in there resonate very well with the designs that I found worked well in the past, so this part gets a solid +1 from me.

(I ended up with a triad of IRenderObject, IRenderGeometry and IRenderProgram, where the render object would AddBatches() to a draw list, each of which refers to one geometry containing the mesh and one program for setting the render state. For instance, a SpeedTree™ render object would typically add three batches, one for each of the branches, fronds and leaves, where each batch would pair the specific geometry with an appropriate program. The draw list is then sorted in one go via a general 128 bit sort key, and the batches rendered in order. This system is general enough that the UI system also can just AddBatches() to this list (so the UI system, as a whole, is just one instance of a render object). In this case, the individual UI geometry objects just represent views into one big dynamic vertex buffer. I probably want to explain this system in detail in another post.)

Another two very inspiring articles so far are the one about geometric postprocess antialiasing, by Emil “Humus” Persson, and the piece about global illumination using a voxel grid, from the teams at the Unis Koblenz/Magdeburg. I already read their ACM paper before and I think it is a viable method.

Various Mac tricks

This is my personal collection of command line tricks on Mac OS X that I found indispensable. The list is far from complete, and may be added to in the future.

Show hidden files in Finder

> defaults write AppleShowAllFiles true
> killall Finder

The first line sets the preference for the Finder to show hidden files, while the second line restarts the Finder so the setting comes in effect. As an alternative for the last line, select the Finder in the Cmd-Alt-Escape popup and select “Relaunch”. I found this one on the Mozilla knowledge base [2].

Delete all .DS_Store files

> sudo find / -name ".DS_Store" -print -delete

If hidden files are enabled in the finder, you will soon make contact with the infamous “.DS_Store” files that the desktop service litters around as you browse the filesystem. This is annoying. Use the above command to delete those suckers. The “-print” is in there just so you can monitor the progress.

Prevent .DS_Store files on network mounts

> defaults write DSDontWriteNetworkStores true

Although there is no method to generally stop “.DS_Store” files, at least you can prevent desktop services from polluting network mounts. Windows users on the same network will be glad! This trick is published in the Apple knowledge base [3].

Disable Spotlight indexing for a given volume

> sudo mdutil -i off /mountpoint

This command will disable indexing for the volume under /mountpoint (for instance /Volumes/MyExternalHarddisk). Under MacOS X 10.5 and later, it also deletes any partial index created up to this point. There is one caveat: The enable/disable information is itself stored inside the “.Spotlight-V100” directory, so do not delete that, and be careful when backing up to another drive. More information is found in [1].


[1] The X-Lab, “Spotlight tips”,

[2] MozillaZine, “Show hidden files and folders”,

[3] Apple Support, “Mac OS X v10.4 and later: How to prevent .DS_Store file creation over network connections”,