Jump to content
  • Advertisement
Sign in to follow this  
jaafit

Depth of Field and Semi-Transparent Objects

This topic is 3783 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

This discussion was opened last year http://www.gamedev.net/community/forums/topic.asp?topic_id=442460 The OP and I have the same question: Given that you want a depth of field effect, how would you blur semi-transparent objects? If you give them their actual depth, they can screw up colors behind them. If you don't let them write to your depth texture, they will never be properly blurred. At the end of that thread I found the best solution I'd heard of so far: "Render the opaque stuff in your scene, and do the downsampling & DOF blur to your target buffer. Then, for each semi-transparent thing (in sorted z order), render it sharp over the opaque stuff, and re-do your downsampling & DOF (presumably clipped to just nearby the newly drawn thing)." The only problem with this method is that a blurry, semi-transparent object will always blur whatever's behind it, making crisp, opaque objects blurry and blurry opaque objects even blurrier. For example, given a car as a subject, the departing car's out-of-focus exhaust would blur the parts of the car it occluded.

Share this post


Link to post
Share on other sites
Advertisement
My friend ran into this problem while implementing this an we found it quite a pain to deal with.

One solution we thought of was to blur opaque objects like normal and then when rendering translucent objects, use the mip-lod-bias DOF trick ( doesn't work on triangle edges ). I figure it should work okay so long as all your translucent objects fade to completely transparent at their borders.

Cheers!

Eric

Share this post


Link to post
Share on other sites
Looks like they mentioned that in the previous post too.. I'm out of ideas other than that. The mip-lod should work for your example of smoke though.

Here's an overview of the best solution I have seen thus far

- Render your opaque objects
- Sort/Render Translucent objects
-- If the object is a billboard then use mip-lod-bias based on depth
- Render translucent objects again into the depth buffer
-- Excluding billboards etc from above
- Post-Process DOF

If an object is just a translucent mesh that it might be worth rendering its depth and blurring it as if it were opaque. This will only blur the closest object so you should only do it if it is fairly opaque. Definitely don't do it for things like billboards and the like that have an alpha channel.


On another note the basic downsample and mix based on depth has issues with color bleeding too. For example a sharp foreground object will blur into a blurry background object and vice versa. The only solution to that that I can think of is to use a really expensive full-screen effect that checks each pixel's depth before using it in the blur.

Eric

[Edited by - WizardOfOzzz on February 8, 2008 5:02:45 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!