PDA

View Full Version : Both sides blending



michalsz
03-11-2011, 11:27 AM
Hi, I'm trying to display anaglyph. I know how it should work, but I have problem with blending. I will explain it by example. I want do display some black text as anaglyph. Cyan text is drawn first, and then red one. Then red text is closer to observer blending works fine - every pixel where red text covers cyan is black. But when scene is rotated and cyan text is closer, it covers red text without blending.
Here's pseudocode:


glEnable(GL_BLEND);
glColorMask(CYAN);
TranslateLeft();
DisplayText();
glColorMask(RED);
TranslateRight();
DisplayText();
glDisable(GL_BLEND);


What could be wrong?

EDIT:
I've forgotten about clearing depth buffer, and that caused problem. Sorry, my bad.

ZbuffeR
03-11-2011, 02:10 PM
As a side note, no need for blending when using colormask. This can reduce rendering time.