Just one last step to get Oculus Rift working fully in BGE

I am working on Oculus Rift support in the Game Engine. I got the input pretty fast, i wrapped the (Boost Licenced) OpenHMD library to Python, and got the sensor data pretty easy. With some transformation hacking, I got the camera rotation. The wrapper can be found in my github: https://github.com/lubosz/python-rift
I didn’t publish an example yet how to use it, I will provide a blend file and the python code at some time.

For the demo I am working on, I got Wii Balance Board support in a similar way (https://github.com/lubosz/python-balanceboard)

My biggest Problem is the rendering though. You need a stereo side-by-side image with reverse lens distortion for the rift.
It is described here: http://www.dgp.toronto.edu/~mccrae/projects/firebox/
Another shader that does that can also be found here: https://github.com/OpenHMD/OpenHMD/blob/master/examples/opengl/shaders/test1.frag.glsl

Blender does stereo side-by-side, but when I apply such shader, the render result is asymmetric and I don’t get why. It’s symmetric for mono and above-below stereo.

The problem explained, renderings, the GLSL shader and a blend file can be found in my stackexchange post:

As mentioned in this thread, 2D filters are broken with stereo rendering:
http://www.mtbs3d.com/phpbb/viewtopic.php?f=140&t=17081

However, I don’t entirely like the solution proposed, and I’m trying to come up with another fix.

Here is a patch that will fix it:
http://www.pasteall.org/43512/diff

Does this work for all 2D filters? (I basically only to stereo 3D games in BGE, so I can use anybody’s filters)

Also, would it be possible to make “rift” a setting in the stereo menu itself?

I was thinking of hacking in support where you’d have two fisheye cameras, and render sbs. I’m guessing the shader would be way better.

The 2d filter and the patch work flawlessly (cmake + mingw32 w/ blender 2.68 standard build. Fov= 108 / resolution = 1280 x 800). I was surprised at how much better the overall effect was compared to shoe horned commercial titles like Skyrim on the Rift. Thank you both! I think this warrants a GraphicAll build.

@PaulStormblader
The rasterizer patch works for all 2d filters including customs but it only fixes the primary problem of the filters being applied more strongly to the left eye than the right. Many filters, like SSAO, will have to be manually adjusted because the results will be offset due to the spherical mapping.

There’s intents to provide a complete example (GraphicAll build included)?
I’m very excited about test my oculus with blender.

So is this patch making Blender fully compatible with the Oculus Rift? Any video to show how this work? and the most important question… if the patch works, it is going to be added into the official trunk?

Video :smiley:

I want to see this in the editor and the BGE :smiley:

I’m trying to get it working but PyRift shows import problem :

I’m trying the simple command inside blender :

from game_engine_rift.rift import PyRift

and in the console I get :

ImportError: libopenhmd.so.0: cannot open shared object file: No such file or directory

I’m on Ubuntu 13.10
I’ve got the right “rift.cpython-33m.so” file built as requested (with cython 0.19).
I had to change a bit setup.py and CMakeList.txt since openhmd.h is inside “usr/local/include/openhmd” and not “/usr/include/openhmd”

I’ve found that “libopenhmd.so.0” is in fact in “/usr/local/lib/”. Why is it not found by the module??

By the way, OpenHMD is working great with my Oculus Rift!! I would love to see that inside Blender!

I got it working!
I had to load the libraries apparently by

sudo ldconfig

And I know I can control the camera inside Blender by moving my Oculus rift: it’s great!

hello Klopp, do you have a working blend file at the moment? I would be very interested.

At the moment I am working with Oculus Rift and trying to build an easy working pipepline for artists. There are three ways which I found so far:

-Unity Game engine (which is unfortunately only working in unity pro, which costs some 1500$. I have that licence but not every artist can afford it)
-Blender Game engine + Delicode NiMate middleware (Which costs some, but unfortunately it is not so stable and only works with a kinect)

  • Ogre3D, which looks good working but needs toooo mucj coding for a visual artist.

Do you know maybe a 4th way which could work better?

I would be happy if you know a solution.

Can we use this on Windows somehow? My Unity Pro trial has run out and I’m just aching to develop for the Rift, but I know nothing of Linux :1

Of course you can! I’ve begun to develop my projects for Windows at first as for me… But I advise you (as I was advised when I begun) to switch to Linux: The import of addons was trickier for me on Windows.
If you know nothing of linux, I don’t see a problem since with ubuntu for example as I use now, you’ll find yourself in known territories! No problem to switch to that

Okay, so I’m trying to improve the distorsion effect : with the script like this from lubosz blog ( http://lubosz.wordpress.com/2013/06/26/oculus-rift-support-in-blender-game-engine/comment-page-1/#comment-97 ), there are big black bands around the images, which decrease the size of the usable image on the screen.
I’m trying to adapt to Blender the Oculus rift SDK where this problem was specifically tackled :
http://static.oculusvr.com/sdk-downloads/documents/Oculus_SDK_Overview.pdf



Other people have succeeded in doing that?

One problem with using the Rift SDK is that it is not GPL compatible. :frowning:

Thanks a lot Moguri for your patch by the way, you did a great job!

Okay, I’ve managed to get a fair good distorsion effect, using the script, and then tweaking with the “scaleFactor”
But I was wondering how to compute these number : HmdParam, Scale, ScaleIn, like described in the SDK.

Even if The Rift SDK isn’t GPL compatible, the entire source is available to help us to know how it’s done

the pixel shader : http://pastebin.com/4vvNXg7n

Haven’t been on here for a while, but um, if I wanted to get it to work on Windows, could you guide me? If not, which Linux distribution should I get?

I’m on Ubuntu 14.04 as for me, but I’m not sure the distribution is important anyway and others probably work too.

I’m waiting for Oculus Rift support for BGE as well, and hope that will be added by default. Let us know how it goes, and hopefully a dev can officially accept this patch.