Stencil Buffer
#OpenGL #CG
ピクセルをマスクしていろいろな描画を行う
登場人物
Func: ステンシルバッファとの比較のしかた
Ref: ステンシルバッファとの比較に用いる基準値
ReadMask: ステンシルテストの際、ステンシルバッファ・基準値の双方にANDされるビットマスク
WriteMask: ステンシルバッファに書き込む際、このマスクのビットだけ変更される
例えば、 255 に対してWriteMaskが 3 で Zero Opを行うと、結果は 252 になる
Op: ステンシルテスト・デプステストの結果に応じてやること
Fail: ステンシルテストに負けたとき
ZFail: ステンシルテストに勝ったがデプステストに負けたとき
ZPass (あるいはPass): ステンシルテスト・デプステスト双方に勝ったとき
Funcの種類
Always: true
Never: false
Less: (ref & mask) < (stencil & mask)
Lequal: (ref & mask) <= (stencil & mask)
Equal: (ref & mask) == (stencil & mask)
Notequal: (ref & mask) != (stencil & mask)
Greater: (ref & mask) > (stencil & mask)
Gequal: (ref & mask) >= (stencil & mask)
Opの種類
Keep: stencil
Zero: 0
Replace: ref
Incr: ref ++、ただし最大値でクランプ
IncrWrap: ref ++、ただし最大値で0に折り返し
Decr: ref --、ただし0でクランプ
DecrWrap: ref --、ただし0で最大値にクランプ
Invert: ~ref (Bitwise Negation)