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: http://itunes.apple.com/app/id586878367.
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:
The bug appears as low frame rate and with the main character shaded solid black, except for eyes and attachments. This hints at a numerical floating-point problem connected to soft-skinning. And indeed, I was able to track down the culprit and there are two things happening:
- There is a square-root operation in the vertex shader that generates NaN, but only when soft-skinning is enabled. This is responsible for the black shading on the characters.
- The low frame rate is related to the address register indirection used for soft-skinning. The driver is somehow mis-compiling this code, since the performance returns to normal when this part is commented out (but then, of course, the characters are not animated). There is not much that can be done about this without a fix from ATI.
I have made a patch to at least fix the visual appearance, so the characters are no longer black. Unzip the patch and replace the two shader files in the Velvet Assassin data folder. On the Mac, this is located inside the app package, exactly here:
Download the patch:
As a side effect, you’ll now get to see all the things that I did not have room to write about in the ShaderX book. For all of those who are going to dissect the shader code, you’ll find the following features in there:
- Algorithmic anti-aliasing of specular highlights (and environment maps too), when high quality is selected. It is done via a heuristic that lowers the material glossiness dependent on the ddx/ddy of the normal, so both normal-map pertubation and fine geometry is taken into account.
- Environment maps are integrated in the shading model, with automatic selection of a mip level that corresponds to the size of specular highlight.
- Two modes of alpha-transparency: One mode to be used as a transparent but solid surface (like glass), then the specular reflection is not modified by the alpha value; and another mode for alpha as a coverage value (for instance when fading-out strands of hair) so the specular reflection must be attenuated too.
- Lots of gamma/de-gamma magic.