so I've been working on and off on my lens diffraction project for the past few weeks and I think I finally reached a milestone yesterday. I've got something that looks correct, is relatively efficient (read: not quite 60 fps yet, but certainly interactive), and simple to implement. However I am still having problems with getting the diffraction pattern to look right, which leads me to believe I am either not using plausible aperture functions or that I'm still missing a parameter somewhere, we are getting close however.
Here is a proof-of-concept render, the left image is a stock HDRI picture of a high contrast scene without any lens flare artifacts (here a forest with a bright sky) and the right image is the same picture "augmented" with a lens diffraction pattern according to a roughly circular aperture with some noise/dust (click to enlarge):
The pattern itself is still a bit noisy because this is really the superposition of three different diffraction patterns at wavelengths 450, 525, and 650 nanometres (blue, green, and red) which leaves a bit of ringing due to aliasing, but I have an idea for dealing with those. Either way I want this implementation to be realtime, as soon as I iron out all the bugs I'll write a post-processing shader for it in DirectX and play around with modifying the aperture interactively to see what works and what doesn't.
I will unveil the tech later once I've got it all sorted out (perhaps in a GameDev article?) but for now it looks promising. I also need to develop methods to tweak it to video game HDR exposure levels, since at the moment, being physically based and all, it really only works well for real-life dynamic ranges (the effect tends to either be too weak or too noticeable otherwise). Ideally I'd like to have a few artist-friendly parameters to be able to rescale and intensify the effect as desired. I understand how rescaling would work but I am not sure about the other just yet.
Thanks to openfootage.net for the test photo.