Fixed the issue of opaque surfaces appearing black. Thought my fix was a hack, but turns out the original paper had the same idea, so I don’t feel too bad.
The fix is to not have opaque surfaces, that is - alpha has to be in range 0 <= a < 1, I got pretty bad numeric instability with the recommended 0.999 limit, but 0.997 on f32 textures works fine for me.
Opaque surfaces still look a little suspect, but close enough if you don’t look too hard. The problem lies in the transmissive curve reconstruction I suspect, the original paper strongly suggests that
Here are the graphs from the paper (figure 2)
As you can see the reconstruction is pretty hand-wavy, and for β values below 1 you get underestimate on absorbance. I’m using β value from the paper, which is 0.25, so it’s in that domain too.
The graph is for 6 bower moments, I’m using the 4 power moment variant.
Trig moments I expect should help for this case, based on the graphs from the paper
But I’m happy enough for now.
While testing the code, I accidentally ran into another usecase where OIT makes a massive difference: hair.
Here’s a shot of a model with somewhat complex hair with a number of layers looks like in Shade
It looks good, so good that it’s hard to believe this is a standard principled BRDF and not a specialized hair shader. Here’s the same thing in three.js
And just to hammer the point home about sorting, here’s a pretty hard model of a bunch of water bottles in a wrap. It’s hard because each bottle is not an individual instance, so sorting instances doesn’t help here. It’s also hard because there is no correct order possible even if they were separate instance, due to the wrap containing everying. And finally, there’s water inside the bottles, which makes the whole thing more complex.
I’d say it’s both impressive and not. Not impressive because you can achieve this many different ways, but to me it’s impressive because there is no sorting involved. Sorting is expensive and GPUs are bad at it due to data dependencies an incoherent access patterns.







