Horde3D
http://horde3d.org/forums/

Stereo rendering
http://horde3d.org/forums/viewtopic.php?f=2&t=777
Page 1 of 1

Author:  wakko [ 10.06.2009, 13:00 ]
Post subject:  Stereo rendering

How do I enable stereo-rendering?
I have discovered the CameraNode parameter "OutputBufferIndex" where I can
set for which eye I want to draw the scene, but what additional steps will
be necessary? Will stereo rendering work without any native OpenGL instructions?

Author:  marciano [ 10.06.2009, 22:17 ]
Post subject:  Re: Stereo rendering

You need to create a quad-buffered OpenGL context, for example by using the GLFW_STEREO flag. But please note that only expensive workstation cards like the NVidia Quadros have quad buffer support, so if you have a consumer card you won't be able to use the quad-buffer (left buffer, right buffer) stereo.

Author:  wakko [ 11.06.2009, 11:48 ]
Post subject:  Re: Stereo rendering

Thanks for the hint.
I will report if I get this running with SDL.
Should be something like
Code:
SDL_GL_SetAttribute(SDL_GL_Stereo, 1);

Author:  wakko [ 19.06.2009, 19:41 ]
Post subject:  Re: Stereo rendering

According to http://www.gali-3d.com/archive/articles/StereoOpenGL/StereoscopicOpenGLTutorial.php
I have to do the following steps to achieve stereoscopic rendering:
Quote:
1) Set the geometry for the view from left human eye
2) Set the left eye rendering buffers
3) Render the left eye image
4) Clear Z-buffer (if the same Z-buffer for left and right image is used)
5) Set the geometry for the view from right human eye
6) Set the right eye rendering buffers
7) Render the right eye image
8) Swap buffers


To transfer this to Horde3D I will enable quad-buffering by setting the appropriate
flag for GLFW/SDL (e.g. SDL_GL_SetAttribute(SDL_GL_Stereo, 1); ) and then render my scene
from two different eye-positions as follows:
1. - 3.) This should be easy as I can render as usual:
Code:
        // left eye
        Horde3D::setNodeTransform( _cam, 0, 0, 0, 0 ,0, 0, 1, 1, 1 ); // fixed view only
        Horde3D::setNodeParami(_cam, CameraNodeParams::OutputBufferIndex, 0);
        Horde3D::render( _cam );

4.) Do I have to clear the Z-buffer manually? If yes, how do I do that? I think this would require
some native OpenGL calls.
5. - 8.) To render the scene for the right eye's position I think that I have to translate my
camera's position by my eye-distance to the right and then set the OutputBufferIndex to my
right eye's buffer. Do I have to translate the camera manually or does Horde3D automatically
adjust the eye-position when I set the buffer to the right eye?
Finally I would call Horde3D::render(_cam); again to get my right eye's view rendered
to the appropriate buffer and then swap buffers.
Code:
        /*
           clear Z-buffer here....
        */
        // right eye
        Horde3D::setNodeTransform( _cam, eyeDistance, 0, 0, 0 ,0, 0, 1, 1, 1 ); // fixed view only
        Horde3D::setNodeParami(_cam, CameraNodeParams::OutputBufferIndex, 1);
        Horde3D::render( _cam );
        SDL_GL_SwapBuffers();


Is anything wrong or missing in this approach? I am not quite sure about how to perform
the eye-offset and how to clear the Z-buffer.

Author:  marciano [ 19.06.2009, 20:27 ]
Post subject:  Re: Stereo rendering

Your steps are all right. Clearing the depth buffer is done in the pipeline scripts. If you use the sample pipelines, you don't have to take care of that yourself.
You need to set the transformations of the cameras yourself. Just translating the cameras is usually not enough, you should at least rotate them so that they focus a single point. But it is better (more correct) to use an asymmetric frustum instead. Here is a good article that shows the math.

Author:  wakko [ 11.07.2009, 12:50 ]
Post subject:  Re: Stereo rendering

I got it working and made a wiki article about this:
http://www.horde3d.org/wiki/index.php5?title=Tutorial_-_Stereo_rendering

Would be great if someone could review it.

Author:  marciano [ 12.07.2009, 09:46 ]
Post subject:  Re: Stereo rendering

Thanks for the article, adding such things to the wiki is the way to go :)
There are two things that I noticed: finalizeFrame should just be called once per frame. The other thing is that your camera matrix calculation is not very robust. For correct result, you should really use an asymmetric frustum, as described in the article I mentioned before. It is some basic math, nothing really complicated. Setting the frustum planes can be done with the CameraNodeParams in Horde.

Author:  Volker [ 12.07.2009, 10:41 ]
Post subject:  Re: Stereo rendering

Thanks a lot for the article.
Additionally to the comment from marciano I would propose to use two camera nodes as a child of one group node. This way you can move around the camera using the group node without having to care about the parallax between the two cameras.

Author:  wakko [ 12.07.2009, 12:44 ]
Post subject:  Re: Stereo rendering

I have fixed the issue with calling finalizeFrame() too often but calculating the asymmetric frustum can still take some time.
Although the results with the symmetric frustum arent't too bad.

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/