Unreal Reality: VR in Unreal Engine 4

Michaël Dubé —  March 18, 2015 — 4 Comments

Mik

Hey guys and gals!

Following last week’s post, which introduced some basic VR concepts, I thought I would do the same but oriented toward Unreal Engine 4. Since the engine went free a few weeks ago, I bet there are a lot of newcomers who could use a hand! So without further ado, let’s delve into the subject.

THE UNREAL EDITOR AND VR

There are a lot of ways to preview your content in Unreal, two of which are particularly helpful for VR. The Play mode can be found in the toolbar above the viewport in the standard Unreal layout.

VR Preview:

This Play mode starts the game in VR mode directly inside the editor. This is new in Unreal 4.7 and is very useful to actually have HMD data inside the editor to debug (in blueprints, for example). This Play mode works well with the Oculus’ Direct to HMD, but it seems to have some issues in extended mode.

PlayMode

Standalone Game:

Prior to 4.7, this was the way to test your VR content. Pressing Alt+Enter starts the stereo rendering. We still use it to profile using Intel GPA. More on our usage of Intel GPA in another post!

World to Meters:

In the World settings, this value is under the VR category. This is the representation of Unreal units to real-world meters. 100 means that 100 Unreal Units equal 1 meter in real life. For FATED, we played a bit with this value to get the proportions we needed. It is recommended to set this value so that it fits with the real-life measurement of your in-game objects.

Head Mounted Display Blueprint Nodes:

There are a lot of exposed methods to do logic directly inside blueprints. This category should be the first place to look for HMD-related functionalities.

HMDBlueprint

Use Less CPU in Background:

You want the editor to stop most of its processing when testing your content. This option can be found under the Editor Preferences in the Miscellaneous section.

LessCPU

Scalability Settings:

I feel like I’m repeating myself, but performance is critical in a VR game! Unreal Engine 4 comes with a great scalability features that can help create the range of performance for your game, from your minimum specs to your recommended specs. More on this in a performance post I’m planning to write soon.

Scalability

COMMAND LINE FUN!

If you’re already familiar with Unreal development, you know about the console and all the commands that can be entered through it. This is also true about the HMD Interface (Head-Mounted Display). Most of these commands are accessed with the “hmd” keyword; here is a list of the ones we use the most in FATED’s development.

hmd stats:

This command displays info about your HMD. A lot of the stuff I’ve mentioned in my previous post can be seen here. Your current latency, whether positional tracking is activated, whether the camera is detecting the HMD, etc. There is also information on Time Warping, and whether the engine is updating the HMD info in the render thread. These are techniques to reduce latency that come right out of the gate in Unreal 4, making it a top-of-the-line choice for VR development.

hmd sp YYY:

YYY must be replaced by a number between 30 and 300. This is one of the easiest performance boosters at the expanse of visual quality. To create a better-looking picture, Unreal scales the image before the distortion process, sampling down afterwards to fit your HMD screen. By default it is at 135, but you can easily bring it down to 100 for better performance. It does look better at a higher percentage, though!

hmd vsync on/off:

Deactivating vsync can be useful to track your actual framerate.

stat unit:

Figure out if you are render thread-bound or GPU-bound. For FATED, we are pretty much always GPU-bound.

stat fps:

Are we running at 75 fps?

stat scenerendering:

This will show useful information about the scene’s rendering. You want to keep an eye on the number of draw calls, for example.

show YYY:

The ‘show’ commands are useful to hide some elements of your scene to try and figure out how much each of these elements takes to render. ‘Show staticmeshes’ and ‘show postprocessing’ are two examples of commands we used in early profiling.

ShowCommands

profile GPU:

This will launch the Unreal Engine GPU Profiler. You can also do this at any time by pressing [Ctrl+Shift+,]. This is a good one to know about, as it is the first tool you will want to use for GPU performance profiling. It is kind of limited (and the reason we are using Intel GPA for deeper profiling), but it will point out some of the costlier effects in your scene.

GPUProfiler

These are the most useful ones for us, but go digging in there and you’ll find plenty other commands that are useful.

In my next episode of the FATED blog…

That’s it for now! Next time, I will talk a bit more about performance and how we got FATED running on a “normal” rig while still retaining great visuals!

Meanwhile, don’t hesitate to comment or ask a question; we’ll be happy to discuss with you guys!

4 responses to Unreal Reality: VR in Unreal Engine 4

  1. 

    Wow, thanks for such a great post. Super helpful!

    I was wondering, what kind of machines are you developing and presenting on? Especially video cards.

    cheers

    Like

    • 

      Hi bnicolucci! I’m glad you found the post helpful 🙂

      The development machines we are working on are using i7 processor (@3.5 GHz), 16GB of RAM on Windows 7/Windows 8 (64 bits).

      Regarding video cards, we are mainly testing using NVIDIA GeForce GTX 680 and NVIDIA GeForce GTX 760, for now.

      Since the headsets are bound to change specs before the consumer version, we may need to get better cards but we are always aiming at improving performance so that our game can be enjoyed by as much people as possible.

      Keep reading the blog, there’s a lot more coming soon!

      Mick

      Liked by 1 person

      • 

        Great Work! Man.

        Which hmd is you develop to, oculus rift.gear vr or others?

        I got a question that when I open my project, the ‘vr preview’ is gray, and cannot be clicked. My hmd is gear vr.

        Thanks firstly!

        Like

  2. 

    Hey Tim,

    We are developing for the Oculus Rift, HTC Vive and Playstation VR HMDs. The “VR Preview” button is probably greyed out because the engine does not detect any VR device connected to your PC. Since you are developing on a phone for the GearVR, it won’t show up.

    As far as I know, you would need to package your game to get it running on your GearVR. Obviously, since we are not developing with that platform, I may be wrong!

    Good luck!

    Mick

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s