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-enginesamaritan-demo
Slide 33/42
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?
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-enginesamaritan-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?
http://mynameismjp.wordpress.com/2011/02/28/bokeh/
http://mynameismjp.wordpress.com/2011/04/19/bokeh-ii-the-sequel/
There I fixed - and this should be in the "code" category.
http://mynameismjp.wordpress.com/2011/04/19/bokeh-ii-the-sequel/
There I fixed - and this should be in the "code" category.
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...
before blur: color=pow(color, 10.0);
after blur: color=pow(color, 1.0/10.0);
and rendertarget should be float-32bit-per-component...
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
I should try the per pixel sprite thingy samping the pixel color on the vertex shader and drawing an hex in the geometry shader
unc: results? ;)
Quote:
So I tried something with point sprites.
I think the "render sprites" was first done in Lost Planet 2:
Fillrate, fillrate.
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.
did you try with a sparse kernel, like a poison disk?
New graphics card, new graphics card!
Sweet.
unc: are you storing the radius in the a channel, when you do the pow thing?
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
radius is just increasing from center to the edges of the screen
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.
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.
General convolution might still be of interest if you work with discrete layers instead of continuous DOF tho.
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 :)
In addition to that fft - might be a bit painful to implement with dx9 and non power of two :)
Get your Bokeh in realtime...
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..
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?
I wonder how fast it renders, I'm guessing we are talking spf rather than fps?
Nope. fps.
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)