Safe Haskell | None |
---|---|
Language | Haskell2010 |
The stencil test is like a configurable depth test with a dedicated additional buffer. Like the depth test, if the stencil test fails then the pixel being tested will not be rendered. The stencil test happens before the depth test, if it's enabled. For a given pixel, the stencil test passes if the following computation
(ref & mask) `stencilOp` (buf & mask)
computes true. The variables ref and mask are configurable constants, buf is
the value in the stencil buffer at the given pixel, and stencilOp is a
configurable comparison operation. The stencil op can also be set to pass
Always
or Never
.
The stencil buffer may be modified in various ways on the following events:
- When the stencil test fails or
- When the stencil test passes then the depth test fails or
- When both tests pass.
An example way of updating the stencil buffer is to write zero, or to write the ref value mentioned above to the location being tested.
example program here
- enableStencil :: Stencil -> IO ()
- disableStencil :: IO ()
- clearStencilBuffer :: IO ()
- basicStencil :: Stencil
- data Stencil = Stencil {
- func :: StencilFunc
- ref :: Int
- mask :: Word
- onStencilFail :: StencilOp
- onDepthFail :: StencilOp
- onBothPass :: StencilOp
- data StencilFunc
- = Never
- | Less
- | LessOrEqual
- | Greater
- | GreaterOrEqual
- | Equal
- | NotEqual
- | Always
- data StencilOp
Documentation
enableStencil :: Stencil -> IO () Source
Enable the stencil test with a set of operating parameters.
disableStencil :: IO () Source
Disable the stencil test and updates to the stencil buffer, if one exists.
clearStencilBuffer :: IO () Source
Clear the stencil buffer with all zeros.
basicStencil :: Stencil Source
In this basic configuration of the stencil, anything rendered will create a silhouette of 1s in the stencil buffer. Attempting to render a second time into the silhouette will have no effect because the stencil test will fail (ref=1 isn't greater than buffer=1).
def { func = Greater , ref = 1 , onBothPass = Replace }
Configuration of the stencil test and associated stencil buffer updating.
Stencil | |
|
data StencilFunc Source
The stencil test passes under what condition.