Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: Logarithmic depth: Why w + 1?

  1. #1
    Intern Newbie
    Join Date
    Feb 2013
    Posts
    39

    Logarithmic depth: Why w + 1?

    Hi.

    I'm implementing the logarithmic depth buffer as described in:

    http://outerra.blogspot.co.uk/2013/0...mizations.html

    But nowhere in any of the articles that preceded the final version does anyone say why they use 1.0 + gl_Position.w
    and farplane + 1. Where does this + 1 term come from?

  2. #2
    Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    369
    log(1) = 0, so it's probably to shift all the depth values into non-negative values. Also, Z=0 without the +1 would result in a NAN or similar math error when you took the log.

  3. #3
    Intern Newbie
    Join Date
    Feb 2013
    Posts
    39
    Makes sense, thanks!

Tags for this Thread

Posting Permissions

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