Oculus provides samples which illustrate basic VR concepts in Unreal such as hand tracking, haptics, and the Boundary Component API for interacting with the Guardian System.
Samples are available from the Oculus Unreal GitHub repository. To access this repository, you must be subscribed to the private EpicGames/UnrealEngine repository (see https://www.unrealengine.com/ue4-on-github for details). An Unreal license is not required.
Once you have access the repository, all samples are in the
All samples require a compatible version of the Unreal Engine which supports the illustrated features. To explore samples, we generally recommend using Unreal versions that we ship from the Oculus GitHub repository, because it includes the latest features. For details about the features added in each release, see Unreal Engine.
This topic contains the following sample descriptions:
The AndroidPermissions sample shows how to request the necessary Android permissions required for an Oculus app such as Internet, external storage and microphone permissions. Press the buttons in the UI while the app is running to trigger permissions requests.The following image shows blueprint that requests microphone permissions:
README.md in the sample folder and the UE4 Code Samples: The Essential (blog post) for more details.
The Avatar sample shows how use a player and a third-person local avatar.
The BoundarySample sample app:
This sample app only works with 6DOF (six degrees of freedom) headsets such as Oculus Rift and Oculus Quest. For more a detailed description of this sample, see Boundary Sample.
This sample shows how to use the:
Check out the
DLCWidget class for the DLC implementation, and the
UCloudSaveWidget for the cloud storage implementation. The ReadMe contains full description of the sample.
Note: To exercise this sample, you must have Quest Publishing Access.
README.md in the sample directory and the UE4 Code Samples: The Essential (blog post) for more details
The Oculus GitHub repo contains two samples that illustrate the Oculus hand tracking feature in Unreal Engine. For these samples to compile and run, you must have the 4.25/v17 release or later version of the Oculus Integration, as this version includes the hand tracking feature.
Find the Hand Sample sample under
Samples/Oculus/HandSample in the GitHub repo. Open the HandTrackingSample or HandTrackingCustomSample maps to see how hand tracking is implemented.
Another hand tracking sample demonstrates hand tracking while interacting with a virtual model train. Find this sample under
Samples/Oculus/HandsTrainSample in the GitHub repo. For more information about this sample, see Train Hand Tracking Sample.
The Touch sample illustrates tracking, thumbstick control, and haptics control using the
PlayHapticSoundWave() functions. When the sample is running, two spheres track with the Touch controllers. The right controller thumbstick may be used to control the position of the light gray box. Touch capacitance sensors detect whether the right thumb is in a touch or near-touch position, which controls the height of the box. Press and hold the left Touch grip button to play a haptics clip. Press and hold the left Touch X button to create a haptics effect by setting the haptics value directly. The following image shows an example:
You will find the Haptics control Blueprint and the Thumbstick control Blueprint in the Touch sample Level Blueprint. NewGameMode and VRCharacter are used to initialize the scene and make the scene display at the appropriate height, and so forth.
This sample includes two spheres that track with the Touch controllers and two UMG widgets rendered as VR Compositor layers. One is rendered as a quad layer and the other as a cylinder layer.
Actor_Blueprint illustrates rendering a UMG widget into a stereo layer. The widget is first rendered into a Material, then the SlateUI texture is pulled from the Material into the stereo layer. This is the UMG widget that is rendered to the quad and cylindrical layers in the sample.
MenuBlueprint to open the UMG widget in the UMG Editor.
VRCharacter are used to initialize the scene and make the scene display at the appropriate height.
The locomotion and interactions sample showcases a handful of common modes for moving the player around. Also included are some interactable objects, focusing on two-handed manipulation, which can be tricky to get right.
This sample demonstrates six different types of locomotion. The following lists the types of locomotion and how to use use them when the sample is running.
README.md in the sample directory and the UE4 Code Samples: The Essential (blog post) for more details.
A trivial sample map with mixed reality capture enabled is available in MixedRealitySample. Select the
OculusMR_CastingCameraActor1 instance to see how the actor is configured for the Level.
For more information, see Mixed Reality Capture.
The following image shows this sample when it is running.
This RenderingTechniques sample app contains several different maps that demonstrate shadow, portal and text rendering techniques. A summary of each map follows, but also see the
README.md in the sample directory for more details on each map and how to use it.
This map demonstrates dynamic shadows using the cascaded shadow map feature in Unreal Engine
When the sample is running, use the triggers on the touch controller to drag the sliders in the map. The light’s rotation is controlled by a Blueprint script attached to the light. See the the UE4 Code Samples: The Essential (blog post) for more details.
The ColorGradeMap demonstrates how to use look-up tables (LUTs) to adjust the look of your scene.
The color grading map requires that you have the Unreal source code and that you apply the patch in the
ColorGradingLUTPatch directory under the sample folder. When you have applied the patch, you can apply color grading LUTs. To learn more about LUTs for color grading, see Using Lookup Tables (LUTs) for Color Grading in the Unreal documentation.
Distance Field shadows are an Unreal Engine feature for precomputed shadows for stationary objects that are more distant.
For precomputed distance field shadows to work, the light type must be set to stationary and you must enable Support Pre-baked Distance Field Shadows in the Mobile Shader Permutation Reduction section of the Engine > Rendering section of the project settings. The following image shows this setting:
The PortalsMap demonstrates two different ways of rendering portals in VR.
The first uses a static parallax-corrected cubemap captured at the location of the portal being looked through. This can be prebaked and is relatively inexpensive performance-wise, but can have issues such as warping when viewed.
The second method uses stereo render targets to render the scene from the perspective of each eye and what it would see through the portal. The effect is very convincing, but at a higher performance cost. The functionality in this sample is split between the PortalCaptureActorBP blueprint, the MF_ScreenAlignedUV_VR material function, and the PortalSampleMaterial material. There are also some helper C++ methods contained in the
The TextRenderingMap demonstrates the effects of different texture filtering settings in combination with high-contrast textures like text, and also shows how VR stereo layers can be used to render high-quality text or textures.