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
+4
A:
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).
Jerry Coffin
2010-07-29 16:48:06
+1 I was just about to suggest that!
Blindy
2010-07-29 16:54:54
It's not? If I have a shape set to 1,1,1,0 the result of SUBTRACT operation should make the new pixel 1,1,1,0?
Milo
2010-07-29 16:58:19
@Blindy The question title refers to substractive blending, but now that you mention it, the question body refers to another completely different matter.
Matias Valdenegro
2010-07-29 17:50:25
A:
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.
Calvin1602
2010-07-29 22:04:35
@Jex you may want to disable depth writes as well, depending on what you're trying to do
Calvin1602
2010-07-30 15:20:03