| View previous topic :: View next topic |
| Author |
Message |
Luke Admin
Joined: 14 Jul 2006 Posts: 449 Location: Australia
|
Posted: Mon May 04, 2009 12:53 pm Post subject: Anaglyph rendering. |
|
|
hey, though I should post a bit of code I did lately for anaglyph rendering.
| Code: |
void CGameEngine::drawAnaglyph()
{
vector3df oldPosition=camera->getPosition();
vector3df oldTarget=camera->getTarget();
matrix4 startMatrix=camera->getAbsoluteTransformation();
vector3df focusPoint= (camera->getTarget()-camera->getAbsolutePosition()).setLength(1) + camera->getAbsolutePosition() ;
//Left eye...
vector3df leftEye;
matrix4 leftMove;
leftMove.setTranslation( vector3df(-0.01f,0.0f,0.0f) );
leftEye=(startMatrix*leftMove).getTranslation();
//clear the depth buffer, and color
driver->beginScene( true, true, SColor(0,200,200,255) );
driver->getOverrideMaterial().Material.ColorMask=ECP_RED;
driver->getOverrideMaterial().EnableFlags=EMF_COLOR_MASK;
driver->getOverrideMaterial().EnablePasses=ESNRP_SKY_BOX+ESNRP_SOLID+ESNRP_TRANSPARENT+ESNRP_TRANSPARENT_EFFECT+ESNRP_SHADOW;
camera->setPosition( leftEye );
camera->setTarget( focusPoint );
draw(); // 'smgr->drawAll();' may go here
//Right eye...
vector3df rightEye;
matrix4 rightMove;
rightMove.setTranslation( vector3df(0.01f,0.0f,0.0f) );
rightEye=(startMatrix*rightMove).getTranslation();
//clear the depth buffer
driver->clearZBuffer();
driver->getOverrideMaterial().Material.ColorMask=ECP_GREEN+ECP_BLUE;
driver->getOverrideMaterial().EnableFlags=EMF_COLOR_MASK;
driver->getOverrideMaterial().EnablePasses=ESNRP_SKY_BOX+ESNRP_SOLID+ESNRP_TRANSPARENT+ESNRP_TRANSPARENT_EFFECT+ESNRP_SHADOW;
camera->setPosition( rightEye );
camera->setTarget( focusPoint );
draw(); // 'smgr->drawAll();' may go here
driver->endScene();
driver->getOverrideMaterial().Material.ColorMask=ECP_ALL;
driver->getOverrideMaterial().EnableFlags=0;
driver->getOverrideMaterial().EnablePasses=0;
camera->setPosition( oldPosition );
camera->setTarget( oldTarget );
} |
similar to the code by bob, here: http://irrlicht.sourceforge.net/phpBB2/viewtopic.php?t=32209
but fixes a few problems, and more irrlicht friendly.
more images here _________________ irrlicht irc - corrodinggames.com
Last edited by Luke on Mon May 04, 2009 1:15 pm; edited 1 time in total |
|
| Back to top |
|
 |
hybrid Admin
Joined: 19 Apr 2006 Posts: 9757 Location: Oldenburg(Oldb), Germany
|
Posted: Mon May 04, 2009 1:02 pm Post subject: |
|
|
Wow, fantastic Actually, this was the thing I wanted to try out with the override material, but I failed to find proper glasses. So I postponed it - guess I have to buy some urgently!
We should probably set up a tutorial with this code. |
|
| Back to top |
|
 |
Malgodur
Joined: 15 Mar 2009 Posts: 195
|
Posted: Mon May 04, 2009 1:34 pm Post subject: |
|
|
Its for 1.5? I got a bunch off errors...
| Code: | rror C2039: 'getOverrideMaterial' : is not a member of 'irr::video::IVideoDriver'
error C2228: left of '.Material' must have class/struct/union |
etc |
|
| Back to top |
|
 |
Luke Admin
Joined: 14 Jul 2006 Posts: 449 Location: Australia
|
Posted: Mon May 04, 2009 1:47 pm Post subject: |
|
|
| Quote: |
We should probably set up a tutorial with this code. |
yeah sounds good.
| Quote: | | Its for 1.5? I got a bunch off errors... |
hmm, you may have to use the svn or wait for 1.6. sorry I always work off the svn, I forget what is in each version. _________________ irrlicht irc - corrodinggames.com |
|
| Back to top |
|
 |
shadowslair

Joined: 31 Mar 2008 Posts: 272 Location: Bulgaria
|
Posted: Mon May 04, 2009 8:16 pm Post subject: |
|
|
Haha! This is niiice...
I`ll better wait for 1.6 also.  _________________
 |
|
| Back to top |
|
 |
wITTus

Joined: 24 Jun 2008 Posts: 167 Location: Germany
|
Posted: Tue May 05, 2009 11:09 am Post subject: |
|
|
@hybrid: Check out ebay, there you can find tons of these glasses.
@Luke: This is almost a candidate for the screenshot of the month competition. Absolutely awesome . But is it real 3D? Normally the red and green bars around the objects should change their size with distance, shouldn't they?  _________________ Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko |
|
| Back to top |
|
 |
Luke Admin
Joined: 14 Jul 2006 Posts: 449 Location: Australia
|
Posted: Tue May 05, 2009 11:19 am Post subject: |
|
|
| Quote: | | @Luke: This is almost a candidate for the screenshot of the month competition. Absolutely awesome Cool. But is it real 3D? Normally the red and green bars around the objects should change their size with distance, shouldn't they? Question |
yeah it is real 3d, and they do change. The red and green bars, reverse at the focus point (the difference between poping out, and looking far away), so it may not look like they change in that image.
have a look at some of the other shots here (you can see the size changing better):
http://corrodinggames.com/forums/viewtopic.php?f=1&t=16 _________________ irrlicht irc - corrodinggames.com |
|
| Back to top |
|
 |
wITTus

Joined: 24 Jun 2008 Posts: 167 Location: Germany
|
Posted: Tue May 05, 2009 1:04 pm Post subject: |
|
|
True. Did I already mention that this is awesome?
Your LUA stuff is also quite cool btw.
Was it hard to implement? _________________ Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko |
|
| Back to top |
|
 |
CuteAlien Admin

Joined: 06 Mar 2006 Posts: 1935 Location: Tübingen, Germany
|
|
| Back to top |
|
 |
BlindSide Admin
Joined: 08 Dec 2005 Posts: 2505 Location: NZ!
|
|
| Back to top |
|
 |
CuteAlien Admin

Joined: 06 Mar 2006 Posts: 1935 Location: Tübingen, Germany
|
|
| Back to top |
|
 |
wITTus

Joined: 24 Jun 2008 Posts: 167 Location: Germany
|
Posted: Wed May 06, 2009 7:43 pm Post subject: |
|
|
In worst case, simply change the color within the code snippet  _________________ Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko |
|
| Back to top |
|
 |
BlindSide Admin
Joined: 08 Dec 2005 Posts: 2505 Location: NZ!
|
Posted: Thu May 07, 2009 1:36 am Post subject: |
|
|
| CuteAlien wrote: | | Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ? |
I knew you would say that you pedantic ****
Actually they are Red-Cyan glasses, the title is misleading. And this is Red-Cyan anaglyph rendering (RED/GREEN+BLUE):
From luke's code:
| Code: |
driver->getOverrideMaterial().Material.ColorMask=ECP_GREEN+ECP_BLUE;
|
Yes I am hustlin' for my 1 DX point per 5 glass purchased.  _________________ ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net |
|
| Back to top |
|
 |
CuteAlien Admin

Joined: 06 Mar 2006 Posts: 1935 Location: Tübingen, Germany
|
Posted: Thu May 07, 2009 2:03 am Post subject: |
|
|
| BlindSide wrote: | | CuteAlien wrote: | | Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ? |
I knew you would say that you pedantic **** :P
|
Lol - purely innocent curiosity - I really had no idea :-) _________________ http://www.irrgheist.com/
http://www.michaelzeilfelder.de/irrlicht.htm
IRC: #irrlicht on irc.freenode.net |
|
| Back to top |
|
 |
thatdudeoverthere
Joined: 24 Apr 2009 Posts: 18
|
Posted: Sun May 10, 2009 5:35 am Post subject: |
|
|
i'm having a seizure... oh, the images just look like that anyhow good work. lol  _________________ //Personal code
bool sarcasm;
bool set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img] |
|
| Back to top |
|
 |
|