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: Black and white mask

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2010
    Posts
    1

    Black and white mask

    I'm learning OpenGL for a new project. I need to create a completely black and white mask created by clipping the view at a specified distance. What's the best way to do that? Where should I focus my reading and training to hit the ground running?

    Basically, I'm trying to create multiple masks at set clipping distances, and subtracting the masks from one another. Each mask will represent a thick slice of visible surface between two clipping distances. When stacked, they should all form a complete mask of all visible surfaces. Make sense?

  2. #2
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Black and white mask

    It sound like it would be a good use of stencil system.
    Clear stencil to 0, set your projection with desired clipping, render while writing stencil=1.
    You have you first mask.
    Then setup the second slice, writing stencil=2. Etc for each slice.
    Then to make the mask appear as black and white, clear color with white (keep stencil), use stencil test so that only stencil=1 passes.
    Draw a big black quad.
    And voilą your first mask, minus all the others.

Posting Permissions

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