Quad buffer stereo
-
- Gnoblar
- Posts: 6
- Joined: Tue Sep 09, 2003 2:30 pm
- Location: Mytilini, Greece
Quad buffer stereo
Hi !
Is it possible to use quadbuffer stereo using OGRE?
We need it in order to use shutter glasses.
(As far as I know when using opengl directly you need to render to the left and the right buffer separelty and then swap the buffers. The render window needs to be initialized so that the graphics card sends sync signal to the emmiters in order to synchronize the shutter glasses)
If not, do you think it is possible to add such a feature in OGRE?
Thank you!
Is it possible to use quadbuffer stereo using OGRE?
We need it in order to use shutter glasses.
(As far as I know when using opengl directly you need to render to the left and the right buffer separelty and then swap the buffers. The render window needs to be initialized so that the graphics card sends sync signal to the emmiters in order to synchronize the shutter glasses)
If not, do you think it is possible to add such a feature in OGRE?
Thank you!
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
-
- Gnoblar
- Posts: 6
- Joined: Tue Sep 09, 2003 2:30 pm
- Location: Mytilini, Greece
Could you give me some tips?
I might be able to do something usefull in the opengl part.
(Don't have an idea about DX)
Which classes should I look into to initialize the window properly for quadbuffer stereo?
Where should I look to select the OGL drawing buffer?
A couple of starting points could be really usefull.
Thanks!
I might be able to do something usefull in the opengl part.
(Don't have an idea about DX)
Which classes should I look into to initialize the window properly for quadbuffer stereo?
Where should I look to select the OGL drawing buffer?
A couple of starting points could be really usefull.
Thanks!
- sinbad
- OGRE Retired Team Member
- Posts: 19269
- Joined: Sun Oct 06, 2002 11:19 pm
- Location: Guernsey, Channel Islands
- x 66
- Contact:
- Proton
- Halfling
- Posts: 41
- Joined: Tue Apr 22, 2003 2:34 am
- Location: Alberta, Canada
- Contact:
I have the Geforce2 GTS with the 3d shutter glasses. The stereo driver from the nvidia website makes ANY opengl or directx program work correctly with them.
I have played half-life, unreal tournament, quake, and even my own Ogre projects in stereo 3d. It looks cool if you dont mind the eye strain and headache.
Im not really sure what quadbuffer means. But you could probably pick up a cheap gf2 with the shutter glasses included.
I have played half-life, unreal tournament, quake, and even my own Ogre projects in stereo 3d. It looks cool if you dont mind the eye strain and headache.
Im not really sure what quadbuffer means. But you could probably pick up a cheap gf2 with the shutter glasses included.
-Proton
-
- Gnoblar
- Posts: 6
- Joined: Tue Sep 09, 2003 2:30 pm
- Location: Mytilini, Greece
Hm! this could be a quick solution... I have to try it.The stereo driver from the nvidia website makes ANY opengl or directx program work correctly with them.
But this is not a general solution it will work only on nvidia and it might be difficult to control parameters (such as eye distance) using your application. (you will have to use the nvidia drivers window)...
Thanks.
I have to look both cases and find out which is better in my case
-
- Gnoblar
- Posts: 8
- Joined: Sun Aug 03, 2003 8:47 am
nvidia stereo driver could do this
Hi
I've tested ogre with a nvidia quadro card and a 3D monitor.
I got this running with a tweaked Nvidia stereo driver.
If you don't find them - I can try to find one.
The biggest problem I think is that you'll need the latest nvidia driver.
But I can't imagine that there are latest tweaked driver around.
Maybe nvidia got their stereo driver running.
Good luck
Marcus
I've tested ogre with a nvidia quadro card and a 3D monitor.
I got this running with a tweaked Nvidia stereo driver.
If you don't find them - I can try to find one.
The biggest problem I think is that you'll need the latest nvidia driver.
But I can't imagine that there are latest tweaked driver around.
Maybe nvidia got their stereo driver running.
Good luck
Marcus
-
- Gnoblar
- Posts: 6
- Joined: Tue Sep 09, 2003 2:30 pm
- Location: Mytilini, Greece
Hi to all,
Sorry for not responding for some time, but I wanted to have some results. Well finally I tried both methods. Using the nvidia drivers and modifying subclasses of Ogre::RenderWindow.
Unfortunately the nVidia stereo drivers are not working with the shutter glasses that I have . (The synchronization emitter did not start)
Fortunately modifying OpenGL render window classes worked fine .
I modified Win32Window::create, and GLRenderSystem::StartRendering.
the create function
the pixel format descriptor is changed ( PFD_STEREO is added and stencil buffer is set to 1),
In case of start rendering it is a little bit more complicated
I suppose that OpenGL render window classes should not change. (Enabling the quad buffer stereo makes rendering slower (rendering is performed two times) so it should not be enabled when it is not used). Changes to the code are minor so another rendering system seems too much.
Also, I do not like changing the camera position inside the startRendering function but I could not understand the way the camera is updated so I ended up to with this solution.
Sorry for not responding for some time, but I wanted to have some results. Well finally I tried both methods. Using the nvidia drivers and modifying subclasses of Ogre::RenderWindow.
Unfortunately the nVidia stereo drivers are not working with the shutter glasses that I have . (The synchronization emitter did not start)
Fortunately modifying OpenGL render window classes worked fine .
I modified Win32Window::create, and GLRenderSystem::StartRendering.
the create function
the pixel format descriptor is changed ( PFD_STEREO is added and stencil buffer is set to 1),
In case of start rendering it is a little bit more complicated
Code: Select all
Viewport *currentViewPort;
Camera *currentCamera;
static float Offset=-0.1;
Offset+=0.1;
glDrawBuffer(GL_BACK_LEFT);
RenderTargetPriorityMap::iterator itarg, itargend;
itargend = mPrioritisedRenderTargets.end();
for( itarg = mPrioritisedRenderTargets.begin(); itarg != itargend; ++itarg )
{
if( itarg->second->isActive() )
{
// get the camera of each viewPort and add an offset for the eyes //
unsigned short nViewPorts = itarg->second->getNumViewports();
unsigned short nvp;
for (nvp=0; nvp<nViewPorts ; nvp++)
{
currentViewPort = itarg->second->getViewport(nvp);
currentCamera =currentViewPort->getCamera() ;
currentCamera->moveRelative(Vector3(-Offset,0,0));
}
itarg->second->update();
for (nvp=0; nvp<nViewPorts ; nvp++)
{
currentViewPort = itarg->second->getViewport(nvp);
currentCamera =currentViewPort->getCamera() ;
currentCamera->moveRelative(Vector3(Offset,0,0));
}
}
}
// RenderTargetPriorityMap::iterator itarg, itargend;
glDrawBuffer(GL_BACK_RIGHT);
// The same loop follows for the right eye
Also, I do not like changing the camera position inside the startRendering function but I could not understand the way the camera is updated so I ended up to with this solution.
- koutsi
- Gnoblar
- Posts: 14
- Joined: Wed Sep 03, 2003 11:01 am
- Location: Greece
- Contact:
-
- Gnoblar
- Posts: 8
- Joined: Fri Jun 04, 2004 12:27 am
- Location: São Paulo / Brazil
- Contact:
-
- Gnoblar
- Posts: 6
- Joined: Tue Sep 09, 2003 2:30 pm
- Location: Mytilini, Greece
You are right GLRenderSystem::StartRendering does not exist anymore.
I am afrraid it will not be straight forward to copy this code now
and I have not made the appropriate changes for the 0.14 version.
A !! a couple of questions.
Have you tried the other method that uses the nVidia drivers for the stereo projection ?
Well as soon as I manage to update the code for the quadbuffer stereo I will post the new source (or maybe upload them as patches)
I am afrraid it will not be straight forward to copy this code now
and I have not made the appropriate changes for the 0.14 version.
A !! a couple of questions.
Have you tried the other method that uses the nVidia drivers for the stereo projection ?
What kind of stereo projection system do you have?The stereo driver from the nvidia website makes ANY opengl or directx program work correctly with them.
Well as soon as I manage to update the code for the quadbuffer stereo I will post the new source (or maybe upload them as patches)
-
- Gnoblar
- Posts: 8
- Joined: Fri Jun 04, 2004 12:27 am
- Location: São Paulo / Brazil
- Contact:
Hi, thanks for your answer.
I haven't tried the nVidia drivers because I couldn't find a Linux version. I think that there is no Linux support for it.
As for our system, we have a 5-wall CAVE, with active stereo projectors. Here is a picture of our system:
This application wasn't made using OGRE, I'm actually working on the first one. This was a port that we made of the program called Celestia:
http://www.shatters.net/celestia/
Thanks for your time,
Victor
I haven't tried the nVidia drivers because I couldn't find a Linux version. I think that there is no Linux support for it.
As for our system, we have a 5-wall CAVE, with active stereo projectors. Here is a picture of our system:
This application wasn't made using OGRE, I'm actually working on the first one. This was a port that we made of the program called Celestia:
http://www.shatters.net/celestia/
Thanks for your time,
Victor
-
- Gnoblar
- Posts: 8
- Joined: Fri Jun 04, 2004 12:27 am
- Location: São Paulo / Brazil
- Contact:
Hello again,
I wasn't able to make the GLRendersystem (SDL) display the stereo correctly, but at least I managed to create a Window with stereo... I'll keep trying but I don't know, maybe I'm too dumb for this...
In the meantime, I came up with a solution that if not ideal, it's working for now. I created a SceneManager plugin, StereoSceneManager, and with this plugin I was able to render in stereo.
If anyone is interested I can post the code...
I wasn't able to make the GLRendersystem (SDL) display the stereo correctly, but at least I managed to create a Window with stereo... I'll keep trying but I don't know, maybe I'm too dumb for this...
In the meantime, I came up with a solution that if not ideal, it's working for now. I created a SceneManager plugin, StereoSceneManager, and with this plugin I was able to render in stereo.
If anyone is interested I can post the code...
-
- Greenskin
- Posts: 114
- Joined: Wed Feb 11, 2004 5:41 pm
- Location: England!
-
- Gnoblar
- Posts: 8
- Joined: Fri Jun 04, 2004 12:27 am
- Location: São Paulo / Brazil
- Contact:
I basically made 3 changes:
1) added an option to the OpenGL RenderSystem, just like " fullscreen"
in SDLGLSupport::addConfig() :
2) added stereo support in Window creation (if requested)
in SDLWindow::create()
Note: I don't know why, but if I create a window in SDL with the flag SDL_FULLSCREEN, the stereo is disabled. Instead, I must first create a regular one and then call SDL_WM_ToggleFullScreen(screen);
This way the stereo works just fine... strange...
3) created the StereoSceneManager
This overrides just one method: _renderScene() , and the only change in it is:
I know this is stupid, ugly, inneficient, etc... but it works... It was a desperate solution, since I must have a working demo and the deadline is closing in, and I yet have to put Ogre to work on a cluster, but that's a different story...
Oh, I also overriden the SDLWindow::getCustomAttribute(const String& name, void* pData); so I can do this (I don know if this is the best way...) :
I registered the StereoSceneManager with ST_EXTERIOR_FAR.
Well that's it... I really hope this helps someone.. any doubts or suggestions?
Victor
1) added an option to the OpenGL RenderSystem, just like " fullscreen"
in SDLGLSupport::addConfig() :
Code: Select all
optStereo.name = "Stereo Projection";
optStereo.possibleValues.push_back("Yes");
optStereo.possibleValues.push_back("No");
optStereo.currentValue = "Yes";
optStereo.immutable = false;
mOptions[optStereo.name] = optStereo;
in SDLWindow::create()
Code: Select all
if(stereo)
SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
This way the stereo works just fine... strange...
3) created the StereoSceneManager
This overrides just one method: _renderScene() , and the only change in it is:
Code: Select all
float offset = 0.1;
glDrawBuffer(GL_BACK_LEFT);
camera->moveRelative(Vector3(-offset,0,0));
mDestRenderSystem->_beginFrame();
mDestRenderSystem->_setRasterisationMode(camera->getDetailLevel());
_renderVisibleObjects();
mDestRenderSystem->_endFrame();
camera->moveRelative(Vector3( offset,0,0));
glDrawBuffer(GL_BACK_RIGHT);
camera->moveRelative(Vector3( offset,0,0));
mDestRenderSystem->_beginFrame();
mDestRenderSystem->_setRasterisationMode(camera->getDetailLevel());
_renderVisibleObjects();
mDestRenderSystem->_endFrame();
camera->moveRelative(Vector3(-offset,0,0));
Oh, I also overriden the SDLWindow::getCustomAttribute(const String& name, void* pData); so I can do this (I don know if this is the best way...) :
Code: Select all
void CaveApplication::chooseSceneManager(void)
{
bool stereo;
// check if we should load the Stereo plugin or not
_window->getCustomAttribute("Stereo",&stereo);
if(stereo)
_sceneMgr = _root->getSceneManager(ST_EXTERIOR_FAR);
else
_sceneMgr = _root->getSceneManager(ST_GENERIC); // no, get the generic
}
Well that's it... I really hope this helps someone.. any doubts or suggestions?
Victor
-
- Gnoblar
- Posts: 1
- Joined: Wed Sep 01, 2004 8:06 pm
Hello,
Thanks for the advice. It is helping us much in our progress to get a game engine with stereo abilities on our VR equipment.
Yet I am having some trouble figuring out where you placed the StereoSceneManager code and some of the other overrides. Can you give a few more specifics on part 3 or links to complete code chunks?
Please forgive me if this request is obvious. I am an old C ond OpenGL programmer fumbling his way through C++ and Ogre.
Thanks,
SilverRat
Thanks for the advice. It is helping us much in our progress to get a game engine with stereo abilities on our VR equipment.
Yet I am having some trouble figuring out where you placed the StereoSceneManager code and some of the other overrides. Can you give a few more specifics on part 3 or links to complete code chunks?
Please forgive me if this request is obvious. I am an old C ond OpenGL programmer fumbling his way through C++ and Ogre.
Thanks,
SilverRat
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
Has any-one done anything more with QuadBuffer rendering? Can it be done with Direct3D? I'm about to start in on this myself, we've got a demonstration machine using Quatro FX and passive stereo (each eye on each video out). Looks brilliant, but since it's not active stereo (as done by the nVIDIA drivers technique) we need to add support to Ogre for the QuadBuffer to show off OUR applications, rather then just the sample ones.
I'll be working on this, and if we get it, will submit the changes back up to the patch tracker, of course.
I'm looking at customising the Render System(s), since this seems to me to be a logical place for it. OpenGL first because there is example code for the buffer selects for that, then I'm going to try and hunt it up in Direct3D (since we have shader issues with OpenGL), although I'm not holding out hope.
Edit: Oh, it'll be only on Win32, BTW.
I'll be working on this, and if we get it, will submit the changes back up to the patch tracker, of course.
I'm looking at customising the Render System(s), since this seems to me to be a logical place for it. OpenGL first because there is example code for the buffer selects for that, then I'm going to try and hunt it up in Direct3D (since we have shader issues with OpenGL), although I'm not holding out hope.
Edit: Oh, it'll be only on Win32, BTW.
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
OK, bumping my own post, but I thought I'd give an update.
It works! It's currently messy as, but I'll be cleaning it up now that I'm back from the trade show. Basically, I'm thinking to add a property to the RenderSystem that specifies how many repeats it wants. In the case of stereo, this is twice, for each eye. Possibly this could be used for rendering off to multiple displays in future, I'm not sure.
The SceneManager has to query the Renderer for how many repeats it wants, then redo the entire rendering process each time. This is because while each eye has it's own color buffer, they share the depth buffer and so on, so they need to be cleaned before alternating.
Incidently, the trade-show is the National Manufacturing Week being held at the Melbourne Exhibition Centre. Clicky.
Photo's of out booth are here
It works! It's currently messy as, but I'll be cleaning it up now that I'm back from the trade show. Basically, I'm thinking to add a property to the RenderSystem that specifies how many repeats it wants. In the case of stereo, this is twice, for each eye. Possibly this could be used for rendering off to multiple displays in future, I'm not sure.
The SceneManager has to query the Renderer for how many repeats it wants, then redo the entire rendering process each time. This is because while each eye has it's own color buffer, they share the depth buffer and so on, so they need to be cleaned before alternating.
Incidently, the trade-show is the National Manufacturing Week being held at the Melbourne Exhibition Centre. Clicky.
Photo's of out booth are here
- Kentamanos
- Minaton
- Posts: 980
- Joined: Sat Aug 07, 2004 12:08 am
- Location: Dallas, TX
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
Yeah, two projectors, like you saw.
OK, patch uploaded to http://sourceforge.net/tracker/index.ph ... tid=302997
All class abstracted and API'd and stuff!
OK, patch uploaded to http://sourceforge.net/tracker/index.ph ... tid=302997
All class abstracted and API'd and stuff!
-
- Halfling
- Posts: 55
- Joined: Mon Jan 31, 2005 9:41 pm
Hi Peter;
I was guided by several folks to the Cygwin utilities in the hope of applying the patch you posted. I moved the patch file to the ogrenew directory and issued a command of "patch --dry-run -p0 < patch.txt". I was given a response that it could not find the file to patch and that I may have used the wrong -p or -strip option. Are you able to apply the patch? If so, how are you doing it?
Bill
I was guided by several folks to the Cygwin utilities in the hope of applying the patch you posted. I moved the patch file to the ogrenew directory and issued a command of "patch --dry-run -p0 < patch.txt". I was given a response that it could not find the file to patch and that I may have used the wrong -p or -strip option. Are you able to apply the patch? If so, how are you doing it?
Bill
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
You will probably want to look into the line endings. I think Cygwin uses the lines \n line endings, where the patch no doubt has the Windows \r\n line endings, which will confuse the "patch" program.
Should be an option there somewhere for switching between the two though... I think! I haven't actually tried applying the patch, as I made it from my modifications.
Should be an option there somewhere for switching between the two though... I think! I haven't actually tried applying the patch, as I made it from my modifications.
-
- Halfling
- Posts: 55
- Joined: Mon Jan 31, 2005 9:41 pm
Morning Peter;
I read up on the patch file format and did some experimenting this morning. I was moderately successful. Apparently, the --- and +++ lines needed to indicate the relative path to the file. Things got better. Then, apparently the version of patch in cygwin did not like multiple sections in the patch file. Each time it encountered an INDEX line after the first, it would bark about a malformed patch file. So I chopped the single patch file into six pieces. It was working until we got to patch4 which is the section on OgreGLRenderSystem.h. I get the deeply insightful error message that the line ends unexpectedly (without telling me which line).
Can you tell me what tool you used to generate the patch file? Perhaps I can solve this mystery by just installing the tool and letting it read its own patch.
Bill
I read up on the patch file format and did some experimenting this morning. I was moderately successful. Apparently, the --- and +++ lines needed to indicate the relative path to the file. Things got better. Then, apparently the version of patch in cygwin did not like multiple sections in the patch file. Each time it encountered an INDEX line after the first, it would bark about a malformed patch file. So I chopped the single patch file into six pieces. It was working until we got to patch4 which is the section on OgreGLRenderSystem.h. I get the deeply insightful error message that the line ends unexpectedly (without telling me which line).
Can you tell me what tool you used to generate the patch file? Perhaps I can solve this mystery by just installing the tool and letting it read its own patch.
Bill
- PeterNewman
- Greenskin
- Posts: 128
- Joined: Mon Jun 21, 2004 2:34 am
- Location: Victoria, Australia
- Contact:
-
- Halfling
- Posts: 55
- Joined: Mon Jan 31, 2005 9:41 pm