Depth mapped lens flares!
by Spencer Tweed on Aug 21, 2016 at 4:20:06 am
I realized that by using this old-school technique you could write an expression that would automagically turn off your lens flare if it went behind an object based on a z depth render: http://www.motionscript.com/design-guide/obscuration.html. I don't know why no one else has done this before, but I couldn't find anything online so I wrote my own expression and am sharing it! Here it is as an animation preset, to work with Optical Flares. As a warning I just threw this together a few minutes ago and I'm sure it could be taken MUCH further... (which I'll inevitably do in short order. I plan on linking this to 3D lights too).
The main down-side of this approach right now is that the light doesn't smoothly fade out as it get's closer to the depth theshhold. I did put a sort of fade paramenter in there (light radius) but that only fades the light out along the depth values as can be seen if you test it out on a gradient ramp. However if you have a very near point next to a far point it doesn't do much... a possible solution is to blur your z-depth image, but then the lens flare will start to encroach into your foreground object. Anyone have an idea how to solve this? Some sort of convolve filter?