art with code

2010-06-06

WebGL stereo rendering demo


Cross your eyes and prepare for eyestrain, here comes the WebGL stereogram. Drag with LMB to rotate, drag with MMB to pan, wheel zooms, shift-wheel scales model.

The demo uses glScissor and glViewport to restrict drawing to one side of the viewport, then draws the scene to the left and right sides with the camera offset slightly. The camera offset is along the right-vector of the camera and you can get it by finding the normal of the camera up and look vectors. Basically right = cross((lookAt - position), up), then leftEye = position - (sep/2 * right); rightEye = position + (sep/2 * right). Then you render to left viewport from rightEye and to the right viewport from leftEye.

5 comments:

Anonymous said...

Can't see anything. I heard OPENGL ES doesn't support stereo?

Ilmari Heikkinen said...

It renders the same image twice, at slightly different angles. It doesn't use any OpenGL stereo stuff. It works here on 64-bit Linux, Chrome, HD4200.

I don't know why it doesn't work on your machine. Maybe something in the WebGL-driver-path limits the mesh size to 65536 tris. Maybe you're using a Mac and its OpenGL driver hates shaders (the current bane of my life). I don't know. If you know, please tell me and I will try to fix it.

Anonymous said...

Sounds like a cool demo but I can't access the link, http://www.cs.helsinki.fi/u/ilmarihe/jscene/demos/stereo.html, due to access permission issues. Appreciate your help in fixing this.

Cheers,
surinder

Ilmari Heikkinen said...

The university account expired, so demos there are now offline.

Anonymous said...

In that case, if its not too much trouble, could I request you to email a tarball of the demo to me @ srplsnh@gmail.com ?
Thanks !
-surinder

Blog Archive