Part of the Khronos Group

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?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Newbie
    Join Date
    Feb 2013

    Logarithmic depth: Why w + 1?


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

    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
    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
    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