Stereo Rendering in Irrlicht engine
-
saransiva_ps
- Posts: 3
- Joined: Thu Jun 19, 2008 6:52 am
Stereo Rendering in Irrlicht engine
Hi,
Is stereo rendering possible (for Head mounted displays, virtual reality, etc.,) in Irrlicht engine. Please provide me some suggestions
Is stereo rendering possible (for Head mounted displays, virtual reality, etc.,) in Irrlicht engine. Please provide me some suggestions
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Depends on which type of rendering you need, i.e. which device you'll use. The easiest way is to use the NVidia stereo drivers, which do this automatically for you. Other ways are to use two cameras and render according to the device's requirements. Direct access to the stereo framebuffers is not possible ATM.
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Well, I already used Irrlicht with the NVidia stereo drivers and a two-screen head mounted display. Worked like a charm. However, if you want to do manual stereo rendering (e.g. with OpenGL and the right and left buffers), you'd need some additional code for the engine. I already made some drafts for this, but didn't find the time (and equipment
) to implement and test it.
The basic idea would be to add special render targets, which would be available via a setRenderTarget(BackLeft) or so. This should be it, modulo some tweaks in beginScene/endScene and a proper camera handling. I'll promise to put this code into the engine (and do the necessary adaptions, at least if it is possible without recreating the engine
) if someone provides a working OpenGL example (and of course it will be faster if you also provide the stereo render devices
)
The basic idea would be to add special render targets, which would be available via a setRenderTarget(BackLeft) or so. This should be it, modulo some tweaks in beginScene/endScene and a proper camera handling. I'll promise to put this code into the engine (and do the necessary adaptions, at least if it is possible without recreating the engine
an example can be provided:
the glasses however i don't have

Code: Select all
// from libmini Fraenkische Demo by Stefan Roettger
if(!stereo) // no stereo anaglyph
{
//normal rendering
}
else // red cyan stereo anaglyph
{
// turn holds horizontal view angle
sina=sin(2.0f*PI/360.0f*turn);
cosa=cos(2.0f*PI/360.0f*turn);
// incline holds pitch
tanp=tan(2.0f*PI/360.0f*incline);
// stereo base
rx=cosa*sbase;
rz=-sina*sbase;
// left channel:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(ex-rx,ey,-ez+rz,ex+sina-rx,ey-tanp,-ez-cosa+rz,0.0f,1.0f,0.0f);
glColorMask(GL_TRUE,GL_FALSE,GL_FALSE,GL_FALSE);
/*
render left chanal
*/
// now clear buffer
glClear(GL_DEPTH_BUFFER_BIT);
// right channel:
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(ex+rx,ey,-ez-rz,ex+sina+rx,ey-tanp,-ez-cosa-rz,0.0f,1.0f,0.0f);
glColorMask(GL_FALSE,GL_TRUE,GL_TRUE,GL_FALSE);
/*
render right chanal
*/
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
}-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
That's easily possible, although Irrlicht doesn't support the color mask, yet. But it can be easily added to the scene manager (seems to fit there better because changing that and COpenGLDriver. Then you'd set two cameras and draw the scene twice. In between change the scene's color mask and active camera.
Maybe using only one camera and changing the offset slightly would be easier for doing interactive scenery, otherwise you'd have to synchronize the two cameras somehow.
Maybe using only one camera and changing the offset slightly would be easier for doing interactive scenery, otherwise you'd have to synchronize the two cameras somehow.
Well a color mask can be simulated by a post processing shader. The days of proprietary fixed function effects are over.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
No way, fixed function pipeline's cool
Weren't you in the process of writing a fixed function projective texture material 
Regarding this special case I also don't see much benefit for the shader appraoch, because you'd either have to change all your shader materials to become more efficient, or do postprocessing with two or three additional passes over the full render image...
Regarding this special case I also don't see much benefit for the shader appraoch, because you'd either have to change all your shader materials to become more efficient, or do postprocessing with two or three additional passes over the full render image...
hoppla!
of course the upper example is used to realize Red/cyan anaglyph
i have tried using it but i can't get it to work - i must be doing something wrong in general.
Can you explain to me why the scene only apeares once? i would expect two scenes overlaping.
(red cyan not realised yet)
thx
of course the upper example is used to realize Red/cyan anaglyph
i have tried using it but i can't get it to work - i must be doing something wrong in general.
Can you explain to me why the scene only apeares once? i would expect two scenes overlaping.
(red cyan not realised yet)
Code: Select all
driver->beginScene(true, true, video::SColor(0,150,50,0));
smgr->drawAll();
driver->clearZBuffer();
camera.setPosition(vector3df(pos.X+rx,pos.Y,pos.Z+rz));
smgr->drawAll();
driver->endScene();
camera.setPosition(vector3df(pos.X,pos.Y,pos.Z));
Did any one made some improvements to the stereo stuff? I have a HMD and a pair of glasses that works with frame sequential mode and some code working in OpenGL but I don't know how to integrate in irrlicht engine... I'm working with Nvida Quadro because there are the unique cards that works with the original stereo drivers, but I cannot make it work without doing the "OpenGL" stuff. I've read that with DirectX should work without doing anything.... that's not working for me :S
Any thoughts?
Thanks,
Pau
Any thoughts?
Thanks,
Pau
Hi,
I've been looking to the irrlicht engine code, and for me is being really difficult to understand where I have to put all the stereo code.
First I have to do is set
so I uncommented
because I found this attribute can be setted from "params" when you create the window. Here I have my first problem, I had a "redefinition error" from Visual Studio, as far as I understand, I have to comment one define that actually creates the window, but I don't know which one have to be commented.
After that I have to call
and finish with setting the camera and the frustum to avoid the "parallax problem". I just make a class based on Paul Bourke website wich I can post here if it's necessary, but is only using glFrustum and gluLookAt with some "weird" params.
Note that also you have to call
every time you change the eye.
And that's all! If anyone can help me saying me where I have to put all this code, I will try to do my best.
Thx!
I've been looking to the irrlicht engine code, and for me is being really difficult to understand where I have to put all the stereo code.
First I have to do is set
Code: Select all
SDL_GL_SetAttribute( SDL_GL_STEREO , 1 );Code: Select all
#define _IRR_COMPILE_WITH_SDL_DEVICE_ After that I have to call
Code: Select all
glDrawBuffer (GL_BACK_LEFT); //or right, depending on the eye you're drawingNote that also you have to call
Code: Select all
glClear( GL_DEPTH_BUFFER_BIT );And that's all! If anyone can help me saying me where I have to put all this code, I will try to do my best.
Thx!
-
hybrid
- Admin
- Posts: 14144
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
You can also use Irrlicht's own way of accessing the stereo buffers (in case they are really there, only a few cards and drivers support stereo render targets). Look into the setRenderTarget overloads, you can use a specific enum for the left and right stereo buffer. Then you can get along with example 13, which shows you how to render into two render targets (rtt and main buffer in that case, you'd use the two stereo buffers instead).
Thanks very much! I didn't realize that it was allready implemented and it worked! I'm rendering in two different devices that uses this functionallity and works perfectly in both.
The only thing that is "weird" is that I have to set the STEREO_BOTH_BUFFER every loop before I draw because if not, buffer is not cleaning... I think it should work without that right?
That's my code:
Thanks a lot again!
The only thing that is "weird" is that I have to set the STEREO_BOTH_BUFFER every loop before I draw because if not, buffer is not cleaning... I think it should work without that right?
That's my code:
Code: Select all
if ( m_bStereo )
{
driver->setRenderTarget( video::ERT_STEREO_BOTH_BUFFERS , true , true , video::SColor( 0, 0 , 0 , 1) );
driver->setRenderTarget( video::ERT_STEREO_LEFT_BUFFER , true , true , video::SColor( 0, 0 , 0 , 1) );
m_CamMgr.setActiveCamera( Camera::STEREOLEFT );
smgr->drawAll();
driver->setRenderTarget( video::ERT_STEREO_RIGHT_BUFFER, true , true , video::SColor( 0, 0 , 0 , 1) );
m_CamMgr.setActiveCamera( Camera::STEREORIGHT );
smgr->drawAll();
}Thanks a lot again!