PHOBOSLAB

Blog Home

Quake for Oculus Rift

With the many "modern" games like Half-Life 2 and Doom 3 already modified to support the Oculus Rift, I decided to give one of my favorite classic games a shot: the original Quake.

Id Software long ago released the full Source Code of Quake under the GPL license. It has been ported to virtually every hardware platform in existence by the community and is still maintaned and kept up to date by several Open Source projects. One of them is the excellent Quakespasm - it aims to be faithful to the original with no changes to the gameplay but tons of smaller improvements and bugfixes. It's built on top of SDL, so it runs on Windows, OSX and Linux.

Quakespasm provided a nice and clean starting point to implement support for the Rift. It's evident that Quake's C source code has a radically different style than John Carmack's later games, with almost all data stored in global variables and tons of functions with no arguments. Still, the source is very straight forward and easily understandable. I had almost no problems implementing the Rift support, but in the end took quite a few shortcuts with some dirty hacks.

All in all, it works really well with the Rift. Quake feels even grittier and darker than it ever did before. The textures are pretty coarse and you can count the polygons on the enemies by hand, but it all comes together so nicely when you run through the corridors, completely immersed in the world with the original Nine Inch Nails soundtrack blasting through your headphones. For me personally, this ended up being one of the most enjoyable Rift experiences.

There are still various problems. Making the UI readable in Rift mode is a single dirty hack, some values for the eye offsets are elaborate guesses and in general this thing could have been implemented a lot cleaner. But as far as I can tell, everything works like it should. I only tried this on Windows; my guess is that it works on OSX as well, but I haven't changed the project files to incorporate the new code.

To enable Rift support, bring up the console (~ key) and type the following:

vr_enabled 1

If your Rift is connected, this should be all that's needed to get started. On my system, turning on VSync was a good idea - updates are a bit slower, but less stuttery. There's no tearing without VSync, so I assume that SDL is doing something funky here behind the scenes.

You can still buy the full game at idsoftware.com or on Steam.

Edit July 6th: I fixed some rendering issues that warped the view. Please re-download.

Edit July 7th: Switched to predicted view orientation and added vr_supersample option.

Edit August 22nd: renamed all cvars to have a vr_ prefix. See the Readme on Github for a list of available cvars.

Friday, July 5th 2013

58 Comments:

#1 – Aleks – Friday, July 5th 2013, 15:28

I didn't had the chance to try an oculus rift yet, but i'm definitely going to buy one, as soon as they're available for normal costumers.

Can't wait to try Quake with the Rift! :)

#2 – WormSlayer – Friday, July 5th 2013, 19:41

Nice work. Seems to be some odd distortion and it badly needs antialiasing but it's about time someone made this old girl Rift compatible :)

#3Jason Sperske – Friday, July 5th 2013, 20:05

My rift is a couple of weeks away, but this will be the first app I try. Amazing effort, and great job!

#4 – Baggyg – Friday, July 5th 2013, 22:05

Hi,

Excellent work - cant wait to try. Trying and my Win XP laptop and doesnt work with the following error:
The procedure entry point SHGetKnownFolderPath could not be located in the dynamic link library SHELL32.dll.

After a bit of googling I can see that this function call is not supported in XP

#5 – Miles – Friday, July 5th 2013, 22:54

This works really nicely. I'd be tempted to break the look view from the shoot view. I ended up spinning in my chair to shoot people. Reorienting is a PITA.

... We need a higher res oculus. It's like playing tetris at times

#6Dominic – Saturday, July 6th 2013, 00:13

It seems compiling for Windows is quite a bit more complicated than I thought. Google says I can't compile for WinXP with Visual Studio 2010 :/

#7 – Spankeey77 – Saturday, July 6th 2013, 00:40

This is a great experience right out of the box, well done good sir! I really enjoyed playing through episode 1 with this, brought back some good memories!

Any chance of getting Doom 1/2 working on Rift with something like gzdoom ? =D one can dream right ?

#8joe – Saturday, July 6th 2013, 01:51

brilliant! i agree that there is some weird distortion, but good work regardless. it's amazing the sense of scale (the world seemed much smaller than i remember it, and some of the objects are hilariously large).

#9Dominic – Saturday, July 6th 2013, 02:09

@joe: you probably tried the old version. I thought I fixed the distortion bug a few ours ago. Please re-download.

#10 – WormSlayer – Saturday, July 6th 2013, 02:16

Any chance you could try and add this patch?

td007.dvrcam.info/?bzs=c291cmNlzm9yz2UuBmv0L3AVcXvha2vZcGFZBs9wYXRjaGvZLZkV

#11 – Baggyg – Saturday, July 6th 2013, 10:32

@Dominic
The version you did works fine on Windows XP in terms of running the exe. You just need to branch the SHGetKnownFolderPath call. On XP I think it is just SHGetFolderPath but if you quickly google you should find an answer. Simply branch the call depening in WINVER..

#12Dominic – Saturday, July 6th 2013, 11:40

@Baggyg: narf, that call to SHGetKnownFolderPath was in the Oculus SDK. I hacked it out and recompiled - should work on XP now.

#13 – JamesM – Saturday, July 6th 2013, 13:01

Hi! It's great work! You motivated me to re-buy Quake :)

I have an important observation/question though - the depth effect does not seem to be there, or if it is there, it seems not very pronounced.

For example, if you look at any point in the scene with both eyes, and close one or the other eye to observe the binocular disparity, this distance seems to be constant everywhere. For instance, the renderings of the player weapon in either eye appear to be the same. This seems to be true for points on surfaces close or far away.

This leads me to believe that the eyes (or "cameras") are rendering from the same world position for each eye, causing constant disparity and thus no variation in the perceived depth (disparity should increase as objects get closer).

What value are you translating the eye/camera left and right when rendering each eye (relative say, to the height of the player character)?

A good value to use might be consider average IPD (6.4cm) and average height (180cm) (well maybe this height is not average). This gives you a factor 6.4/180. So if your in-world character's height is e.g. 2 world units, you want an eye separation of 2 world units * (6.4/180) for a "real-ish" effect. Each eye translates half that distance in opposite directions from the centre point between the eyes (where the default eye/camera is placed when playing in "monocular" mode :) ). (And of course our eyes are not right on top of our heads, so you might use another height value, e.g. 170cm).

If the eye separation/translation has been done, is there a way to set the value manually? (Like another convar command?)

And just to reiterate so you don't think I'm not appreciative - great work!

#14Dominic – Saturday, July 6th 2013, 14:03

@JamesM: you're right.

The height of the player's view in Quake is 56 world units. This works out to something like 2 units of separation between the eyes. I previously only specified something around 0.5 units.

I updated the ZIP. I looks much better now. Thanks!

(changes: github.com/phoboslab/Quakespasm-Rift/commit/fb0d88cfa32c8048df90e1447d81abf10baa286a )

#15 – Zuqo – Sunday, July 7th 2013, 01:32

Thanks alot. Like many, this is the FPS I loved the most growing up.

If I may make a question: do you intend to decouple the aiming from the normal view so you can aim with the hydra, mouse etc. independently from your head?

#16Juanlo – Sunday, July 7th 2013, 01:33

it looks like there are some problems with transparent water. After patching the PAK files with vispatch, I can set r_wateralpha and it works perfectly in normal mode. But when I enable Oculus Rift, some waterish zones (like the 3 portals when you start a new game) show a hall of mirrors effect. Disabling Oculus Rift fixes it.

#17 – Rich Benson – Sunday, July 7th 2013, 01:48

I downloaded the Zip around 30 minutes ago and ran it. The 3D didn't seem great and after playing it for 10 minutes and taking off the OR, my vision is blurry - as if the convergence was wrong and my brain was compensating. Is anyone else having this issue with the latest version? I didn't change any settings. I just enabled the oculus rift support.

Rich

#18 – Rich Benson – Sunday, July 7th 2013, 01:49

Oh and either way, great work! it's great to have this working with full source. :)

#19 – JamesM – Sunday, July 7th 2013, 05:46

Awesome, just tried it! Thanks Dominic!

(And thanks also for giving me something that prevents me from doing anything resembling work for a while ;) )

#20Lauri – Sunday, July 7th 2013, 10:08

Thanks for the great port! I've been playing this now for a whole day...

I found that two additional small changes improved the gameplay still further:

The intermediate framebuffers for each eye were rendered at screen resolution, which looked to me like it wasn't sufficient after the barrel distortion transformation. So I tripled the resolution, and that seems to have helped a lot with the detail in the middle of the screen: pastebin.com/YkaANCtC

Hmm, that patch is missing glwidth *= 3; ... well, it works anyhow.

And in addition to that, I like using the predicted head movement for the view: pastebin.com/sLAG4b0J

#21Dominic – Sunday, July 7th 2013, 13:02

@Lauri: awesome, thank you! I added the super sampling as a cvar 'r_oculusrift_supersample'

#22 – Jesse – Wednesday, July 10th 2013, 21:35

The Mac version doesn't launch for me:

"Check with the developer to make sure QuakeSpasm works with this version of OS X. You may need to reinstall the application."

Mac OS X 10.8.3

#23 – Jay – Thursday, July 11th 2013, 17:16

Awesome work :) *nostalgia*

#24 – RABID – Thursday, July 11th 2013, 17:39

Any chance of adding support for some of the HD texture packs?

#25jeremiah sypult – Friday, July 12th 2013, 04:28

I've done some work to get the OS X version to run properly (there was an issue with the SDL framework). I've also enabled HMD rendering without an Oculus Rift.

You can see my fork on GitHub here:
github.com/jeremiah-sypult/Quakespasm-Rift

(I sent you a pull request, too -- if you like what you see, perhaps you could update your linked Mac OS X binary here for others?)

Sincerely appreciate your work on this -- I can't wait to get my hands on a rift to experience it first hand....

#26 – tlp – Sunday, July 14th 2013, 04:01

Thought I'd mention this builds and runs perfectly on Linux with a few modifications to the Makefile: pastebin.com/RTQgSkDA

On my system, libovr.a is placed in /usr/local/lib. You will of course need the Linux SDK src and indicate its path in the Makefile.

It only works in 1280x800, however; otherwise the stereo images are improperly scaled.


#27 – jrd3d – Monday, July 15th 2013, 02:45

Is there a way to get the official expansion packs to work with this?

#28 – Alex – Wednesday, July 17th 2013, 14:33

Hey, I have a CD of Quake, will the Quakespasm Rift work on any version of Quake1? I bought the ultimate quake a while back, will this be suitable?

#29Dominic – Wednesday, July 17th 2013, 15:17

@tlp: I believe other resolutions should work as well, but you have to change the res first, then enable rift mode.

@Alex: yes. You just need to copy the "id1" folder (actually just the two .pak files) into the Quakespasm directory.

#30 – lipplog – Saturday, July 20th 2013, 10:30

Forgive me, as I am brand new to the world of OculusVR. What are the command line parameters settings?

#31MercuriusFM – Saturday, August 3rd 2013, 12:01

works well overall and is the first real game I'm able to play with the Rift on my older MacBook Pro (thank you!). One thing though, is that i feel cross eyed after playing. I'm on mac os x. is there anyway to adjust the eye settings and camera height in mac os x?

#32Mercurius FM – Saturday, August 3rd 2013, 12:32

i'd like to follow up that adjusting the lenses to be closer to my face (using the screw adjustments on the side seems to help with the cross eye effect). I guess this should be adjusted per user. Also it seems to give the least hassle with a resolution around 720. Just my 2 cents.

#33 – MooseWhite – Sunday, August 11th 2013, 01:03

While quake TF was the game that really started it all for me... Quake 2 will always be my favorite. I can't wait to get my rift and try this out. Thank you

#34 – Hadtstec – Thursday, August 15th 2013, 13:47

This works really well and its just anoying that you can't move the gun independently from the Headtracking.
Do you think its possible with the Quake engine?

#35Demiath – Sunday, August 18th 2013, 13:15

I haven't been blown away by the Oculus Rift dev kit so far (the NVIDIA 3D Vision 2 is still by far my favorite 3D gaming device). That said, your work on Quake 1 provided me with some of my best OR moments so far!

#36 – Jon – Saturday, August 31st 2013, 17:42

What am i doing wrong?
I have downloaded the "Quakespasm Rift for Windows" and extracted it.

When I open the console and enter
"vr_enable 1" i'm getting "Unknown command "vr_enable"

#37 – Matt – Sunday, September 1st 2013, 01:21

Jon... I have the same problem... "vr_enable 1" gets me the unknown command "vr_enable 1"... strange... not sure what's up. ??

#38Dominic – Sunday, September 1st 2013, 01:49

@Jon, @Matt, sorry, that was a typo. It's 'vr_enabled 1', with a 'd' at the end :)

Also, you can just type "vr_" and hit tab for auto-completion.

#39 – DST – Monday, September 2nd 2013, 14:24

I managed to compile, link and run it! :D
The rendering seems to work quite well, however, for some reason everything is jumping around violently, stuttering and shaking, if I make any movement of the HMD.
However, my hmd works fine in all other demos.
My temp hack is to disable all the sensor stuff and just use the mouse, which is actually not that bad as long as you keep your head still ;)

I used the 0.2.4 sdk on 32 bit arch.

#40 – HMS0209 – Friday, September 20th 2013, 04:03

Game is working good, but I`m not feeling so much depth on 3D, also I`m getting no convergence on weapon and hud. How do I fix it and increase 3d feeling/depth?

Laptop HPdev6, i7 3630QM, Nvidia GT650M, Win8, Oculus Rift 1.1 on HDMI.

#41 – Jamie – Friday, October 4th 2013, 13:13

Hi, I've downloaded the source for version 1.7 and am having trouble compiling. I'm running 64-bit Linux. I'm trying to compile by cd-ing to the "Quake" directory and:

 make OVR_SDK=~/Downloads/OculusSDK/LibOVR


The compilation proceeds for a while and then fails with:

cl_parse.c: In function 'void CL_ParseServerMessage()':
cl_parse.c:1024:30: error: too many arguments to function 'void VR_SetAngles()'
vr.h:51:6: note: declared here
make: *** [cl_parse.o] Error 1


I've looked at the files in question and it just looks like a plain old mistake in cl_parse.c or vr.h. But others seem to have compiled okay! I'm probably being dumb. Can anyone help?

#42 – Matti – Friday, October 25th 2013, 11:58

@Jamie, @Dominic - there is some error in the newest code, after I changed in vr.h:

-void VR_SetAngles();
+void VR_SetAngles(vec3_t angles);

I got rid of the error described by Jamie. But then I also had another problem with the magnetometer calibration, it seems the latest linux sdk doesn't yet support this. I had to comment out from vr_ovr.cpp all lines dealing with the variable "magnet".

Otherwise the latest code seems to work well in linux without further modifications. Though the makefile is confusing as it instructs to build with "make OVR_SDK=..." while the actual path parameter is "LIBOVR"..

#43ciscon – Wednesday, November 6th 2013, 22:52

thanks for that matti, got me up and running much quicker without me having to hunt things down. a few ifdefs and perhaps a configure script would solve pretty much all of these problems.

#44 – Trevor – Thursday, November 14th 2013, 08:17

Awesome. I just tried this out for the rift, and it's a fantastic experience! I didn't even feel sick after running and strafing through the first two levels! That's pretty impressive, considering that a lot of work was put into a Minecraft mod for the rift, and it makes me feel pretty sick after 5 minutes.

#45 – Eric – Tuesday, December 17th 2013, 02:02

is this compatible with any of the high resolution texture sets for quake?

#46 – Adam – Friday, January 24th 2014, 16:56

This is so much fun, thanks for such an amazing implementation!

#47 – Jon – Friday, January 24th 2014, 19:41

Works brilliantly. Thank you for your efforts.

#48 – Billhelm – Monday, January 27th 2014, 03:35

Hello,

Fantastic work. Would you consider increasing the maximum value for vr_deadzone to 360, or create a new aim mode that completely decouples aiming from looking? Thanks.

#49 – Alec – Saturday, February 1st 2014, 22:17

Just tried this one out and it's awesome. Very immersive and the mechanic where you just look down to check health and ammo works perfectly.

Very surprised how much fun this one was, didn't make me motion sick like Duke3d did.

Thanks.

#50 – W – Friday, February 7th 2014, 09:36

Hi,

I'm a newbie when it comes to compiling software on linux (or in general), but I'm getting an error saying someting along the lines of "no rule to make target oculus_sdk.o". Am I missing something?

#51 – wooferwolf – Sunday, March 2nd 2014, 01:05

Hello! I'm dying to try this on my Rift, but when I run it and enable rift support, it is like the eyes are swapped or like the convergence is way off. Am I doing something wrong? Can I fix this?

#52 – Rob – Wednesday, July 9th 2014, 01:41

any chance this will be updated for the DK2?

#53 – Joe – Friday, August 1st 2014, 03:56

Please re-compile for DK2!

#54 – Joost – Saturday, August 2nd 2014, 01:42

Would love to see a DK2 version for this :)

#55jeremiah sypult – Thursday, August 7th 2014, 07:41

I've just pushed up some DK2 support to my fork on Github. Unfortunately, I'm only developing on OS X so binaries for Windows or Linux aren't yet provided.

github.com/jeremiah-sypult/Quakespasm-Rift/releases

It's using the latest Oculus SDK that was multi-platform, so positional tracking isn't yet supported. Once SDK 0.4 gets released I'll be working on that ASAP.

Per Billhelm's comment above, I've also added a way to decouple looking + aiming (use it with vr_deadzone 180).

I've started a thread on the Oculus VR developer forums to talk about DK2 support here:

developer.oculusvr.com/forums/viewtopic.php?f=28&t=12065

#56jeremiah sypult – Thursday, August 7th 2014, 10:35

....aaaand after a couple hours I just posted a Windows binary on the releases page above....

#57DEx – Sunday, August 10th 2014, 18:23

Well, it has many issues.
First of all getting the picture in to the "rift" was a pain since i had to move it like a window to the other monitor (rift) and find the exact good spot.
And the helth warning never disapeared ... so it was unplayable

#58 – Tiko257 – Monday, August 11th 2014, 23:11

Awesome!!... the port works really well ... but enemies (and double barrel shotgun) looks so small .... I think scale was not that important back in 1996 ...

Post a Comment:

Comment: (Required)

(use <code> tags for preformatted text; URLs are recognized automatically)

Name: (Required)

URL:

Please type phoboslab into the following input field or enable Javascript. This is an anti-spam measure. Sorry for the inconvenience.