pouët.net

Bokeh DOF

category: code [glöplog]
http://vimeo.com/14539543 That one is epic.

What I found so far...
http://mynameismjp.wordpress.com/2011/02/28/bokeh/[url]
[url]http://mynameismjp.wordpress.com/2011/04/19/bokeh-ii-the-sequel/


From "MartinM_GDC11_DX11_presentation.pdf" http://www.slideshare.net/drandom/the-technology-behind-the-directx-11-unreal-en ginesamaritan-demo
Slide 33/42
Quote:

For each pixel:
–Compute the Circle of Confusion (CoC) radius
–Compute viewport (foreground / backgound)
–Setup a quad with the Bokeh texture(RGB: Bokeh*scene color, A: Bokeh)
–Render quad with additive blending


Seems those guys (also MJP) render quads/point sprites with the bokeh shape based on the circle of confusion.

I wonder whether there's a better way to do that without rendering pointsprites by just using some post processing passes.

What I thought of is taking a texture with the "highlights", blur it and interpret it that as some kind of 2D distance field (of course you need to modify the range for the distance properly), I assume the gradient gives you the direction to the closest highlight and the value the distance (or something like that), now one could apply some atan2 magic and fake some kind of "hexagonal outline". Of course I didn't try that yet (Hi smash! :D) and I guess it will be more some kind of strange/cool outline rendering than a good looking bokeh fake + you don't get the bokeh shapes to blend over each other that way.

Any Ideas to get it done without using pointsprites?
added on the 2011-06-28 16:07:40 by las las
added on the 2011-06-28 16:08:48 by las las
i've been experimenting with this -
before blur: color=pow(color, 10.0);
after blur: color=pow(color, 1.0/10.0);
and rendertarget should be float-32bit-per-component...
added on the 2011-06-28 16:13:38 by unc unc
There's probably not much do to. Either you blur an HDR buffer, or you use the sprites thing. The sprites thing sounds really slow, but bluring is also really slow you you take enough pixels and do some test to check if the sample is far enough.

I should try the per pixel sprite thingy samping the pixel color on the vertex shader and drawing an hex in the geometry shader
added on the 2011-06-28 16:17:19 by xernobyl xernobyl
unc: results? ;)
added on the 2011-06-28 16:19:12 by las las
added on the 2011-06-28 16:42:58 by kb_ kb_
added on the 2011-06-28 16:43:19 by kb_ kb_
Quote:
So I tried something with point sprites.
added on the 2011-06-28 16:44:47 by las las
I think the "render sprites" was first done in Lost Planet 2:
BB Image
added on the 2011-06-28 16:48:55 by hornet hornet
Fillrate, fillrate.
added on the 2011-06-28 17:16:46 by xernobyl xernobyl
I did some experiments with bokeh a while back. All I did was a circular blur kernel, it looked ok (but ran like glue ;) It really needs HDR to work well though, then you start getting the nice circular highlights.
added on the 2011-06-28 17:26:49 by psonice psonice
did you try with a sparse kernel, like a poison disk?
added on the 2011-06-28 17:28:33 by xernobyl xernobyl
New graphics card, new graphics card!
added on the 2011-06-28 17:29:17 by las las
BB Image
added on the 2011-06-28 17:38:06 by unc unc
Sweet.
added on the 2011-06-28 17:41:41 by las las
unc: are you storing the radius in the a channel, when you do the pow thing?
added on the 2011-06-28 18:04:42 by xernobyl xernobyl
no, it is not even a real dof, only bokeh i'd say
radius is just increasing from center to the edges of the screen
added on the 2011-06-28 18:08:57 by unc unc
The problem I found was that you basically have to do a 'worst case' high blur radius kernel for every pixel. Some pre-pass magic to figure out which pixels need high radius would really help.
added on the 2011-06-28 18:28:12 by psonice psonice
I was about to suggest looking at FFT based 2D convolution but then I realized that the COC is variable per pixel. So, second fail in this thread successfully averted.

General convolution might still be of interest if you work with discrete layers instead of continuous DOF tho.
added on the 2011-06-28 19:09:36 by kb_ kb_
Jep, we already though about fft for bokeh, but yeah - you know the problem.
In addition to that fft - might be a bit painful to implement with dx9 and non power of two :)
added on the 2011-06-28 20:12:11 by las las
BB Image

Get your Bokeh in realtime...
added on the 2011-06-28 20:23:14 by cryer cryer
i never understood the point of DoF in games.. If you're supposed to feel like you're part of the thing, it doesn't help to make it look like it's imaged through a camera lens..

In demos I guess it may be justified from a technical standpoint..
That Cryengine 2 stuff in the vimeo-link in the first post looked fantastic!

I wonder how fast it renders, I'm guessing we are talking spf rather than fps?
added on the 2011-06-28 21:51:03 by Sdw Sdw
Nope. fps.
added on the 2011-06-28 21:55:18 by las las
Quote:
i never understood the point of DoF in games.. If you're supposed to feel like you're part of the thing, it doesn't help to make it look like it's imaged through a camera lens..

Actually you can experience bokeh effects with the human eye (At least I'm able to see round bokehs in certain scenarios)
added on the 2011-06-28 22:06:07 by las las

login