The Oculus Rift Side-by-side-stereo FisheyeLens and Filters

Code for this issue:
github.com/ubernaut/OculusRift- … oOculus.py
based on:
panda3d.org/manual/index.php … _the_Panda

I have been lucky enough to have received an Oculus Rift. I’ve just started to try and get it working with panda3d.

So I’ve edited /etc/Config.prc to the correct resolution and to enable side by side stereo:

side-by-side-stereo 1
win-size 1280 800

Next Get image filters working so I can apply the correct distorion.

Unfortunately when I use the example from:

panda3d.org/manual/index.php … ge_Filters

This is the result: imgur.com/JIbC5G1
What am I doing wrong? do I need to apply the filter to both the left and right eyes? How would I go about that?

Or is it possible to apply a FisheyeLens to each eye?

panda3d.org/apiref.php?page=FisheyeLens

How is FisheyeLens supposed to be used?

Unfortunately, I don’t believe that the FilterManager is currently set up to be able to filter multiple display regions at the same time. You’ll need to add this functionality to FilterManager.

The FisheyeLens is intended to be used with a NonlinearImager, which works by rendering offscreen into a buffer, and then applying that buffer to a distorted mesh. This could perhaps also be an effective way of implementing the required distortion without requiring shaders, by making a Lens derivative that is used with a NonlinearImager - although I personally have no experience with that.

Thanks a bunch for the reply rdb. Is that something I would have to add to the C++ API or the Python API or would I have to do both?

The FilterManager approach would be Python-based, whereas the NonlinearImager would be C+±based.

Update: I got basic stereo 3D support working with the Oculus Rift by disabling all filters, enabling side-by-side stereo and using something called the “Oculus Overlay” to do the warping for me. I had to tweak the values in the config file. (Oculus Overlay is windows only unfortunately)

I’ve packaged the overlay app along with a version of my project here:
code.google.com/p/stableorbit/d … usRift.zip

As far as I know this should work for any Panda3D app by simply disabling all shaders and enabling ‘side-by-side’ stereo in the Config.prc file.

Also,
Oculus released a new SDK with linux support. developer.oculusvr.com/?action=dl

I had a few issues getting it to install on my xubuntu 12.10 box but I resolved them here:

[developer.oculusvr.com/forums/v ... =20&t=2347](https://developer.oculusvr.com/forums/viewtopic.php?f=20&t=2347)

I’ve also found a python-rift wrapper that I’m currently trying to get to work:
github.com/lubosz/python-rift

I think it is easier to disable side-by-side and create 2 cameras manually. Then you apply the same filter for both cameras.

Or you can create two FilterManager objects and hack them to use different display regions:

# Find the display region corresponding to our camera
stereo = None
for region in win.getDisplayRegions():
    if region.isStereo() and cam == region.getCamera():
        stereo = region
        break

fmLeft = FilterManager(win, cam)
fmLeft.region = stereo.getLeftEye()

fmRight = FilterManager(win, cam)
fmRight.region = stereo.getLeftEye()

Right on rdb! I’ll try this tonight!

On second thought, that code won’t work because the first FilterManager replaces the camera, causing the second FilterManager to be unable to determine which region to use. The way to fix this is probably to allow an explicit DisplayRegion to be passed to the FilterManager to be passed instead of a camera and window pair. This is a trivial fix; in FilterManager.py, just add a “region=None” parameter to the init and then replace this code:

        region = None
        for i in range(win.getNumDisplayRegions()):
            dr = win.getDisplayRegion(i)
            drcam = dr.getCamera()
            if (drcam == cam): region=dr

with something like this:

        if region is not None:
            win = region.getWindow()
            cam = region.getCamera()
        else:
            for i in range(win.getNumDisplayRegions()):
                dr = win.getDisplayRegion(i)
                drcam = dr.getCamera()
                if (drcam == cam): region=dr

I’ll look into making such a fix permanent. (It would be even better if the FilterManager handled stereo under the hood, but the current design does not make that easy.)