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: The point of shadow samplers vs regular samplers

  1. #1
    Intern Contributor
    Join Date
    Jul 2009
    Posts
    53

    The point of shadow samplers vs regular samplers

    Shadow mapping is the last fronteir for me for modern GL techniques that I'd like to master. Can someone please explain to me why so many of the tutorials I find DON'T use sampler2DShadow

    Aren't the shadow samplers better? Can someone explain to me the difference between shadow samplers and regular texture samplers.
    Last edited by mlfarrell; 08-12-2014 at 02:45 PM.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,224
    Quote Originally Posted by mlfarrell View Post
    Shadow mapping is the last fronteir for me for modern GL techniques that I'd like to master. Can someone please explain to me why so many of the tutorials I find DON'T use sampler2DShadow

    Aren't the shadow samplers better? Can someone explain to me the difference between shadow samplers and regular texture samplers.
    The shadow samplers allow you to utilize hardware-accelerated depth comparisons and filtering (e.g. PCF, which is "free" on some GPUs). In other words, with the shadow samplers, the "in shadow" visibility tests and filtering are internalized in the texture lookup from the shadow map. These must be fed textures with a depth component (e.g. base type of GL_DEPTH_COMPONENT or GL_DEPTH_STENCIL), and hardware depth compare must be enabled for the texture.

    With the non-shadow samplers, what you get back is the depth values, and you have to do your own filtering. They'll work with depth component textures, but you can feed anything else you want in here instead.

  3. #3
    Intern Contributor
    Join Date
    Oct 2011
    Posts
    73
    On the topic of shadow samplers, what I can't seem to understand is the logic behind the limitation of making shadow samplers only work with depth surfaces. Is this a problem with the hardware implementation? It certainly cannot be that complicated, since it's doing little more than a filtering and compare operation. Yet, this operation still has uses on any other kind of surface; most obvious one is implementing shadow maps with linear values, but there's other more obscure uses one could apply this to.

    On nVidia drivers it's possible to use a shadow sampler on a non depth texture and it works as expected (or, at least, as what I'd expect). However, you get the required warning that this is undefined behavior, which is correct based on the GL spec.

    So just out of curiosity, is there any good reason for the spec to limit shadow samplers to depth textures?

Posting Permissions

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