Jump to content

  • Log In with Google      Sign In   
  • Create Account






Oculus Rift + Hieroglyph 3 = Fun!

Posted by Jason Z, 14 June 2014 · 134 views

rift d3d11
I recently have been adding support to Hieroglyph 3 for the Oculus Rift. This post is going to discuss the process a little bit, and how the design of the Hieroglyph 3 engine ended up providing a hassle free option for adding Rift interaction to an application. Here's the first screen shot of the properly running output rendering:

Attached Image


I have been an admirer of the Rift for quite some time, and I wanted to find a way to integrate it into some of the sample applications in Hieroglyph. I'll assume most of you are already familiar with the device itself, but when you think about how to integrate it into an engine you are looking at two different aspects: 1) Input from the HMD's sensors, and 2) Output to the HMD's screen. If your engine is modular, it shouldn't be too hard to add a few new options for a camera object and an rendering pass object.

After working on the engine for many years, I was completely not interested in building and maintaining multiple copies of my sample applications just to support a different camera and rendering model. I work pretty much on my own on the engine, and my free time seems to be vanishingly small nowadays, so it is critical to get a solution that would allow for either a runtime decision about standard or HMD rendering, or a compile time decision using a few definitions to conditionally choose the HMD. I'm pretty close to that point, and have a single new application (OculusRiftSample) set up for testing and integration.

Representing the HMD

The first step in getting Rift support was to build a few classes to represent the HMD itself. I am working with the OculusSDK 0.3.2 right now, which provides a C-API for interacting with the device. I basically created one class (RiftManager) that provides very simple RAII style initialization and uninitialization of the API itself, and then one class that would represent the overall HMD (RiftHMD).

RiftHMD is where most of the magic happens with the creation of an HMD object, lifetime management, and data acquisition and conversion to the Hieroglyph objects. The OculusSDK provides its own math types, so a few small conversion and helper functions to get the sensor orientation and some field of view values was necessary. You can check out the class here (header, source).

Getting the Input

Once you have a way to initialize the device and grab some sensor data, the first job is to apply that to an object in your scene that will represent the camera movement of your user. In Hieroglyph 3 this is a accomplished with an IController implementation, called RiftController (header, source). This simple class takes a shared_ptr to a RiftHMD instance, and then reads the orientation and writes it to the entity that it is attached to.

All actors in Hieroglyph are composed of a Node3D and an Entity3D. The node is the core of the object, and the entity is attached to it. This allows for easily composing both local (via the entity) and absolute (via the node) motion of an object. For our Rift based camera, we attach the RiftController to the entity of the Camera actor. This lets you move around with the normal WASD controls, but also look around with the Rift too.

Rendering the Output

Rendering is also quite interesting for the Rift. The DK1 device has a 1280x800 display, but you don't actually render to that object. Instead, you render to off-screen textures (at much higher resolutions) and then the SDK uses these textures as input to a final rendering pass that applies the distortion to your rendered images and maps that to the HMD's display. All of this stuff is nicely encapsulated into a specialized SceneRenderTask object called ViewRift (header, source).

This object creates the needed textures, sets up the state objects and viewports needed for rendering, and also supplies the actual rendering sequence needed for each eye. This construct where a rendering pass is encapsulated into an object has been one of the oldest and best design choices that I have ever made. I can't emphasize it enough - make your rendering code component based and you will be much happier in the long run! All rendering in Hieroglyph is done in these SceneRenderTask objects, which are just bound to the camera during initialization.

The Final Integration

So in the end, integration into an application follows these easy steps:

1. Create a RiftManager and RiftHMD instance.
2. Create the application's window according to the RiftHMD's resolution.
3. Create a RiftController and attach it to the Camera's entity.
4. Create a ViewRift object and bind it to the camera for rendering.
5. Put on the headset and look around :)

It is simple enough to meet my requirements of easy addition to existing samples. I still need to automate the process, but it is ready to go. Now I want to experiment with the device and see what types of new samples I could build that take advantage of the stereo vision capabilities. The device really is as cool as everyone says it is, so go out and give it a shot!




I tried a DK1 recently. I found the display really pixelated and the response time to head movements was really slow. Not sure if this is improved in DK2 or if it was something wrong with the setup.

 

There is a local shop offering demos for £2.50 for half an hour, which I'm sure is entirely illegal and I should probably report them. They were a bunch of total morons and may have had it set up wrong, but I was horribly aware of the three RGB colour rects on each pixel. Turning my head was producing a slow response much like the old VR sets from the '90s.

 

Anyone else found similar?

I actually find that the image is obviously pixelated, but I never noticed the sub-pixel color elements.  Regarding the tracking, I found that the response was quick, but that there is a motion blur if you move faster than a threshold amount.  The DK2 is supposed to take care of both of these issues at least to some degree, so it will be interesting to try it out.

 

The DK1 device certainly isn't perfect, but the initial experience was quite striking for me.  The way it makes you go into the scene is quite different from a normal gaming experience.  I think it is mostly due to the complete immersion - you can't see anything else but the game, so it is a much more 'full' notion of being there.  I can't wait to see where it all leads!

Absolutely agree re the immersion, apart from the distractions I mentioned. I hope the only solution to the pixelation problem isn't just ramping up the resolution (seems to be the current direction from what I can gather) as the upper limit will stop being anything to do with the Occulus hardware and become bound by the resolution your graphics hardware can render at.

 

They seem to be investing in higher and higher res tech at the moment, which is all fine and dandy, except how is a just-reasonable rig going to provide that HD content quickly enough?

 

Be a shame if you have to have a super-spec PC in order to provide Occulus with sufficiently high resolution input to avoid the pixelation. This I see as a real potential barrier at the moment.

 

Maybe there is some approach they can take to post-process a more normal resolution in hardware prior to display to reduce the pixel artifacts? This is wild speculation on my part here.

I completely agree.  The way that they do the rendering now does seem like a form of a work around.  You render to a target, and then they sample that and warp it for the distortion rendering.  It would be significantly more efficient if they used a warping technique and rendered directly to the final distorted image.  This would have similar challenges as paraboloid mapping, but the same solutions would apply - ensuring that your geometry is tessellated properly, and being careful to clip what is behind the view plane.

 

I also think that there are anti-aliasing techniques to be discovered that would work with the warped images.  Who knows though - I'm sure if John Carmack is working on it that he will be on top of the rendering challenges...

Indeed, far cleverer people than me well aware of these issues, I'm sure :)

 

Very interesting journal entry by the way, thanks. I'm quite fascinated to see where this new lunge at VR takes us over the next few years.

September 2014 »

S M T W T F S
 1 2 3456
78910111213
14151617181920
21222324252627
282930    

Recent Comments

Recent Comments

PARTNERS