Anaglyph rendering.

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Anaglyph rendering.

Post by Luke »

hey, though I should post a bit of code I did lately for anaglyph rendering.

Code: Select all


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/ ... hp?t=32209

but fixes a few problems, and more irrlicht friendly.




Image

more images here
Last edited by Luke on Mon May 04, 2009 1:15 pm, edited 1 time in total.
[url=irc://irc.freenode.net/irrlicht]irrlicht irc[/url] - corrodinggames.com
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Wow, fantastic :D 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.
Malgodur
Posts: 195
Joined: Sun Mar 15, 2009 8:22 pm

Post by Malgodur »

Its for 1.5? I got a bunch off errors...

Code: Select all

rror C2039: 'getOverrideMaterial' : is not a member of 'irr::video::IVideoDriver'

error C2228: left of '.Material' must have class/struct/union
etc
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

We should probably set up a tutorial with this code.
yeah sounds good.
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.
[url=irc://irc.freenode.net/irrlicht]irrlicht irc[/url] - corrodinggames.com
shadowslair
Posts: 758
Joined: Mon Mar 31, 2008 3:32 pm
Location: Bulgaria

Post by shadowslair »

Haha! This is niiice... :)
I`ll better wait for 1.6 also. :?
"Although we walk on the ground and step in the mud... our dreams and endeavors reach the immense skies..."
wITTus
Posts: 167
Joined: Tue Jun 24, 2008 7:41 pm
Location: Germany

Post by wITTus »

@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 8). 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
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

@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
[url=irc://irc.freenode.net/irrlicht]irrlicht irc[/url] - corrodinggames.com
wITTus
Posts: 167
Joined: Tue Jun 24, 2008 7:41 pm
Location: Germany

Post by wITTus »

True. Did I already mention that this is awesome? :wink:

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
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Meh. I urgently need red-green glasses!
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Well if you want 3D glasses you can get em for 2 dollars with free shipping from here:

http://www.dealextreme.com/details.dx/s ... r.19022052

Yes thats my shamelessly tacked on referral id on the end there. :lol:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Hm, those are red-blue glasses. What will I need for that image here? Red-Green, Red-Blue, Red-XYZ?
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
wITTus
Posts: 167
Joined: Tue Jun 24, 2008 7:41 pm
Location: Germany

Post by wITTus »

In worst case, simply change the color within the code snippet :lol:
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
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

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

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: Select all

driver->getOverrideMaterial().Material.ColorMask=ECP_GREEN+ECP_BLUE; 
Yes I am hustlin' for my 1 DX point per 5 glass purchased. 8)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

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 :-)
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
thatdudeoverthere
Posts: 28
Joined: Fri Apr 24, 2009 2:43 pm
Location: over there...

Post by thatdudeoverthere »

i'm having a seizure... oh, the images just look like that anyhow good work. lol :)
//Personal code

bool sarcasm;

void set_sarcastic()
{
sarcasm = true;
}
[img]
http://imgs.xkcd.com/comics/goto.png
[/img]
Post Reply