depth of field

hello all

i am trying to learn and make a depth of field shader, i have being looking on lighthouse 3d tutorials and slowly working through them, but there are some big holes in my unstanding.
but i have found a depth of field shader of sorts, but this shader also makes the geometry and displays the spheres in 2d. what i would like to do is pass in a 3d objects and then apply the depth of field shader. if any one could help me out, or point me in the direction that would be champion-)
when i have being hacking about small changes make it make very strange.

the shader from GLSL SandBox
and i got it from this post±mapped-projection-±light-control/10891/0


That’s a neat shader but a pretty tricky way to do DOF :slight_smile: Have you checked out ofxPostProcessing? That’s probably a better example of what you’re looking for, usually what you do is make two textures: one that encodes the distance of the pixel from focal plane the camera (i.e. white is really close, grey is far) and then one for the actual color in the shader, lookup each texture at one pixel and figure out how much blurring to do. That’s what ofxPostProcessing does and it’s actually pretty straightforward when you check out his code.

thanks that is perfect, i will have a good look at it, but it look like the addon to use!