Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 24

Thread: Depth Of Field

  1. #11
    Junior Member Regular Contributor
    Join Date
    Nov 2002
    Location
    Los Angeles, CA
    Posts
    208

    Re: Depth Of Field

    You could get a good approximation of depth in alpha just by calculating the right depth for each vertex in software or a vertex program and storing that in the alpha component of the frame buffer. This will give subtly different results though, since there is perspective in the values stored in the depth buffer so that there is more distance between distant adjacent depth values than close adjacent depth values, just as there is more distance between distant pixels and close pixels. Interpolating alpha from the vertices will be pretty much linear from the near plane to the far plane, while using the depth values will vary more rapidly for pixels closer to the camera and taper off as you get further away.

  2. #12
    Intern Contributor
    Join Date
    Dec 2002
    Posts
    69

    Re: Depth Of Field

    Thanks for your input, guys. I really want to settle on a method now - as time is running out.

    Originally posted by jwatte:
    Because the framebuffer already contains the sharp piece, you don't need to put that in a texture.
    But I need to grab the sharp image into a texture in order to blur it (ie. autogenerate mipmaps from it).

    Coriolis, I don't want to impose any requirements on the actual rendering of the scene - I've got stuff like multipass perpixel lighting and reflection going on, plus stencil shadows....and god knows what else I may eventually want to implement...therefore I don't want to make things even more complex by storing depth in destination alpha while rendering the scene.

    Has anyone implemented a depth of field effect in their applications?
    Anyone any idea how a game like Wreckless (on the XBox) does its DOF effects?

  3. #13
    Intern Contributor
    Join Date
    Dec 2002
    Posts
    69

    Re: Depth Of Field

    Just found this interview with the guys who programmed Wreckless - it's a real gem of tips, so I'm sure you'll all be interested:- http://spin.s2c.ne.jp/dsteal/wreckless.html

  4. #14
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: Depth Of Field

    I'm afraid you really have to perform another pass in order to get depth values. It's not complicated since you don't need fancy per-pixel lighting, shadows or whatever effect. You just need to render your geometry without lighting of any kind.

    About getting the distance value, I recommend 1D texturing with automatic texture coordinate generation in eye-space. It's really flexible and available since OpenGL1.0

  5. #15
    Intern Contributor
    Join Date
    Dec 2002
    Posts
    69

    Re: Depth Of Field

    Has anyone looked at the code I wrote (above)?
    Why would I need a 1d texture when I can do the subtraction in the register combiners?
    Why would I need a second scene render pass?
    I'm even more confused - I don't think we're on the same page in the book here!

  6. #16
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: Depth Of Field

    The above register combiner setup will give you signed distance. I don't get how signed distance can help you until you get the absolute value of it or until you square it.

  7. #17
    Intern Contributor
    Join Date
    Dec 2002
    Posts
    69

    Re: Depth Of Field

    You must have missed the line:-
    Code :
    out.rgb = lerp(tex0, tex1, unsigned(spare0));
    The 'unsigned' keyword is the same as abs, or so I thought.

  8. #18
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    France
    Posts
    768

    Re: Depth Of Field

    afaik, the 'unsigned' keyword means 'clamp to 0' in register combiners terminology.
    Taken from the spec :
    Code :
    [ Table NV_register_combiners.4 ]
     
           Mapping Name              Mapping Function
           -----------------------   -------------------------------------
           UNSIGNED_IDENTITY_NV      max(0.0, e)

  9. #19
    Intern Contributor
    Join Date
    Dec 2002
    Posts
    69

    Re: Depth Of Field

    Right, ok, I remember now - it's just a clamp.
    So, I square it - no problem there, done it before in register combiners, just need to adjust the texture lod for each unit, no problem.
    One parting shot from this "topic that went nowhere" :-
    I'm pretty surprised nobody seems to have much of a clue about implementing depth of field. From the bits I've read of this forum, I assumed you lot were up to date, but obviously not. You prefer to talk about the symantics of the term "bump mapping" rather than solve real problems. Do you have trouble breathing with your heads so far up your own arses?
    Over and most definitely out.

  10. #20
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Depth Of Field

    KuriousOrange,

    I've looked at depth of field, but in the context of ARB_fragment_program, where it's fairly obvious how to calculate the blur factor, so I stayed away from the register combiner specific part of your question. If you're looking for specific nVIDIA-specific extension set-ups, realize that the pool of people who want to or are able to accurately answer is much smaller.

    Also, you wrote:
    But I need to grab the sharp image into a texture in order to blur it (ie. autogenerate mipmaps from it).
    The implications of my original suggestion was that you'd render into the frame buffer, then CopyTexSubImage() into the texture; i e, the frame buffer itself doesn't need to go into a texture target, and needn't be part of the input into the second pass, except for being part of blend.
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •