Bokeh depth of field in Source.

Hey all thought I would let you in on a little trick have been working on, using entities in hammer to mimic Bokeh Depth of Field effects (seen in the latest Unreal update and Unity updates). Basically im using some tricks to mimic the effect using sprites and func_illusionary boxes with a blur texture I created (blurs anything seen while looking through it). The effect can transition between focus (fading out a “blur box” and fading in another one giving the effect of shift in focus) also the sprites will transition from a “bokeh” shape to a normal glow.

This effect would be good for use in cutscenes, background maps, and if used strategically during gameplay. I am planning to throw the effect into one of HL2’s maps and making a video of it in action but for now here is some test screens.

http://img839.imageshack.us/img839/9225/dofscreen01.jpg

http://img842.imageshack.us/img842/5774/dofscreen02.jpg

As seen in the 2 above screenshots bokeh styles are at the discretion of the artist depending on what sort of effect they want.

http://img801.imageshack.us/img801/9083/dofstyles.jpg

Please discuss, if you guys have any ideas on how I can improve this please share.

So they’re just sprites? Awww, but it still looks pretty convincing :v:

haha yeah just sprites, but im using them in very clever ways, if only sources blur shader was better…

I’ve thought of this before, but didn’t have the texturing knowledge to do it.
So does the ‘blur box’ move farther away as the player looks farther away?

There’s a blur shader? Tell me more.

How do you think valve made motion blur?

Magic?

unfortunately no.
Also there is a refract shader you can use.

Is it possible to use the refract shader on such a low level that it looks blurred and not refracting?

probably. Or just make a blurry normal map?

Yeah. That would be a pretty cool map!

That’s how Bokeh works in Unreal / Unity / CryEngine 3 / Just Cause 2 or any other game with the effect. Creates a quad for each emissive out of focus area and applies the Bokeh sprite with an average colour sample.

Garry is working on a SuperDOF Bokeh system, which could be used along with a script to make SuperDOF render every frame.

http://www.garry.tv/wp-content/uploads/2011/03/2011-03-18_00004.jpg

It’s very wip though.

Hmmm sounds promising, I cant wait to see what comes out of that.