Anaglyph (3D): Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (small wiki-styling/enhancements. Great article already Ozgur!)
(Added Mac OS X implementation, explanation of variables,new screenshots for ver/hor modes, warning for use of glasses.)
Line 1: Line 1:
This wiki describes how to use the '''stereo vision''' or '''[http://en.wikipedia.org/wiki/Anaglyph_image anaglyph images]''' ability of [[OpenSceneGraph]] and let you experience the [[FlightGear]] world in 3D. Another excellent example and simple application of FlightGear's flexibility and realism.
This wiki describes how to use the '''stereo vision''' or '''[http://en.wikipedia.org/wiki/Anaglyph_image anaglyph images]''' ability of [[OpenSceneGraph]] and let you experience the [[FlightGear]] world in 3D. Another excellent example and simple application of FlightGear's flexibility and realism.
'''Important Notice:''' Even though it might not pose any danger, try avoiding excessive use of different color paired glasses, and after your flying sessions with the glasses or whatever, let your eyes and brain rest for a while before starting to sew, chop meat, drive 160mph, dig the garden etc.


==Anaglyph, that weird looking glasses...==
==Anaglyph, that weird looking glasses...==
Line 29: Line 32:


After you entered the last value, click "OK" to quit from the Advanced Options window. Remove your pilot raybans, put your fancy 3D glasses and click "Run".
After you entered the last value, click "OK" to quit from the Advanced Options window. Remove your pilot raybans, put your fancy 3D glasses and click "Run".
===Mac OS X===
[[Image:Anaglyphic2.jpg|thumb|Red-Green Anaglyph OSG Render in action]]
Thanks to [http://flightgear.org/forums/memberlist.php?mode=viewprofile&u=1650 someguy] (not some guy, a FlightGear forum member!) for providing Mac OS X instructions. And here is the related [http://www.flightgear.org/forums/viewtopic.php?f=19&t=9222&p=93141#p93141 post]with more screenshots.
# In the Finder, select the menu item Go > Go to Folder... and enter "~/.MacOSX" without the quotes. You will go to a hidden folder in your user directory.
# You should see a file named "environment.plist". Open it in TextEdit.
# Between the <dict> and </dict> tags, add the following:
  <key>OSG_EYE_SEPARATION</key>
  <real>0.025</real>
  <key>OSG_SCREEN_DISTANCE</key>
  <real>0.5</real>
  <key>OSG_STEREO</key>
  <string>ON</string>
  <key>OSG_STEREO_MODE</key>
  <string>ANAGLYPHIC</string>
Don't disturb anything else in there and save the file. Fire up Flightgear and be amazed.
If you don't see environment.plist, you'll need to create it. No problem, just open a new document in TextEdit, enter these lines, and save as environment.plist:
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
  <key>OSG_EYE_SEPARATION</key>
  <real>0.02500000037252903</real>
  <key>OSG_SCREEN_DISTANCE</key>
  <real>0.5</real>
  <key>OSG_STEREO</key>
  <string>ON</string>
  <key>OSG_STEREO_MODE</key>
  <string>ANAGLYPHIC</string>
  </dict>
  </plist>


===Tweaking The View/Stopping Nausea===
===Tweaking The View/Stopping Nausea===
(on the way...)--[[User:Ozgur|Ozgur]] 17:57, 30 August 2010 (UTC)
A brief explanation of the values we gave for the environment variables goes like this. This info comes directly from the [http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings OSG Stereo Settings] page.
 
'''OSG_STEREO=ON:''' is quiet self explanatory...We have to tell OSG to turn on the stereo rendering.
 
'''OSG_STEREO_MODE=ANAGLYPHIC:''' Well, the fanciness level starts here...In our relatively cheap case, we chose anaglyph rendering since we only had red-green or red-cyan glasses to see...So we tell OSG to fit our budget by rendering the scene according to ANAGLYPH method. But on the other hand, OSG provides not only ANAGLYPH (as default), it supplies its user with a wide variety of stereo render options.(Don't get scared by the frame rates shown on the screenshots, enabling stereo view didn't effected the framerates of the old laptop the screenshots were taken).These are;
 
 
*<tt>ANAGLYPH          Use anaglyphic stereo when in stereo (default) (See green-red filtered images).</tt>
*<tt>QUAD_BUFFER Use quad buffered stereo when in stereo.</tt>
*<tt>HORIZONTAL_SPLIT Use horizontal split stereo mode when in stereo [http://wiki.flightgear.org/index.php/File:OSG_Anaglyph_StartScreen.jpg Starting],[http://wiki.flightgear.org/index.php/File:Hor_Cockpit.jpg Running!], [http://wiki.flightgear.org/index.php/File:Stereo_B1900D_View.jpg External Stereo View]</tt>
*<tt>VERTICAL_SPLIT Use vertical split stereo mode when in stereo [http://wiki.flightgear.org/index.php/File:Vertical_Sep_Cockpit.jpg Vertical Separation Cockpit] and [http://wiki.flightgear.org/index.php/File:Vertical_Sep_External.jpg External View]</tt>
 
To understand the red-green images, one can carefully inspect especially the vertically separated images. If you carefully look at [http://wiki.flightgear.org/index.php/File:Hor_Cockpit.jpg this] image, note how the runway markings are appearing in a different perspective in left and right images. What OSG does when you tell to enable the Anaglyph instead of this vertical stereo, it applies color filters that exactly (not at practice sometimes, within color bandwidth limits) matches with your green and red filters on your glasses. Then it overlaps these filtered images and displays as a single image. Then, your left eye, with a green filter, filters the green image and sees the reddish image and vice versa for the right eye. Thus, giving each eye what they should be seeing in a real cockpit is also assembled by our brain, and perceived as a 3D environment.
 
'''OSG_SCREEN_DISTANCE=0.95:''' is the "distance" to your very own screen in metrics. For a good practice, you'd better measure this distance to your screen and not to make it 0.2 meters or 14.3 meters , since the first one is dangerous to your health and latter one to your flight profile. For multiple display, the measurements (should?) be from your viewpoint to the monitor surface. Contributes to the feeling of the depth on your screen.
 
'''OSG_EYE_SEPARATION=0.06:''' Eye seperation...Funny but is the actual distance between two pupils of your eyes. Measure but don't pop them out for a precision measure with a caliper. Makes significant contributions to the realism of the simulator. Generally 5 to 7 cm (0.05 to 0.07 meters). For imperial units convert 1 inch=25.4mm, 1 meter=3.280 ft.
 
==Links==
*[http://www.openscenegraph.org OSG Website]
*[http://www.openscenegraph.org/projects/osg/wiki/Support/UserGuides/StereoSettings Stereo Settings]
*[http://en.wikipedia.org/wiki/Anaglyph_image Anaglyph Image on Wikipedia]
*[http://en.wikipedia.org/wiki/Retinal_rivalry An important warning about using highly filtering glasses]

Revision as of 00:13, 31 August 2010

This wiki describes how to use the stereo vision or anaglyph images ability of OpenSceneGraph and let you experience the FlightGear world in 3D. Another excellent example and simple application of FlightGear's flexibility and realism.

Important Notice: Even though it might not pose any danger, try avoiding excessive use of different color paired glasses, and after your flying sessions with the glasses or whatever, let your eyes and brain rest for a while before starting to sew, chop meat, drive 160mph, dig the garden etc.


Anaglyph, that weird looking glasses...

As you might know or not, FlightGear migrated graphics functions from PLIB to OSG. FlightGear 1.9.0, released Decemeber 22, 2008, marked the release of the OSG version of FlightGear. As of August 2010, most recent stable version of Flightgear uses OSG. For those who are unaware of OSG, it is an open source high performance 3D graphics toolkit.

Stereo vision exploit the human perception by showing a 3-Dimensional image on a 2-Dimensional surface. To understand stereo vision and human judgement of visual distance (that is how we keep visual separation from the traffic), make the following small experiment. While reading this text, close your left eye and then right eye, open left. When you alternate your view, it'll feel like the monitor is moving to little left when you observe with right eye, and vice versa. This situation gives us two different images. Now imagine you took this two "slightly" different images and match it such that each eye sees what it is supposed to see. There are not so many but quite a few ways to achieve this separation. And OSG is capable of doing all of this. Now apply this to your short final 28R at KSFO!

How to multiply your realism level by 10

For this experience, you will need

  1. A working copy of FlightGear, of course.
  2. A pair of Red-Green or Red-Cyan pair of 3D glasses. You might have one at home or if you are a DIY type, check NASA way of doing glasses or Liquid Crystal Shutter Glasses and probably suitable hardware (anyone experienced with or owns one pair of this thing might help developing this page).

The easiest and shortest way to experiment with this is to follow the procedure below (quick start).

Windows

Accessing advanced options.
Final result in Environment settings.
  1. Start the FlightGear launcher, select your aircraft and select your location.
  2. On the next screen, click "Advanced" just above the "Run" button.
  3. On the new window, titled "Advanced Options" highlight the "Environment" from the list on the left
  4. Now, you will create new environment variables, click "New" and type OSG_STEREO=ON, then again click "New". At this point you should be seeing "OSG_STEREO=ON" on environment list.
  5. The commands (including the one we just created) that you have to pass to OSG consist of:
    • OSG_STEREO=ON
    • OSG_STEREO_MODE=ANAGLYPHIC
    • OSG_SCREEN_DISTANCE=1
    • OSG_EYE_SEPARATION=0.025

The result should be something like shown on the right.

After you entered the last value, click "OK" to quit from the Advanced Options window. Remove your pilot raybans, put your fancy 3D glasses and click "Run".




Mac OS X

Red-Green Anaglyph OSG Render in action

Thanks to someguy (not some guy, a FlightGear forum member!) for providing Mac OS X instructions. And here is the related postwith more screenshots.


  1. In the Finder, select the menu item Go > Go to Folder... and enter "~/.MacOSX" without the quotes. You will go to a hidden folder in your user directory.
  2. You should see a file named "environment.plist". Open it in TextEdit.
  3. Between the <dict> and </dict> tags, add the following:


  <key>OSG_EYE_SEPARATION</key>
  <real>0.025</real>
  <key>OSG_SCREEN_DISTANCE</key>
  <real>0.5</real>
  <key>OSG_STEREO</key>
  <string>ON</string>
  <key>OSG_STEREO_MODE</key>
  <string>ANAGLYPHIC</string>

Don't disturb anything else in there and save the file. Fire up Flightgear and be amazed.

If you don't see environment.plist, you'll need to create it. No problem, just open a new document in TextEdit, enter these lines, and save as environment.plist:

  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  <plist version="1.0">
  <dict>
  <key>OSG_EYE_SEPARATION</key>
  <real>0.02500000037252903</real>
  <key>OSG_SCREEN_DISTANCE</key>
  <real>0.5</real>
  <key>OSG_STEREO</key>
  <string>ON</string>
  <key>OSG_STEREO_MODE</key>
  <string>ANAGLYPHIC</string>
  </dict>
  </plist>

Tweaking The View/Stopping Nausea

A brief explanation of the values we gave for the environment variables goes like this. This info comes directly from the OSG Stereo Settings page.

OSG_STEREO=ON: is quiet self explanatory...We have to tell OSG to turn on the stereo rendering.

OSG_STEREO_MODE=ANAGLYPHIC: Well, the fanciness level starts here...In our relatively cheap case, we chose anaglyph rendering since we only had red-green or red-cyan glasses to see...So we tell OSG to fit our budget by rendering the scene according to ANAGLYPH method. But on the other hand, OSG provides not only ANAGLYPH (as default), it supplies its user with a wide variety of stereo render options.(Don't get scared by the frame rates shown on the screenshots, enabling stereo view didn't effected the framerates of the old laptop the screenshots were taken).These are;


To understand the red-green images, one can carefully inspect especially the vertically separated images. If you carefully look at this image, note how the runway markings are appearing in a different perspective in left and right images. What OSG does when you tell to enable the Anaglyph instead of this vertical stereo, it applies color filters that exactly (not at practice sometimes, within color bandwidth limits) matches with your green and red filters on your glasses. Then it overlaps these filtered images and displays as a single image. Then, your left eye, with a green filter, filters the green image and sees the reddish image and vice versa for the right eye. Thus, giving each eye what they should be seeing in a real cockpit is also assembled by our brain, and perceived as a 3D environment.

OSG_SCREEN_DISTANCE=0.95: is the "distance" to your very own screen in metrics. For a good practice, you'd better measure this distance to your screen and not to make it 0.2 meters or 14.3 meters , since the first one is dangerous to your health and latter one to your flight profile. For multiple display, the measurements (should?) be from your viewpoint to the monitor surface. Contributes to the feeling of the depth on your screen.

OSG_EYE_SEPARATION=0.06: Eye seperation...Funny but is the actual distance between two pupils of your eyes. Measure but don't pop them out for a precision measure with a caliper. Makes significant contributions to the realism of the simulator. Generally 5 to 7 cm (0.05 to 0.07 meters). For imperial units convert 1 inch=25.4mm, 1 meter=3.280 ft.

Links