Quad buffer stereo

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
gen
Gnoblar
Posts: 6
Joined: Tue Sep 09, 2003 2:30 pm
Location: Mytilini, Greece

Quad buffer stereo

Post by gen »

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!
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

We don't support it directly because of a lack of hardware of this sort, and the relatively low demand for this sort of thing. However, I don't see any reason why you couldn't customise OGRE to do it, perhaps through the use of multiple render targets (which we support).
gen
Gnoblar
Posts: 6
Joined: Tue Sep 09, 2003 2:30 pm
Location: Mytilini, Greece

Post by gen »

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!
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19269
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Look at the subclasses of Ogre::RenderWindow for details of surface creation - each subclass does it it's own way and you'll find the GL and D3D specific details in there.
User avatar
Proton
Halfling
Posts: 41
Joined: Tue Apr 22, 2003 2:34 am
Location: Alberta, Canada
Contact:

Post by Proton »

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.
-Proton
gen
Gnoblar
Posts: 6
Joined: Tue Sep 09, 2003 2:30 pm
Location: Mytilini, Greece

Post by gen »

The stereo driver from the nvidia website makes ANY opengl or directx program work correctly with them.
Hm! this could be a quick solution... I have to try it.

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
marcus
Gnoblar
Posts: 8
Joined: Sun Aug 03, 2003 8:47 am

nvidia stereo driver could do this

Post by marcus »

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
gen
Gnoblar
Posts: 6
Joined: Tue Sep 09, 2003 2:30 pm
Location: Mytilini, Greece

Post by gen »

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

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 
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.
User avatar
koutsi
Gnoblar
Posts: 14
Joined: Wed Sep 03, 2003 11:01 am
Location: Greece
Contact:

Post by koutsi »

Perhaps this addon should be imported in OGRE and used only for GL (for the momment) and maybe it could be an additional option at the config dialog for OpenGL rendering..
Informatics and Telematics Institute -
Augmented and Virtual Reality Laboratory
vhpgomes
Gnoblar
Posts: 8
Joined: Fri Jun 04, 2004 12:27 am
Location: São Paulo / Brazil
Contact:

Post by vhpgomes »

Hi,

I can't find GLRenderSystem::StartRendering... Maybe it's name had changed...
where should I put this code now???

thanks,

Victor
gen
Gnoblar
Posts: 6
Joined: Tue Sep 09, 2003 2:30 pm
Location: Mytilini, Greece

Post by gen »

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 ?
The stereo driver from the nvidia website makes ANY opengl or directx program work correctly with them.
What kind of stereo projection system do you have?

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)
vhpgomes
Gnoblar
Posts: 8
Joined: Fri Jun 04, 2004 12:27 am
Location: São Paulo / Brazil
Contact:

Post by vhpgomes »

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:
Image

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
vhpgomes
Gnoblar
Posts: 8
Joined: Fri Jun 04, 2004 12:27 am
Location: São Paulo / Brazil
Contact:

Post by vhpgomes »

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...
supersuper
Greenskin
Posts: 114
Joined: Wed Feb 11, 2004 5:41 pm
Location: England!

Post by supersuper »

i'm interested in seeing the quad buffer stereo :)
vhpgomes
Gnoblar
Posts: 8
Joined: Fri Jun 04, 2004 12:27 am
Location: São Paulo / Brazil
Contact:

Post by vhpgomes »

I basically made 3 changes:

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;
2) added stereo support in Window creation (if requested)
in SDLWindow::create()

Code: Select all

    if(stereo)
            SDL_GL_SetAttribute( SDL_GL_STEREO, 1 );
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:

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));
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...) :

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
}
I registered the StereoSceneManager with ST_EXTERIOR_FAR.

Well that's it... I really hope this helps someone.. any doubts or suggestions?

Victor
SilverRat
Gnoblar
Posts: 1
Joined: Wed Sep 01, 2004 8:06 pm

Post by SilverRat »

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
User avatar
PeterNewman
Greenskin
Posts: 128
Joined: Mon Jun 21, 2004 2:34 am
Location: Victoria, Australia
Contact:

Post by PeterNewman »

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.
User avatar
PeterNewman
Greenskin
Posts: 128
Joined: Mon Jun 21, 2004 2:34 am
Location: Victoria, Australia
Contact:

Post by PeterNewman »

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
User avatar
Kentamanos
Minaton
Posts: 980
Joined: Sat Aug 07, 2004 12:08 am
Location: Dallas, TX

Post by Kentamanos »

Neat stuff. Did you use 2 polarized projectors? It looks like it from the glasses and one shot looks like 2 projectors stacked...

[EDIT] Just saw your other post that mentions the polarized projectors.
User avatar
PeterNewman
Greenskin
Posts: 128
Joined: Mon Jun 21, 2004 2:34 am
Location: Victoria, Australia
Contact:

Post by PeterNewman »

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!
wwoelbel
Halfling
Posts: 55
Joined: Mon Jan 31, 2005 9:41 pm

Post by wwoelbel »

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
User avatar
PeterNewman
Greenskin
Posts: 128
Joined: Mon Jun 21, 2004 2:34 am
Location: Victoria, Australia
Contact:

Post by PeterNewman »

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.
wwoelbel
Halfling
Posts: 55
Joined: Mon Jan 31, 2005 9:41 pm

Post by wwoelbel »

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
User avatar
PeterNewman
Greenskin
Posts: 128
Joined: Mon Jun 21, 2004 2:34 am
Location: Victoria, Australia
Contact:

Post by PeterNewman »

I used WinCVS to create the patch. I'm not sure if it uses an external program (I dont think so).
wwoelbel
Halfling
Posts: 55
Joined: Mon Jan 31, 2005 9:41 pm

Post by wwoelbel »

The WinCVS route ran dry. I can see how to make the patch but not how to reverse the process. You know what? There is one tool that I think I can get to work - the keyboard. The patch is not that huge and I think I understand how to "read" it. Thanks for the help though!

Bill
Post Reply