I want to create a stereo camera

[size=75][color=green]I added it in, but it closes both windows. Is there a way to make it so that it calls a certain window?[/size]

There is one window that is considered special, it is the “main” window. If you pass the main window to base.closeWindow(), it will consider the application finished and exit, closing any other windows along the way.

You should only call base.closeWindow() on additional windows you have created after the main window. If you want to designate a new main window, use base.openMainWindow().


[color=green]Thanks for the help. I was still getting a problem so I looked under methods, and found it. I wasn’t passing any arguments. So it was closing everything. Instead of just the one that I wanted it to close.

[size=75][color=green]I just found an error that occurs when I close a window. I can open another one, but when I go to close that one it closes both the windows. The value error that I am having right now is list.remove(x): x not in list. What exactly does this mean, and do you think you can know my problem?[/size]


I’m chiming in late on this thread, and am interested in creating a stereo image. Has anyone used 3D flicker glasses to do this?

I always thought that 3D flicker glasses took pretty much any openGL rendered image and converted it to 3d at a driver level. Am I on crack?

If some preparation is needed, is there a simple way to arrange to use these fairly “standard” and cheap glasses in Panda3D?

I’m close to buying some flicker glasses and, although they are fairly cheap, I want to know if I should save my money.


Stereo shutter (“flicker”) glasses do require special driver support. Recent NVidia drivers do seem to provide this support, though you have to dig through the driver control panel and find the option to enable stereo (it’s not enabled by default, and it’s not always immediately obvious how to find the option to enable it). I don’t know whether ATI drivers provide stereo support or not. Also, this is only an option if you are using the OpenGL drivers, since DirectX9 doesn’t even provide an API call for Panda to hook into the driver’s stereo mode.

In any case, once you have enabled stereo support in your driver, you can use shutter glasses with Panda3D fairly automatically, ever since version 1.2, simpl y by putting:

framebuffer-stereo 1

in your Config.prc file. This will work with almost any existing Panda application; for instance, you can try it with Airblade.

By the way, even without buying shutter glasses, you can try this out using the cheesy red-blue glasses that come with some 3D comic books or movies, by putting:

red-blue-stereo 1

in your Config.prc file.

It is also possible to write an application that is stereo-aware, and turns on or off stereo mode at appropriate times, or does other special effects with stereo. But the above variables will work pretty much out-of-the-box.


Wow…I’m excited about this.

First of all Thanks for the quick reponse. Second, thanks for telling me exactly what I hoped was the case :wink:

Now the trouble…I configured my card and tested it using the blue red stereo setting. This works with the HL2 Source engine. However, I added those lines in the config file and saw no results when using Panda. Other tweaks (ie win-size) seem to be fine. Any ideas?

Shoot. It looks like we’ve got a bit of code rot; some recent change has broken the red-blue-stereo variable. I’ll look into as soon as I’ve got a chance, and check in a fix.

In the meantime, I’ve just confirmed that the framebuffer-stereo variable does still work as expected. You can run with this variable enabled, even without shutter glasses; if you’ve enabled stereo in your graphics driver, you’ll see everything flicker with the alternating left and right images.


Hey guys,
This is also a late responce in this thread,
but how can I get stereo to render to a HMD (head mounted display),
I know that I dont want the red-blue stereo, but two different images
so i can get dept affect in my scene.

can any one please help, I fairly new to panda.

with regards, MEZ

You’ve got two different screens inside your HMD, so you’ll have two different DisplayRegions–or possibly even two different GraphicsWindows–one for each screen. Note that it’s more efficient to have two DisplayRegions in one window, if you can arrange this with your hardware.

The latest Panda has explicit support for a stereo camera. You just create your two DisplayRegions, and in the first one, you say:


And in the other one:


Now you can assign the same camera to both DisplayRegions, and set the interocular distance and convergence distance to your preferred values on the camera’s lens. Panda will render the appropriate eye to each DisplayRegion.


hey David,
Thanks for the responce, but I am still unclear about what you are telling
me. For example,
After I set up the two DisplayRegions, how can I assign them to the same camera. Also, how can I set the interocular distance and convergence distance on the lens, and lastly when I assign each Displayregion to a stereoChannel and assign each channel to a lens, will those lens be controlled
through the camera that i assign, say the default camera “base.camera”


def splitScreen():
    """ This function splits the main display region into two separate
    left-and-right regions, which represent the left and right eye of
    the camera. """

    # First, disable the default DisplayRegion, which covers the whole
    # screen.
    dr = base.camNode.getDisplayRegion(0)

    # Now, make a new pair of side-by-side DisplayRegions.
    window = dr.getWindow()
    dr1 = window.makeDisplayRegion(0, 0.5, 0, 1)
    dr2 = window.makeDisplayRegion(0.5, 1, 0, 1)

    # Set these both up to use the same camera.

    # And make them into left and right stereo pairs.

To set the interocular and convergence distance, you can either do:


or you can just put them in your Config.prc file like this:

default-iod 0.2
default-converge 25

You may want to explicitly set the aspect-ratio config variable, with a line like this:

aspect-ratio 1.3333

to disable the automatic adjustment of aspect ratio that ShowBase would do otherwise, and which would screw up in this side-by-side configuration.

have another suggestion for this topic.
i am about to maybe build an interactive-animation for a nature-museum and since we already have tons of 3d-stuff in our exhibition i thought about makeing the animation 3d-too.
so i played with the code shnippsets in this thread and pandas buildin red-blue mode. but both did result in quite bad coloring of the scene. so googled a bit and found a promising side which contains the neccessary math do combine 2 images to an more color-true image.
can someone give it a try with panda?

Some of those are really quite good! I guess to do this in real time we’d have to render both eyes offscreen, then combine the resulting buffers onscreen with a fragment shader.


I used your example to make a “mkAnaglyph” function, which renders an anaglyph stereo image that is NOT limited to red and blue:

def mkAnaglyph(lr,lg,lb,rr,rg,rb,dist,px,py,pz,lx,ly,lz):               # l(rgb)=left eye color
    leftBuffer = base.win.makeTextureBuffer('left', 512, 512)           # r(rgb)=right eye color
    leftBuffer.setClearColor(VBase4(0, 0, 0, 0))                        # dist=eye distance
    base.makeCamera(leftBuffer)                                         # p(xyz) camera position
    rightBuffer = base.win.makeTextureBuffer('right', 512, 512)         # l(xyz) camera lookAt
    rightBuffer.setClearColor(VBase4(0, 0, 0, 0))
    leftCard = CardMaker('left')
    leftCard.setFrame(-1, 1, -1, 1)
    leftCard.setColor(lr, lg, lb, 0.5)
    leftCardNP = render2d.attachNewNode(leftCard.generate())
    rightCard = CardMaker('right')
    rightCard.setFrame(-1, 1, -1, 1)
    rightCard.setColor(rr, rg, rb, 0.5)
    rightCardNP = render2d.attachNewNode(rightCard.generate())
    base.camList[1].setPos(px-(dist/2), py, pz)
    base.camList[1].lookAt(lx, ly, lz)
    base.camList[2].setPos(px+(dist/2), py, pz)
    base.camList[2].lookAt(lx, ly, lz)

to use this function simply run it, NO need to disable a view or cam:

mkAnaglyph(1,0,0, 0,0,1, 0.2, 0,0,0, 0,20,0)
#red-blue ; eye distance 0.2 ; cam position 0,0,0 ; lookAt 0,20,0
mkAnaglyph(1,0,0, 0,1,1, 0.4, 10,0,0, 0,0,0)
#red-cyan ; eye distance 0.4 ; cam position 10,0,0 ; lookAt 0,0,0
mkAnaglyph(1,1,0, 0,1,1, 0.2, 0,0,0, 0,20,0)
#orange-cyan (my favourite system) ; eye distance 0.2 ; cam position 0,0,0 ; lookAt 0,20,0

I don’t know why, but i like the orange-green system most, i think because it has nearly full color support, because left eye sees red and green and right eye sees green and blue…

Cool! For the record, though, Panda’s own built-in automatic anaglyph mode also supports any combination of primary or secondary colors.

You can enable it in the Config.prc file with:

red-blue-stereo 1
red-blue-stereo-colors red cyan  # or "yellow blue" or whatever

Since orange isn’t a primary or secondary color, I’m guessing you mean the same thing I’m calling yellow: equal amounts of red and green channels, and no blue channel.

You can enable it at runtime, too, but you do have to create a new DisplayRegion for that. It’s also easy to switch it on and off at runtime.

The most popular color for manufacture of anaglyphic glasses these days is red-cyan, which is superior to red-blue for the reasons you mention (in particular, it doesn’t completely lose the green channel). This is also the default color setting in Panda, despite the name of the config variable as “red-blue”.


does panda3d use asymmetrical frustums to render anaglyphs?

I have used asymmetrical frustums before and they do work very well

Yes, that is the model that Panda uses to generate stereo frustums by default.

You can tune the settings of these frustums with:

default-iod 0.2
default-converge 25.0

which define the interocular distance and the distance to the convergence plane, both in Panda scene graph units (i.e. whatever you have defined 1 unit to be). You can also fiddle with these values at runtime via:



oh, if it’s possible to do the anaglyph on engine-side for every color, then i use that, because my plane projection function 1) does not have a ConvergenceDistance and 2) slows down the FPS, because everything has to be rendered twice PLUS the 2 semitransparent layers do have to be rendered too.

oh and is it possible to do that anaglyph settings in runtime? because i would like that more then using a config file.

ah and, yes i did mean yellow, RGB(1,1,0), but because my texture was red, it looked like orange after applying the yellow filter.

Here’s code that enables anaglyph mode in 1.6.x:

# Choose a suitable pair of colors for the left and right eyes
leftColor = ColorWriteAttrib.CRed
rightColor = ColorWriteAttrib.CBlue | ColorWriteAttrib.CGreen

# Enable anaglyph stereo mode on the window
base.win.setRedBlueStereo(True, leftColor, rightColor)

# Remove the original, mono DisplayRegion
oldDr = base.cam.node().getDisplayRegion(0)

# Create a new, stereo DisplayRegion
dr = base.win.makeStereoDisplayRegion()

# The stereo region draws the left eye, then the right eye.  We need
# to clear the depth buffer after drawing the left eye and before
# drawing the right eye.

Once you have enabled it, either via the above code or via the more simple expedient of setting red-blue-stereo in your Config.prc file, you can toggle back and forth with:




And you can change the colors by calling base.win.setRedBlueStereo() at will.