V002 Bokeh Under the Hood Procedure

gutsblow's picture

I have recently stumbled upon Vade's Bokeh video.

v002 Bokeh preview from vade on Vimeo.

I have to say, that is really impressive demo and even more astonishing is the fact that it is realtime. Not sure, if he has released it, but I have gone through the description, but I don't get the process exactly.

First of all, it is mentioned that it uses 'Point Spat' technology. Does that mean every pixel in that image is actually a point sprite? If so, it would be drawing a million point sprites every frame, for a basic 1024x1024 image size?.(in realtime).

Or the is the Circle of Confusion(CoC) calculated for every pixel and only if the CoC is greater than a certain value, a point sprite is overlayed on that region. I'm guess this is an efficient way to do, but I would love to know how its achieved. Thank you.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

vade's picture
Re: V002 Bokeh Under the Hood Procedure

I really need to come back to this, and clean it up...

Basically, your second explanation is fairly close to what I am doing. There are some issues however, 1 is density, 2 is regularity, 3 is the fact that it ends up being a rather slow process. I am also using geometry shaders, which after a certain update to Mac OS X 10.6 (I believe it was 10.6.4), the software fallback path on ATI got exponentially slower due toboth the fragment and the vertex pass falling back. Previously, only the vertex portion fell back to software.

I do have some ideas on cleaning it up however, and making it somewhat more organic. Time. Energy. I need more of both.

lookitscook's picture
Re: V002 Bokeh Under the Hood Procedure

Thought I dig this up rather than make a new thread. I'm working on the same thing, with the end goal being decent DoF blur with the Kinect (though it looks like the NI masked blurs will do nicely for now).

If anyone else is interested in implementing/optimizing bokeh/point-splatting I've attached a quick example with a core image filter I adapted from some code in the oF forum (http://forum.openframeworks.cc/index.php?topic=8583.0)... it's slow, but works.

Also, I only get a small, white centered square when I try using the NI Bokeh patch, what am I doing wrong?

bokeh.qtz3.12 KB

gtoledo3's picture
Re: V002 Bokeh Under the Hood Procedure

A somewhat "cheap" way of doing Bokeh is to make a blur that blurs according to luminosity.

Then, you feed it whatever gradient you need along with white or colored specks in your target places. It's pretty easy to generate those specks with some GL Points. I place the points in Over mode, with some alpha value, so they are somewhat translucent, and start to match color of whatever they're laying over. I usually use OpenCV and heavy levels of thresholding (I don't really want that many points).

psonice's picture
Re: V002 Bokeh Under the Hood Procedure

What you probably want is this: http://advances.realtimerendering.com/s2011/White,%20BarreBrisebois-%20Rendering%20in%20BF3%20(Siggraph%202011%20Advances%20in%20Real-Time%20Rendering%20Course).pdf (particularly the big section on highly efficient hexagonal bokeh rendering with DOF).

In most cases that will be much more efficient than splatting. Where splatting wins out is where you just want a few spots that show bokeh, but you want a big COC, because the fill-rate hit from the splatting isn't too heavy and the big COC means a nasty hit with any of the blur methods.

Oh, and you'll also want splatting if you want an unusual bokeh shape - square + hexagon are easy with a blur, circles can be done with a smaller kernel, but if you want it heart shaped or something with a large COC you'll have to splat.