How to do anaglyph 3D using LWJGL

I see what you mean.

But I think it’s a problem caused by rendering 2 different view ports to the same screen while ideally it should be 2 screens right in front of both eyes. Remember I’m rotating the camera’s and not the spectator’s eyes (they are still more or less right in front of the screen, no matter how the camera’s are rotated).
I think it is a small problem related to the viewing angle difference from your 2 eyes to the screen, and does not actually have anything to do with rotation of the camera’s.

But I can’t imagine it to be really noticable unless you’re really close to the screen.

I think it all comes down to this (I’ll quote myself here):

[quote]In an ideal world, you’d wear contact lenses with little monitors in them that would track the rotation of both eyes and adjust the view ports accordingly. But that’s not really viable yet, so we’re stuck with one 2D screen with a fixed view that we somehow want to translate to a stereoscopic image.
[/quote]
But I find it all quite mind boggling :o so I’m not ruling out I’m making a mistake somewhere, but I think (especially interactive) stereoscopic projection using just one screen and with no tracking of the spectator’s eyes is a trade off no matter what, caused by the fact that the cameras’ orientations will differ from those of the spectator’s eyes.

You could say that the inward rotation of the camera’s should be same as that of the spectator’s eyes, but then you still have the same problem as soon as you look at something at a different depth from the screen.

A comparison for anaglyph color mixing.

NVidia seems to use the “Optimized Anaglyphs”.

For camera, without rotation it is the “parallel method” and with rotation it is the “Toe-in method”… and there are both “wrong” :wink:

The “good” method is the “Off-axis method

Thanks for the helpful links!
I get it now and see I was wrong after all…

Sorry for the confusion and not being the sharpest tool in the shed sometimes ::slight_smile: :persecutioncomplex:

Getting back to Cameron’s 3D camera, I think the fact that the lenses can be ‘toe-ed in’ doesn’t mean he’s making the same mistake as I did.
I guess it’s still possible (and actually quite likely) that rotating the lenses inward will still film with an ‘off axis’ perspective by exposing the film (or CCD or whatever) at an angle. That’d probably even be the best way to film ‘off axis’.

BOOM! Exactly what I do. :smiley:

It make me want to redo some anaglyph stuff :stuck_out_tongue:

What glasses are you using ? (And how effective are they ?)
With a quick search, I found thoses (sorry in french, it is the second ones)

I use a pair called “Pro-X” or something. They work pretty well, but there’s some ghosting that especially noticeable in bright areas. I think the reason for the ghosting is my monitors, though.

I’m using the cheap paper ones.
My understanding is that the plastic ones (the 2nd one in the link) are doing also some focus correction on the red glass so those might be easier on the eyes and give a sharper image.

As for ghosting, I found that the monitor makes most difference here. I see a lot of ghosting on laptop screens (to the point that the 3D effect becomes almost ineffective), but on my CRT monitor and LCD TV there’s much less ghosting and the effect is quite good there.

I’m also considering to implement ColorCode 3D (amber-dark blue anaglyph). It’s supposed to look better than traditional red-cyan.

Ok first try :

I’m not sure for the view setup.

What I use for none stereoscopic view :


GL11.glViewport(viewport_x, viewport_y, viewport_w, viewport_h);
    GL11.glMatrixMode(GL11.GL_PROJECTION) ;
    GL11.glLoadIdentity();
    
    if (type == ORTHOGONAL)
    {
      GLU.gluOrtho2D(left,right,bottom,top);
    }
    else
    {
      GLU.gluPerspective(fovy,(float)viewport_w/(float)viewport_h, zNear ,zFar);  
    }
    
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadMatrix(correctZ.getFloatBuffer());

For left eye :

public void applyLeftEyes(float eyesep,float focal)
  {
    GL11.glViewport(viewport_x, viewport_y, viewport_w, viewport_h);
    GL11.glMatrixMode(GL11.GL_PROJECTION) ;
    GL11.glLoadIdentity();
    
    if (type == ORTHOGONAL)
    {
      GLU.gluOrtho2D(left,right,bottom,top);
    }
    else
    {
      float aspectratio = (float)viewport_w/(float)viewport_h;
        
      float top = (float)Math.tan(fovy*Math.PI/360.0) * zNear;
      float bottom = -top;
      
      float left = aspectratio * bottom + 0.5f * eyesep * zNear / focal;
      float right = aspectratio * top + 0.5f * eyesep * zNear / focal;
        
      GL11.glFrustum(left,right,bottom,top,zNear,zFar);
    }
    
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadMatrix(correctZ.getFloatBuffer());
  }

For right eye :


public void applyRightEyes(float eyesep,float focal)
  {
    GL11.glViewport(viewport_x, viewport_y, viewport_w, viewport_h);
    GL11.glMatrixMode(GL11.GL_PROJECTION) ;
    GL11.glLoadIdentity();
    
    if (type == ORTHOGONAL)
    {
      GLU.gluOrtho2D(left,right,bottom,top);
    }
    else
    {
      float aspectratio = (float)viewport_w/(float)viewport_h;
        
      float top = (float)Math.tan(fovy*Math.PI/360.0) * zNear;
      float bottom = -top;
      
      float left = aspectratio * bottom - 0.5f * eyesep * zNear / focal;
      float right = aspectratio * top - 0.5f * eyesep * zNear / focal;
        
      GL11.glFrustum(left,right,bottom,top,zNear,zFar);  
    }
    
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadMatrix(correctZ.getFloatBuffer());
  }

Now I wonder how to do the optimized anaglyph. Of course, there is allways the shader solution. May be I can use the GL_COLOR matrix but I only heard bad thing about it ? Accumaltion buffer ? Something else ?