PDA

View Full Version : Stereo Anaglyph using glColorMask



Jeffg
10-19-2010, 01:51 PM
Wondering if someone could verify that my cam panning is correct for the proper color or if I'm doing this completely wrong. Thanks


for(int x3d = 0; x3d < 2; x3d++) {

//3d View - Set up Color Masking
if (anaglyph) {
if(x3d == 0) {
cam.pan(2,0);
gl.glColorMask(true, false, false, true);
}
else {
cam.pan(-2,0);
gl.glColorMask(false, true, true, true);
}
}
else {
x3d++;
}
Draw a bunch of stuff...
}

aqnuep
10-20-2010, 06:57 AM
When you set the two cameras for anaglyph rendering you should set the two eye position to an appropriate distance from each other. This fully depends on your application.
Besides that, you also want to use a different view direction for the two eyes based on where is the focus distance for the "eyes".
Actually the simplest way to do it is to use gluLookAt.
E.g.:

gluLookAt(-1,0,0, 0,0,-3, 0,1,0);
... draw left eye image ...
gluLookAt( 1,0,0, 0,0,-3, 0,1,0);
... draw right eye image ...

Of course you don't have to use gluLookAt but whatever view matrix you like but the math behind it should be something similar.
So set the eye positions but don't forget to set their direction as well so the view directions intersect at the focus plane.

Jeffg
10-20-2010, 08:20 AM
Might I be able to change the eye position using glTranslate?

ZbuffeR
10-20-2010, 09:14 AM
Read "Asymmetric frustum parallel axis projection stereo" section here, at the bottom :
http://www.orthostereo.com/geometryopengl.html

The drawing is better here, read "Off-axis (Correct)" :
http://local.wasp.uwa.edu.au/~pbourke/miscellaneous/stereographics/stereorender/