Applying IBL split-term approximation to transmitted specular

Started by
1 comment, last by dpj 8 years ago
Hi all,

Recently I was doing a little experimentation with real time transmitted specular for cubemap light probes (for a real-time glass shader).

Many of us are probably aware of the split-term approximation (and variations of it) for used for the reflected specular component in image based lighting. This decomposes the GGX equation that determines the appearance of the reflection into 2 separate parts -- one roughly corresponding to the blurriness of the reflection, and other part corresponding to the brightness.

But the paper that originally introduced the term GGX was actually about transmitted specular (ie, what we might have previously called refractions). So I got to wondering if the same split-term idea could work for this part, as well... There's been a lot of research into order independent transparency methods recently -- so doesn't it make sense we should have good equations for transmitted specular to go along with it?

I wanted to share my experiences in case anyone else had tried this (and also because it's a little interesting).

I started working with the equations in "Microfacet Models for Refraction through Rough Surfaces" by Walter, et al -- "the GGX paper". I found that mostly it works the same for transmitted and reflected -- except for one really important part.

The term that caused me problems was this:

FocusingEqn.png


I called this the "focusing term" because it seems to control how the brightness of the transmission changes due to light being focused due to refraction. Walter describes how he developed this term as an approximation of the derivative of the angle of the transmission half vector with respect to the outgoing angle (ie, see equation 17).

So, if the outgoing angle changing more slowly than the half vector, then we will get focusing of light -- and a brightening effect.

Now, there are two problems with this for our split term approximation. The first is that Walter's equation was designed for ray tracers. But the sampling we do when building the split term approximation is slightly different. For most of the GGX math, it doesn't actually matter. But in this case, we actually need an derivative with respect to the incoming angle (not the outgoing angle).

So, we could just flip the variables around a little bit and use the same approach as Walter... But there was something about Walter's approximation that didn't feel perfect yet. I had seen other approaches to solving this same approximation (for example, from Jos Stam in a paper related to skin rendering). Walter's is definitely better... But I started to play around with different approaches.

This is where it get a little complicated. I found that if I considered the outgoing direction constant, then I could use i.o and ht.o as the cosines of the angles in equation. We can build equations for these, and use an algebraic approach to take the derivative of the angles. The result is a very complicated and awkward equation... This is not a real-time equation (it's only used when generating split-term lookup tables). But, it would still be better to have a simpler equation. By hand I came up with a reasonable approximation, which looks like this:

SimpleEqn.png

Where "a" is the ratio of the indices of refraction.

So, armed with this new version of the "focusing term", and adding in all the other elements of the GGX transmission equation, I finally created 2 new split-term lookup tables, that give us a nice, viable real time approximation!

GlassSphere.png
(the background texture here is from sIBL Archive)

I haven't extensively tested the math. But I did find that the focusing term helped a lot make the material "read" like glass. It also helps with shape cues. Without the focusing, the material tended to look oddly flat (even with the distorted shape of the refractions). Even though the focusing is subtle, my eyes seemed to miss it when it wasn't there.

I also found that I would reuse the blurred reflection texture for refraction -- and that actually, it was the same focusing term than allowed me to find a relationship between the amount of blurriness in the reflections and the amount of blurriness in the refractions!

In the end, the real-time cost is only slightly more expensive that the reflection case. But it is an extra IBL tap. Oddly enough, I originally started thinking about this for foliage. Because if we had bright lights burned into the IBL environment, it would appear strange if leaves didn't let through at least some light. But after looking at the video for "A phenomenological scattering model for order-independent transparency" by McGuire and Mara, I noticed that the glass sometimes had that oddly flat look... So I think this focusing term could be useful in that kind of situation.

If anyone has tried something similar, I'd love to hear about it. I've also got a little more detail and screenshots on this blog post.
Advertisement
Thank you for the information. It looks useful and gives a nice result.
How about some snippets from the implementation?


L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

All the code for this engine is open source. The most relevant parts are here:

https://github.com/xlgames-inc/XLE/blob/master/Working/Game/xleres/Lighting/IBL/IBLPrecalc.h

https://github.com/xlgames-inc/XLE/blob/master/Working/Game/xleres/Lighting/LightingAlgorithm.h

It's still a bit rough, but you can see some of the experiments and variations I tried.

BTW, I thought I remembered your name from somewhere... I ran across your DXT compressor a few months ago, when looking for a BC6H solutions ^^.

This topic is closed to new replies.

Advertisement