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

Thread: How to read stencil buffer in glsl?

  1. #1
    Junior Member Newbie
    Join Date
    May 2014

    How to read stencil buffer in glsl?

    I have two questions about using stencil buffer:
    (1) How can I read stencil buffer in glsl?
    (2) If (1) is possible, should I bind it as a texture ? How to do it?


  2. #2
    Member Regular Contributor Agent D's Avatar
    Join Date
    Sep 2011
    Innsbruck, Austria
    If you render to an FBO, you can always bind a depth/stencil or stencil only target and after the FBO pass is done bind the
    stencil texture as a regular texture and read from it.

    Reading from the stencil buffer you are rendering to is AFAIK not possible, as stencil testing (as well as depth testing and blending)
    is done on the result of the fragment shader, after the fragment shader for the given fragment has been executed.

Posting Permissions

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