Subject: Anaglyphic stereo in real time ?

From: Marc BAADEN <[email-masked]>
Date: Thu, 15 Mar 2001 10:14:29 +0000

Hi,

yet another question.

Having discovered the power of anaglyphic stereo representations
(those images which use red/blue glasses) recently, I wonder why
there are no molecular viewers out there, which support such a
display in real time (except SwissPDBviewer, see note below).

In fact I have tried (and succeeded) to create a 3D anaglyphic image
of a molecule from VMD, and it proved very easy and the result was
very convincing. The only problem is that it is not interactive and
you thus get a static view only.

Is anybody aware of a molecular viewer with real-time display in
anaglyphic stereo ?

Would anybody be interested in including such a feature in an existing
viewer ? (I would like to do it, but I think it exceeds my programming
capacities/available time).

NOTE 1:
-------

For those who are interested, here how to get an anaglyphic stereo
image from VMD:

Step-by-step instructions (with VMD)

    1.Display your system in the view you like. 
    2.choose Stereo/Left in the Display menu 
    3.choose snapshot in the Render menu 
    4.save e.g. as left.rgb 
    5.choose Stereo/Right in the Display menu 
    6.choose snapshot in the Render menu 
    7.save e.g. as right.rgb 
    8.on the command line, type 
       combine -stereo left.rgb right.rgb snap.rgb 
       (this requires that ImageMagick is installed) 
    9.convert to any format you like, for example gif 
       convert snap.rgb snap.gif 
       (this requires that ImageMagick is installed)

NOTE 2:
-------

SwissPDBViewer

This viewer has an option to display anaglyphic stereo in realtime.
Two things annoyed me very much:

a) The stereo image is only monochrome, and very "basic" concerning the
   display features.

b) The quality was VERY bad (especially compared to a stereo image from
   VMD), and I couldn't figure out how to possibly adjust the stereo
   red/blue color settings to improve it.

Thank you in advance,

  Marc Baaden

-- 
 Dr. Marc Baaden - Laboratory of Molecular Biophysics, Oxford University
 mailto:[email-masked]  - ICQ# 11466242 -  http://www.marc-baaden.de
 FAX/Voice +49 40333 968508  -  Tel: +44 1865 275380  or  +33 609 843217

---

From: John Stone <[email-masked]>
Date: Thu, 15 Mar 2001 10:15:26 -0600

Dear Marc, CCL,
  It is indeed possible to do anaglyph stereo in real-time as
you've already seen.  There are a few challenges which make 
implementation a little tricky as you mentioned in your
commentary on the colors in SwissPDBviewer:

  1) One can use the OpenGL accumulation buffer along with glColorMask()
     to draw the scene with the blue/red filtering enabled for each eye.
     This solution has the disadvantage that not all OpenGL implementations
     provide a workable accumulation buffer.  Some implement the accumulation
     buffer entirely in software, which can be _very_ slow.  Paul Bourke has
     a web page that discusses this:
       http://astronomy.swin.edu.au/pbourke/opengl/redblue/
  
  2) One could use a fully-stereo-capable video board, with quad-buffered 
     stereo (front/back/left/right color buffers) and simply enable the 
     color mask using glColorMask() before drawing the left and right images
     respectively.  This solution assumes that the video hardware can do 
     quad-buffered stereo, but I believe there are more boards that support
     stereo in hardware than support an accumulation buffer in hardware.
     This solution would probably be easy to implement in an existing 
     stereo-capable molecular visualization program, I will try it out 
     in VMD when I get back from a conference next week and if it works out,
     It'll show up in the next release of VMD.  

  3) There is a problem with both of these solutions in that certain color
     combinations in your molecule will look very bad when viewed in anaglyph
     stereo.  Only grayscale images will appear entirely correct in both eyes,
     but this is a big sacrifice to make, to give up all coloring of the 
     molecule.  Perhaps its "ok" to color your molecule semi-normally and
     allow glColorMask() to chop out the red/blue components.  As long as
     the user has fine control over the coloring of her molecule, it should
     be possible to tweak the scene to look good even in anaglyph mode.
     Here is another web page which has some brief coverage of color issues
     with anaglyph stereo:
       http://www.cs.jhu.edu/~acw3f/cg/project/intro.html#problems
     Making the colors look passable in anaglyph stereo is probably a 
     bigger challenge than the actual rendering techniques in 1) and 2).
     It sounds like SwissPDBviewer takes the approach of forcing the 
     molecule to grayscale as a first step.  Does SwissPDBviewer pass the
     green color channel at all when it draws, or does it only pass red 
     and blue? Those details matter a fair amount.  This is where I'd 
     expect the trouble to arise with implementing in VMD, making the colors
     look half-decent.

I'll make an attempt at implementing 2) in VMD, and see if it works well,
it should be a small hack to the existing CrystalEyes stereo mode, and 
should be able to render at 100% full-speed on any machine that has 
quad-buffered stereo.  The accumulation buffer technique on Paul Bourke's
page could also be implemented, but VMD isn't smart enough to manage an 
accumulation buffer well at present, and most current video boards do not
implement the accumulation buffer in hardware.  

I strongly encourage any other molecular visualization software developers
to chime in on this topic, I'd be curious to hear what other solutions people
have for doing anaglyph stereo in real-time...

Thanks,
  John Stone
  [email-masked]

On Thu, Mar 15, 2001 at 10:14:29AM +0000, Marc BAADEN wrote:
> -= This is automatically added to each message by mailing script =-
> [email-masked] -- To Everybody  | [email-masked] -- To Admins
> [email-masked] -- HELP CHEMISTRY or HELP SEARCH
> [email-masked] -- archive search    |    Gopher: gopher.ccl.net 70
> Ftp: ftp.ccl.net  |  WWW: http://www.ccl.net/chemistry/   | Jan: [email-masked]
> 
> 
> 
> 
> 
> 

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: [email-masked]                 Phone: 217-244-3349              
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078

---

From: John Stone <[email-masked]>
Date: Thu, 15 Mar 2001 11:05:31 -0600

Dear Marc and CCL,
  Although I should be preparing slides for a talk, I found it hard
to resist attempting the implementation of Anaglyph stereo in VMD
using method 2) below.  :-) 

I got it to work, and it looks fairly decent.
As expected, it runs very well speed-wise, but requires the machine to 
have quad-buffered stereo.  So this solution only really helps those
that have all of the equipment except for the stereo glasses.  If your
computer doesn't do quad-buffered stereo, then the implementation in 
I just wrote for VMD still isn't enough for your needs.  While I'd like
to implement an accumulation-buffer-based technique, this will have to 
wait for another time.

I do feel that a VMD user would want to modify some of the default 
colors it uses for drawing in order to get better looking pictures
when using anaglyph stereo, but the technique for method 2) is 
straightforward, its just a matter of getting the glColorMask() calls
in the right places in the existing stereo code.  So now a question
to CCL:
  - what colors are the lenses in your anaglyph glasses??  
  - Paul Bourke's accumulation-buffer-based example code implements several 
    different possible color combinations for people that have Cyan/Magenta,
    Red/Green, Red/Blue and other color combinations on their glasses.
  - To make the code I just wrote for VMD useful to more people it would
    be nice to hear back as to what color lenses people _actually_ have, 
    then I won't clutter up menus with color combinations that nobody will
    ever use. 

I'll be checking in the first version of this code today for anyone that
wants to see it.  (We have a read-only CVS access for those that would like
to see it before we release the next alpha/beta version of VMD 1.6.1...)

Thanks,
  John Stone
  [email-masked]