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

Thread: Linearized depth for shadowmap

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    177

    Linearized depth for shadowmap

    Hello,

    for improving precision of my shadow maps I would like to use linear depth distribution of the z-buffer. I have tried to modify the projection matrix like this, also playing around with different signs:

    mp[10] = 1 / (far - near)
    mp[14] = -n / (far - near)

    Additionally I am premultiplying the transformed z with w in the vertex shader but it doesn't seem to work. Has anyone done this before?

    Thanks a lot!

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2005
    Location
    South Tyrol, Italy
    Posts
    105

    Re: Linearized depth for shadowmap

    I think you shouldn't modify the projection matrix at all as the outcome of multiplying the vertices with this matrix will be used for proper clipping. Changing it will only get you into trouble later on. Instead compute the linear depth value in the vertex shader based on camera and vertex position and store this into a floating point render target. I think with proper scaling into the [0, 1) range it would also be possible to use an RGBA8 target with some packing and unpacking.

    [ www.trenki.net | vector_math (3d math library) | software renderer ]

Posting Permissions

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