开发者

Subtractive blending with OpenGL?

I would like to for example draw shapes A, B, C then set the ble开发者_如何学Pythonnder, then draw shape D and everywhere where shape D is, the scene shows my background color of (1,1,1,0). Thanks


I'm not aware of that being possible directly. There are a few possibilities to get the same effect though. The cleanest would probably be to start by filling the stencil buffer with 1's, then drawing shape D into the stencil buffer with 0's, then draw everything else (with the stencil buffer enabled, of course).


Much simpler than other answers :

  • Display shapes A, B and C the normal way
  • glDisable(GL_DEPTH_TEST);
  • glDisable(GL_ALPHA_TEST);
  • glDisable(GL_BLEND);
  • Display shape D with color (1,1,1,0)

and you're done.


glBlendEquation can do it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜