VR: Developer Alpha

We’re excited to announce support for VR in ROBLOX! This is a very early preview that makes it possible to adapt the games to work in VR. It’s mainly targeted at developers - a lot of product features (like play loop, platform integration etc) are missing.

Platforms

We currently only support Oculus Rift devices (namely, DK1 and DK2). To make it work, just install Oculus 0.8 Runtime from https://developer.oculus.com/downloads/pc/0.8.0.0-beta/Oculus_Runtime_for_Windows/.

While our intention is to eventually support all major VR platforms/devices, we have not yet settled on the release platform(s). Treat this as a development preview, not as a product.

How to enable VR

VR is enabled as long as you have a compatible device:

  1. Whenever you play a game on ROBLOX on PC, we automatically activate VR if you have Oculus Rift plugged in and powered on

  2. Whenever you use Play Solo in ROBLOX Studio, we automatically activate VR as well. Studio server/client mode currently does not use VR.

As we develop VR support further we are considering adding VR as another formfactor, similar to tablet/phone/desktop. For now it’s lumped in with desktop.

If you don’t want to play or test in VR, just power your Rift off (or unplug).

Due to some compatibility issues with Oculus Runtime in some cases it may hang the client; usually to solve this you have to restart Oculus Runtime.

Content

In VR the most important part is having most of your content in 3D. We are not ready right now to provide guidelines on what works well and what does not - in part we expect you to help us figure it out, however one significant itme would be to minimize or eliminate your usage of 2D UI. In VR we display your 2D UI in the center of the screen so that all control elements are not in your peripheral vision, but the details of how we handle 2D UI may change.

Both SurfaceGUI and BillboardGUI work fine in VR so you should use them. We currently have player names hidden in VR but we’ll fix this in upcoming releases.

We currently have neon, water reflections and SSAO disabled in VR - instead we force enable MSAA. Support for these effects in VR will be restored (also next week MSAA in VR will scale with the quality level).

API

While we’re still fleshing out the details of working with cameras in VR in ROBLOX, the basic element you should have is using the tracking data from the VR headset (position and orientation, essentially) to control the camera. To do that we expose these APIs:

bool UserInputService.IsVREnabled

This is true if your game is running in a VR environment; you could use this to disable certain control elements that are problematic in VR

CFrame UserInputService.UserHeadCFrame

This is the CFrame containing head position/orientation data, with the origin being the “resting head” position - you can reset the origin in Oculus Debug Utility.

We’re working on adding code that uses these APIs to builtin camera/character control scripts. For now you could just use the head CFrame transformation for your camera, e.g.:

local vrframe = game:GetService("UserInputService").UserHeadCFrame
workspace.CurrentCamera.CoordinateFrame = basecameracframe * vrframe

(assuming basecameracframe is constructed using inputs from controller)

Please note that the API is experimental. If we need to change the API we will provide limited compatibility by deprecating the old API and creating new API, but the deprecated VR APIs will be removed at some point before official launch. Of course you’ll be notified of all API changes.

Controls

Currently the most natural device for VR is the gamepad - it’s easy to locate gamepad buttons with your hands without taking the headset off. However, keyboard/mouse can also work well in some cases - we encourage experimentation. You should also read this https://developer.oculus.com/documentation/intro-vr/latest/concepts/book-bp/ for some information that was gathered by Oculus during their testing.

Performance

One final important criteria for VR is performance. Desktop VR devices that are shipping this year are targeting 90 Hz refresh rate; since we have to render the scene twice this puts additional pressure on the graphics card and our rendering subsystem. On mobile you still need to maintain 60 Hz and the device is way slower. All of this means that performance will be very important for VR.

We’re doing a lot of work on our side - some of the performance improvements are already in the shipping stage, and some are planned. This includes all systems - physics/rendering/sound/etc. However, we’ll also expect the developers of games to be aware of performance issues and anti-patterns - expect to hear more performance-related discussions and guidelines from us in the future.

In addition to that, of course you need a reasonably powerful PC. ROBLOX VR will work well on PC on systems that are not “Oculus-ready” performance-wise, but the quality of your experience will directly depend on your CPU and GPU.

When?

All of the above is already live on desktop client and Studio - so if you happen to have a DK1/DK2 or a friend who has one, you can start now! We will ship incremental updates that enhance built-in systems with better VR support, add new APIs for VR-compatible games to use, optimize client with VR in mind, etc. Interestingly, most of the optimization work benefits us across the board - VR just sets a much higher bar in terms of performance, but it’s not that unique otherwise.

Can’t wait to see what you come up with!

44 Likes

Well… now I just need an Oculus Rift.

23 Likes

I think this code would work to control the camera with the VR device:

local Camera = workspace.CurrentCamera
local RS = game:GetService("RunService").RenderStepped
local UIS = game:GetService("UserInputService")

Camera.CameraType = "Scriptable"

local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Head = Character:WaitForChild("Head")

local CF = Camera.CoordinateFrame
CF = CF - CF.p

while true do
	local vrframe = UIS.UserHeadCFrame
	vrframe = vrframe - vrframe.p
	vrframe = vrframe:lerp(CFrame.new(),0.75)
	CF = CF * vrframe
	Camera.CoordinateFrame = CF
	RS:wait()
end

(Will lock your camera to First Person, but I guess that’s a good goal here)
I assume that UserHeadCFrame is just a rotation, so its position is 0,0,0?

EDIT: I just realised you need to look behind you, away from your PC to look backwards in-game.
Eh, I might edit the code to work a bit… better…

EDIT2: If you look left, the camera should now rotate left. It’s like a joystick, your head being the stick.

10 Likes

Google cardboard on Android?

6 Likes

Why just android? Cardboard also works on iOS :stuck_out_tongue:

3 Likes

I’m working on updating the default playerscripts to work with VR. It’ll be as generic as we can manage, so you’ll still be able to override it like that and do your own!

5 Likes

I kinda meant mobile. Just used Android out of habit.

2 Likes

Just writing a quick temporary thing people can use.
I’m bored anyways, might as well write some code.

EDIT: I think I made my code much better.
The VR device should now act like a sort of joystick.

Now I really want to get a rift… MY MONEY THO ;(

2 Likes

It depends on the VR device. On DK1/Cardboard/GearVR you’d get 0. On DK2 you’d get the position of your head…

1 Like

Stay tuned.

4 Likes

That’s weird.
Can the DK2 give the relative position from the “scanner” or something?

EDIT: Changed the code to ignore position anyways

It has an external camera and IR lights on the headset.

Oeh fancy.
So for example, in Phantom Forces Beta, since it’s a FPS:
You can make it that if you move your head left, your character leans to the left too?
[size=11]gotta see if there’s an enemy behind the corner, let’s stick my head out[/size]

Neat, I’ll try this out with a rift when I get home. I tried using those two properties a few days ago but they didn’t seem to be activated.

This is really exciting!

Now the question is, where can I find an Oculus Rift

1 Like

If we get Google Cardboard ($20 + existing phone vs $600 for Oculus Rift), can we plug it into a laptop/desktop? I would prefer to use a keyboard and use powerful laptop specs rather than rely on the mobile CPU on my LG G3.

1 Like

If this could work with Steam VR that would be great. Steam VR is $50 for whenever it comes out and that is much more affordable than $600.

EDIT: it was released that it is several hundred dollars, must have been mistaken… it is still cheaper than oculus though

1 Like

Yes. And iron sights! Iron sights!!! Like you actually have to aim with your left eye closed. PF <3.

3 Likes

That… seems… unlikely. You may be thinking of Cardboard.

3 Likes