PDA

View Full Version : how do "depth of field" ?



airseb
05-26-2003, 08:08 AM
hi !
i have read the section "depth of field" of the redbook and i wonder how i have to use glFrustum and the rest if something else is necessary.
I think that it is a question for advanced programmers, so thanks for your help !


[This message has been edited by airseb (edited 05-27-2003).]

knackered
05-26-2003, 08:14 AM
Are you sure you don't mean "field of view"?
As far as I remember, the red book doesn't talk about depth of field, as that's more of a research area rather than an OpenGL specific area.

airseb
05-26-2003, 08:26 AM
in fact, i have the redbook in french and they speak of "depth of field" ("profondeur de champ" in french)in the chapter 10 about the different buffers but they explain it quickly and somebody told me that maths were required, so i post here to know what maths are required and how it works if you can help me.

jwatte
05-26-2003, 08:42 AM
A mock-up, with source, of depth-of-field using very few extensions, can be found here:
http://www.mindcontrol.org/~hplus/graphics/dof.html

Quality can be enhanced with more work.

Humus
05-26-2003, 08:45 AM
Depth of field can be done by rendering scene into a texture and storing the depth in the alpha. Then apply a blur filter on that texture rendering it into another texture. Then use the difference between the stored depth and plane to ineterpolate between the blurred and non-blurred scene textures. This will require GL_ARB_fragment_program alternatively heavy multipassing though.

[This message has been edited by Humus (edited 05-26-2003).]

Mazy
05-26-2003, 09:02 AM
Sort of http://192.48.159.181/discussion_boards/ubb/smile.gif
ive done it in 6 passes on hardware that only supports destination alpha, and for simplicity vertex program ( but that could be done by the CPU instead.)

but i do it exacly as described by Humus

vincoof
05-27-2003, 03:52 AM
airseb, I guess you're referring to the chapter that uses accumulation buffer for the depth-of-field effect. In fact, this method is rarely used because hardware-accelerated accumulation buffers are not very common nowadays. Cards are just starting to implementing it, just like stencil started to be implemented in hardware few years ago.