PDA

View Full Version : Depth of Field + Translucency



sqrt[-1]
06-15-2009, 04:57 PM
Currently, the Depth of Field (DOF) I am using takes a resulting depth buffer value and blurs accordingly. While this works OK for opaque geometry, I am having some issues with handling translucent geometry.

Eg. I either do not render into the z, in which case translucent geometry gets the DOF of what was behind it.
Or, I render the translucent geometry with z values (after the color buffer has been laid down) and then run into issues with looking through windows etc. (Distant mountains etc are not DOFed)

I have seen some people render a z that is based on how opaque the object is (eg. almost fully opaque, render the object z in the correct position, almost fully tranparent, render at a far distance).

I was wondering how other people are handling this issue. (or of they do DOF in a completely different way that I am missing something?)

zed
06-15-2009, 05:26 PM
good minds think alike
http://www.gamedev.net/community/forums/topic.asp?topic_id=535789

Actually I was gonna relook at the whole DOF issue again in the next couple days ( I believe I might of solved the halo effect, well at least on paper its solved reality often disagrees )

sqrt[-1]
06-15-2009, 06:50 PM
Thanks for the link. The "write blur factor into alpha" might prove useful.

If you have any other ideas, be sure to let me know.

FYI: I have read that some games solve the "halo effect" of DOF by pre multiplying the blurred depth buffer by the depth/alpha then rendering on top with blend state ONE,ONE_MINUS_SRC_ALPHA (instead of SRC_ALPHA,ONE_MINUS_SRC_ALPHA) (Sorry if this is not clear, I'll try and find the paper if you are interested)

zed
06-16-2009, 01:35 AM
(Sorry if this is not clear, I'll try and find the paper if you are interested)shes right, that was similar to what I had in mind (though without the blending), I was thinking of altering the first inputtexture for the blur shader (based on whether or not to blur)

Ive been looking at DOF again tonight for the last couple of hours, gah I dont know, sometimes I think its good + sometimes I think its bad. I think the key is to have it really subtle + to alter the blurred image a bit (eg reduce contrast)
http://ps3media.ign.com/ps3/image/article/947/947694/uncharted-2-among-thieves-20090123092107648.jpg

zed
06-17-2009, 02:05 AM
I tried the above method + I dont think it works that well
the only way I see is to
1/ do solid stuff with DOF
2/ do transparent stuff with DOF as a separate pass (separate blur etc) blended over the top, thus quite expensive. One thing u could do is render this stuff as 1/4 or even 1/16 size ( u prolly do this alread with the DOF buffer )

Ive decided to ignore DOF with particles (it looks better that way than using the existing blur factor) then again I dont have any windows

dletozeun
06-17-2009, 03:22 AM
I either do not render into the z, in which case translucent geometry gets the DOF of what was behind it.


You mean that in this case, the translucent surface is not blurred but only what is behind it?

Timothy Farrar
06-17-2009, 07:16 AM
A possibly cheap option for DoF on opaque geometry followed by blend-in of particles: compute a blur factor in the vertex shader from Z, and pass this into the particle pixel shader to either use as a LOD bias, or to blend between a sharp and blury version of a texture (perhaps a NxNx2 3D texture, or NxNx4 3D texture for 4 blur states). Post DoF particles might be able to use the free down-sampled depth buffer for faster soft particle effects...

sqrt[-1]
06-17-2009, 04:28 PM
You mean that in this case, the translucent surface is not blurred but only what is behind it?

No, If the window is supposto be in focus, and the background "mountain range" is out of focus, the window will be blurred the same amount as the distant "mountain range".

The only correct resolution of this is to do depth peeling - but I was hoping for a hack. (some of the separate blending of translucency geometry suggesting seem promising)

I was also thinking of of "render everything that is behind the DOF plane", blur it, then render everything in front and combine..(have not thought this through yet)