简体   繁体   中英

Subtractive blending with OpenGL?

I would like to for example draw shapes A, B, C then set the blender, 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).

glBlendEquation可以做到。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM