Hi all, I would like to apply a depth of field on my render. Does anyone know how I can do this? Luckily, all my objects are black, and are fogged white into the distance - so I can use my actual render as a depth map if need be. I tried mocking it up in aftereffects using the Lens Blur filter and using my render as the depth map as well, and it looks gorgeous … If I can do that in realtime I would be very happy
Here are a couple of forum links that might be of help.
This raytracing code included some nice depth of field effects:
Using FBO for blur - you could do this and combine it with some sort of blend based on blur amount so that closer stuff has less blur and further stuff has more blur:
Thanks theo, I want it as realtime as possible, so I’ve started down the FBO route and it looks quite promising … almost there!
check out this paper:
it explains every step needed to achieve dof with shaders on the GPU in real time. Even though this is HLSL it should be possible to port it to GLSL. I am unfortunatelly busy with other things right now but I will give it a try in the next weeks. You can also achieve real time ambient occlusion with similar techniques.
I just saw that someone else was faster:
includes all the shaders. if you can get it to work within OF Id love to see some source code.
I think you forgot the link
** EDIT **
I’m sure that link wasn’t there when I posted!! anyways will check it out thanks…
well there are ways where the occlusion factor gets generated in real time:
check this out. its not real ambient occlusion but a fake one which gets used in games like crysis.
I implemented a working dof:
Discription and related shader source linked on vimeo. The whole thing runs at 60fps.
ah cool, i’ll check out that code. I think i never got round to posting my dof stuff. I’d posted some early dof code at http://www.memo.tv/realtime-gpu-based-d-…–glsl-v0-1 but then discovered some super crazy fast blur algorithms (where you expand the number of pixels between the neighboring pixels in the blur kernel) so you can blur the entire HD screen until the whole screen is just one big smudge - all at 60fps will post that once I tidy it up and have a video sample… so much to do, so little time…
yeah that sounds great. I can blur the whole screen at 60fps too but not in one pass