Here are some useful findings when developing in Unreal Engine for the HoloLens 2:
- Getting started and installing the required plugins
- Creating a HoloLens 2 project in Unreal Engine
- Optimising project settings for augmented reality
Getting started and installing the required plugins
To start developing for the HoloLens 2, you need to update and install additional components to the Windows operating system, Visual Studio, and Unreal Engine.
Windows setup
Windows 10 | 10 1809 or later Enable Developer settings (Update & Security > For developers > Toggle on) |
Windows SDK | Windows SDK >= build 18362 (Can include this using the Visual Studio Installer) |
Visual Studio setup
Visual Studio 2019 | Latest version and workloads (Open VS Installer from Windows menu) * Desktop development with C++ * .NET desktop development Windows 10 SDK (>= 10.0.18x) * Universal Windows Platform (UWP) development * + USB Device Compatibility * + C++(v142) UWP tools * Required Disk Space = Total 17 Gig in the Visual Studio C:Drive |
Unreal Engine setup
Install UE4 | Downloads > login (version 4.25 or above) |
Install/Enable | HoloLens 2 |
UE4 Plugins | Plugins > Augmented Reality > HoloLens Plugins > Virtual Reality > Microsoft Windows Mixed Reality |
UE4 UXTools Plugin | UX Tools > Download .zip file from GitHub via releases Unzip into the UE Project Plugins folder (create if doesn’t exist) Install via UE Editor (will automatically pick up the plugins added) Show plugin content from editor view to view folder structure within the project |
Creating a HoloLens 2 project in Unreal Engine
Create a new project
When creating a new blank project in Unreal Engine, choose C++ as the type of project if you wish to package to a HoloLens 2 device, and set the quality to ‘Scalable 3D or 2D’, target ‘Mobile / Tablet’ (as the HoloLens is like a mobile device with limited computing processing compared to a desktop PC), disable ‘Raytracing’ and don’t include starter content.
Optimising project settings for Augmented Reality
Performance
To optimise the project for the Hololens 2, under: Project Settings > Engine > Rendering >
Mobile > Disable vertex fogging in mobile shaders = TRUE
Mobile > Maximum number of CSM cascades to render = 1
Culling > Occlusion Culling = FALSE
Forward Renderer > Forward Shading = TRUE
VR > Instanced Stereo = TRUE, Mobile HDR = FALSE, Mobile Multi-View = TRUE
AR Config
To manage the AR session, create an ARSessionConfig Data Object.
Add > Misc > Data Object > ARSessionConfig and rename it ‘ARSessionConfig’.
Set both ‘Generate Mesh Data from Tracked Geometry’ and ‘Track Scene Objects’ to TRUE and save.
On event begin play, start the AR session using the Session Config file created earlier. This can be created using the Blueprint editor.
On event end play, add the component ‘Stop AR Session’.
MR Pawn
The Pawn in Unreal Engine is the player, and this ‘Pawn’ can be optimised for Augmented Reality. Create a custom Pawn named ‘MRPawn’ to use in the project.
Add > Blueprints > Blueprint Class > DefaultPawn and rename it to ‘MRPawn’.
To avoid the ‘player’ from banging into things, remove the collision from the new Pawn. Double-click the MRPawn to edit and select ‘NoCollision’ from the Collision Presets. Do the same for the Mesh Component. Select the Collision Component and add a camera.
Using the MRPawn via Gamemode
To use your new Pawn, it needs to set up in the Gamemode component.
Add > Blueprint > Blueprint Class > (type ‘gamemodebase’ ) > select one
Double-click ‘gamemode’ and ‘Set Default Pawn’ to ‘MRPawn’, compile and save.
Set default map and gamemode on startup.
Now you have a custom MRPawn that is called from the gamemode, setup the default map (or scene) that opens when the project starts.
Settings > Project Settings > Maps & Modes, and then select the gamemode and your default map.
Summary
This post included some useful tips for developing for the HoloLens 2 in Unreal Engine and covered:
- Getting started and installing the required plugins
- Creating a HoloLens 2 project in Unreal Engine
- Optimising project settings for augmented reality