Optimizing GGX: Update

Optimizing GGX: Update

Thanks for everyone who took a look at the proposed optimization of GGX that I put together in the last post. There were a few interesting discussions that came out of it with some thoughts worth post.

First off, Stephen Hill (@self_shadow) had a good idea to save an instruction or two. Instead of storing (F_avis,F_bvis), you can store ((F_a-F_b)vis,F_bvis). And then the optimized shader becomes:

Here is the new shader code. Stephen Hill’s optimization is _OPT5.

optimized-ggx.hlsl

Second, it would probably help to have some images to test with. Creating the lookup table isn’t that difficult, but not everyone has a good BC6h compressor lying around. So I’ve included the texture as an EXR as well as a BC6h compressed DDS version. The texture is 512x128.

ggx-helper.zip

Third, we have some numbers. Maciej Kacper Jagiello from ciciolog.jagiello.it did some Unity tests and posted it in a comment. And it seems to be a win over standard GGX. As mentioned before, whether it’s a win or not is highly dependent on your platform and whatever else you are doing in the shader.

comments powered by Disqus