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.
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.
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.
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.
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.
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.
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.
Figure out if you are render thread-bound or GPU-bound. For FATED, we are pretty much always GPU-bound.
Are we running at 75 fps?
This will show useful information about the scene’s rendering. You want to keep an eye on the number of draw calls, for example.
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.
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.
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!