Stereo vision manager [now as a plugin]

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

I have only tested the stereo manager with anaglyph or polarized glasses, but never with head mounted display but I hope these advices can apply to head mounted display too.

We achieved a great stereo effect by setting the focal distance to the distance between the screen and the observer (an optimal distance we have chosen), and by setting the FOV of the camera to the angle covered by the screen in the observer's vision field when he is at the optimal distance. (The useScreenWidth() method calculates the FOV for you)
With these settings, what is displayed on the screen is exactly what you would see through the screen if it was just a "window" to th virtual world.
The objects on the focal plane will be displayed with a 1:1 scale on the screen. Of course, this works better with a projector and a big screen and even better if the bottom of the screen touches the floor.

(If I am not clear, I can illustrate this with a schema)

The differences with head mounted display is that there is lenses between the eye and the screen and you can't find easily these distances but the idea is the same : the stereo settings must fit the (perceived) physical characteristics of your display device.
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Post by murderv »

hey,

http://www.inition.co.uk/inition/produc ... bCatID_=16

im working with that HMD. and now that im a bit clear about the values it might be possible to get best results..

this uses a 1280x1024 resolution with a 60 degrees FOV.
they also mention in the website the distance between eye (IPD) are between 52-74 mm. maybe i should set the eyespacing on the application to some value between that.

the info below comes from wikipedia. it talks about the FOV and other parameters, but im not sure what could be the best results for it.


what you think about this values ?!

eyespacing = 0.06; // european adult male (6cm)
focallength = 0.2; // assume distance from monitor is about 10 feet
screenwidth = 1; // screenwidth is 1m
fixedscreen = true;
camera fov = ?? its computed within the code.




-------------------------------------------------------
Performance Parameters
Stereoscopic imagery. A binocular HMD has the potential to display a different image to each eye. This can be used to show stereoscopic images. It should be heeded that so-called 'Optical Infinity' is generally taken by flight surgeons and display experts as about 9 metres. This is the distance at which, with the average human eye rangefinder "baseline" (distance between the eyes or Inter-Pupillary Distance (IPD)) of between 2.5 and 3 inches, the angle of an object at that distance, becomes essentially the same from each eye. At smaller ranges the perspective from each eye is significantly different and the expense of generating two different visual channels through the Computer-Generated Imagery (CGI) system, becomes worthwhile.
Field Of View (FOV) - Humans have around 180 degree FOV, but most HMDs offer considerably less than this. Typically, greater field of view results in greater sense of immersion and better situational awareness. Most people do not have a good feel for what a particular quoted FOV would look like (e.g. 25 degrees) so often manufacturers will quote an "apparent screen size". For example, "Our new HMD presents an image that looks like a 72 inch screen at 10 feet." However, this tends to be quite misleading since people focus on the screen size rather than the distance and manufacturers will often increase the distance until the screen size sounds good. Most people sit about 2 feet away from their monitors and have quite a good feel about screen sizes at that distance. To convert the manufacturers "apparent screen size" to your desktop monitor position, just divide the screen size by the distance in feet, then multiply by 2. So 72 inches at 10 feet becomes 14.4 inches. A 14 inch monitor on your desk sounds a lot less impressive than "72 inches at 10 feet" which is why they do not explain it that way.
Resolution - HMDs usually mention either the total number of pixels or the number of pixels per degree. Listing the total number of pixels (e.g. 1600x1200 pixels per eye) is borrowed from how the specifications of computer monitors are presented. However, the pixel density, usually specified in pixels per degree or in arcminutes per pixel, is also used to determine visual acuity. 60 pixels/degree (1 arcmin/pixel) is usually referred to as "eye limiting resolution", above which increased resolution is not noticed by people with normal vision. HMDs typically offer 10 to 20 pixels/degree, though advances in micro-displays help increase this number.
Binocular overlap - measures the area that is common to both eyes. Binocular overlap is the basis for the sense of depth and stereo, allowing humans to sense which objects are near and which objects are far. Humans have a binocular overlap of about 100 degrees (50 degrees to the left of the nose and 50 degrees to the right). The larger the binocular overlap offered by an HMD, the greater the sense of stereo. Overlap is sometimes specified in degrees (e.g. 74 degrees) or in percent indicating how much of the visual field of each eye is common to the other eye.
Distant Focus ('Collimation'). Optical techniques may be used to present the images at a distant focus, which seems to improve the realism of images that in the real world would be at a distance.
Inter-Pupillary Distance (IPD). This is the distance between the two eyes, measured at the pupils, and is important in designing Head-Mounted Displays.
------------------------------------------
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

I don't think you should use the screen width setting, because with an HMD, the perceived FOV is fixed (60° in your case), but the perceived screen width is difficult to evaluate. It is the same with the focal length which greatly depend on the distance between the screens : if you increase the distance between th screen in your glasses, the images perceived by the eyes will be more different and the sensation of depth will be more intense.

eyespacing = 0.06; // european adult male (6cm)
fixedscreen = false;
camera fov = 53 // 60 degree of the diagonal FOV converted to the vertical FOV of a 5:4 screen
//the screenwidth is not used

But I don't really know what should be the focal plane. you can try to change the focal distance in your program to get the best stereo effect.
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Post by toglia »

Thieum wrote:Hi! No problem, don't worry.
You will need a program to apply the patch, I used GNU patch
Copy patch.exe in c:\windows\ (it may not be the best solution but it is the simplest)
Copy the patch in the orgrenew folder, open a command window here and use this command :

Code: Select all

patch -p0 -i multihead_wip2.patch
This should work fine. but i did not tested the patch on ogre 1.4.7, only on ogre 1.4.6.
Hi Thieum, I'm trying to get this patch working but I'm no pro... (From the first day I have used the precompiled version) Now I have followed your steps precisely and I have the patch installed with no errors, but I'm thinking I have to compile these changes right?, and maybe change the Ogre's environment variable cause I'm changing the Ogre's SDK path?

First time compiling ogre. :oops: How do I recompile the direct3d renderer?

Could you please clear things up after applying the patch?

Thanks!!!
User avatar
toglia
Gnome
Posts: 336
Joined: Sat Dec 08, 2007 4:28 am
Location: Canada
x 7

Post by toglia »

Since this is not exactly related to the patch thread, I'm following on:
http://www.ogre3d.org/phpBB2/viewtopic. ... 273#284273
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

Hi everyone !

I turned my little manager into a plugin. Now you just have to add it to plugins.cfg, chose "Yes (anaglpy)" for "Enable stereo rendering" in the OGRE config dialog box and your app should now be automagically in anaglyph stereo 8)
You can change the stereo settings in the file stereo.cfg automatically generated. The settings depend on the scene and you will have to find the optimal one for each app.

It is a bit hacky and very exprerimental, it still have some compatibility issues with deferred shading and the compositor.
I'm also sad i could not test the plugin with a real game or a bigger project made with ogre. I could not manage to make the OGRE released with other program load a plugin I compiled. I could not even see how miserably my plugin would fail :(
I also only supports anaglyph stereo since Dual output mode needs that windows are created with a special method and not auto created when the root is initialized. I don't believe i would possible to support this mode in the plugin.

But if you want to use the manager with you own app, I don't recommend using the plugin, just add the classes to the project and initialize the manager yourself. You will have full control and the plugin will not try to guess on with viewport it will have to enable the stereo.

I want to thank Assaf Raman, I used his plugins as an example

The manager itself was also improved, it no longer needs to be initialised with a camera, it will retreive it from the viewport.
The viewport can now have compositors attached to it in anaglyph mode

The files, compile with both ogre 1.4.9 / 1.6 and ogre sdk / source (you must have defined OGRE_HOME (if you use the sdk) or OGRE_SRC (if you use the source release) with the path of ogre)
http://fiftythree.free.fr/upload/StereoManager.zip
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 »

Hey, that's pretty interesting. If you want a slot in the OgreAddons for this, drop me an email and we'll organise it.
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

Thanks ! I sent you an email
User avatar
meatless
Gnoblar
Posts: 7
Joined: Mon Oct 27, 2008 4:43 am
Location: Vienna
Contact:

Post by meatless »

hi firs i have to thank you for your effort in that topic
was quite similar to what i intended to do in the future but i am a noob for now

second i have a question the stereoscopic effect seems to me like looking throug a window gaining depth in the distance.
but for the things i'm working on i'd need the objects poping out of the screen so gaining also a certain amount of depth in front of the screen so that it might seem as if the things where just i front of the viewrs face.

is that easyly acomplished by changing some values in the config file (i alrady tried a lot) or is it ment to be just like looking throug a window effect where would i have to look for those lines of code which could make the closer objects pop out much more even further than the debugging display and logo appear
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

Hi and thank you!
You have to change the parameter named "focal length" (or something like this)
all the objects farther from the camera than focal length will appear behind the screen, all the object closer will appear to come out of the screen.

But beware, it is more difficult to have a good stereoscopic effect with object popping out because if the edges of the screen crop the object, all the effect will be ruined
This happens because a farther object (the edges of the screen) occludes a closer object (an object in the scene) and this is physically impossible
User avatar
meatless
Gnoblar
Posts: 7
Joined: Mon Oct 27, 2008 4:43 am
Location: Vienna
Contact:

Post by meatless »

are you actually thinking of still improoving the tool further?
like performance, usibility or multi display support
(noob question) is it actually possible to write a own compositor wouldn't it run much faster or is it anyway build like one (as i see it by now it's not)

in maya and toxic 2009 anaglyph cameas, rendering and compositing options are avalable now even in somewhat realtime, maybe there is something to learn from if somedody gets the hands on them
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

Hi!

Yes, I will improve the manager in the future. I would like to support shutter glasses for example. I will also try to improve the plugin part , but I am still not very convicted of its usefulness). But if you can, use only the StereoManager class instead of the full plugin, because this way you can have a full control.
Concerning the multi display, it is not supported by the plugin, but it is supported by the StereoManager class if you apply the multihead patch (the link is in StereoManager.h). I will try to add support in the plugin, but I must improve the patch before, and for that I have two find a second screen :?

I am sorry but I don't really understand you question :oops: ? Are you talking of the anaglyph (red/blue) rendering ? It uses the compositor to blend the left and the right views.
User avatar
meatless
Gnoblar
Posts: 7
Joined: Mon Oct 27, 2008 4:43 am
Location: Vienna
Contact:

Post by meatless »

jap i ment the red blue thing thanks because i just loked at the code brefley and actually am no programmer :)

i just was wandering why it runs so slow in comparison to other comositing effects which do quite some image work too.

is it because it has to render two views?

i just would realy want to push that thing further but i did not got the idea jet how it really works.

if you could give me some reference also external sources u might have used i could at least punch my mind on track trying to impove

bacause after a while i think i'll get anoing whith stupid noob questions

--- the spirit is willing but the flesh is rare---
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

there was a stupid error in the code :oops:
each eye was rendered two times. I will release a rewrote version in a few days
User avatar
meatless
Gnoblar
Posts: 7
Joined: Mon Oct 27, 2008 4:43 am
Location: Vienna
Contact:

Post by meatless »

can't await
that should give the first performance boost it needs
keep on going
--- the spirit is willing but the flesh is rare---
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

then try this : http://www.ogre3d.org/phpBB2/viewtopic.php?t=46017
it should improve the performances
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

New version !
http://www.axyz-images.com/support/OGRE/stereoscopy.zip
This is an improved version of the prerelease linked in the previous post

changes :
- Changed the licence from LGPL to BSD to allow the static link of StereoManager
- Rewrote the core to fully use the compositor. This should also fix fps bug previously reported
- Added support to interlaced stereo (vertical, horizontal and checkboard)
- Renamed the script files from anaglyph.* to Stereoscopy.* because now they are also used by interlaced stereo
- Changed the config file format to use a literal constant instead of a number for the stereo mode (you should delete the file or replace the value yourself)

changes since the prerelease :
- the manager still works in case of lost device
- the interlacement is still correct if the resolution has changed
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Post by jacmoe »

Nice to see the BSD license applied to an Ogre-related plugin.
People should use that more often! :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Post by Thieum »

I changed that because the main class can be included directly in a program without using the plugin. Since it was released under LGPL, all the program should be released under a LGPL compatible license.
I hesitated with the MIT license, but I did not really investigated the differences with the BSD license...
ludm
Gnoblar
Posts: 18
Joined: Thu Jul 10, 2008 9:37 am

Re: Stereo vision manager [now as a plugin]

Post by ludm »

Hello

I have a problem when I build the project Demo_Fresnel_stereo :

Project : error PRJ0019: Un outil a retourné un code d'erreur à partir de "Exécution d'un événement après génération..."

Do you know what's wrong ?
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

It's because the post-build event failed. There is an error in the event. My bad :oops:
copy the post-build event of Plugin_StereoManager and paste it in the post-build event of Demo_Fresnel_stereo
it should be
if exist $(OGRE_SRC) copy "$(TargetPath)" "$(OGRE_SRC)\Samples\Common\Bin\$(ConfigurationName)"
if exist $(OGRE_HOME) copy "$(TargetPath)" "$(OGRE_HOME)\Bin\$(ConfigurationName)"
ludm
Gnoblar
Posts: 18
Joined: Thu Jul 10, 2008 9:37 am

Re: Stereo vision manager [now as a plugin]

Post by ludm »

Thank you for your quick answer. Now it builds and runs.

But I have only a black screen in the Ogre window.

I have an nvdia Quadro 770m, could it be the problem ?
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

I don't know, the stereo manager was tested only on a geforce. But it should work if ogre runs with your card. Which stereo mode are you using ?
ludm
Gnoblar
Posts: 18
Joined: Thu Jul 10, 2008 9:37 am

Re: Stereo vision manager [now as a plugin]

Post by ludm »

I have build with default settings, where can I change to be in anaglyph mode ?
Is it

Code: Select all

mStereoManager.init(gLeftViewport, gRightViewport, StereoManager::SM_INTERLACED_CB);
? in Fresnel.cpp.
I haven't found the lines you talk about in your 1st post :

Code: Select all

mStereoManager.init(mCamera, mWindows[0]->getViewport(0), mWindows[1]->getViewport(0), StereoManager::SM_DUALOUTPUT);
// or
mStereoManager.init(mCamera, mWindow->getViewport(0), NULL, StereoManager::SM_ANAGLYPH);
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2
Contact:

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

the first post is out of date, I have to edit it
yes that's this line. change SM_INTERLACED_CB to SM_INTERLACED.
Have you put the resources in your media folder (in a directory referenced in resources.cfg) ? or is there any error in the log file ?
Post Reply