HIVE-ResearchGroup / OpenXR_Varjo_Template

An Unity template using HDRP which uses OpenXR, the new Unity Input System with support of all Varjo features.
3 stars 0 forks source link

OpenXR_Varjo_Template

Introduction

This project focuses on combining two workflows (OpenXR and Varjo SDK) into one project and making it easy to switch between those two headset just as by ticking two checkboxes. It features:

Dependencies

Make sure to have the following programs installed before starting:

Included dependencies:

What about other render pipelines?

It is possible to use the scripts and prefabs inside this template to use some of the Varjo features also in your SRP/URP project. Note, that you will only have support for AR mode and Depth testing. Please be aware that you will have to set your own settings for lights, shaders, materials, reflections. You now need to switch the materials with the ones in the "Materials"/"BiRP" folder. Those materials are made with the Built-In renderpipeline in mind (BiRP), yet you can easily upgrade them to URP. Note that there is no replacement for the ShadowCatcher material (the one being transparent on the floor and just displaying the shadows) as this is an HDRP only feature. You also need to change the colour of the Camera Background flag inside the camera object to Color -> black.

Please don't forget to create the used layers (ARObjects [layer 6], VRObjects [layer 7]) and the used tags (Fracture, Pickable), as well to set the Opaque value inside the Varjo SDK to false. Also, note that using the Volume objects are also restricted to HDRP which is why you should delete them when switching.

Important notice: If you choose to "Update all materials to HDRP", the materials inside the BiRP folders will also update and not be able to be used with the BiRP!

Structure

There is one main file managing this transition: The deviceManager object, containing following scripts:

Useage

For more information about the usage, please have a look at the README.

Use the Unity project

If you intend not to start from scratch, download this project and use it as a starting point. The project already uses the package and the project/input settings are already set - no further configuration needed.

How to install the package

If you want to use the features in an already existing project or want to custom-build your scenes, you might want to go with just installing the package.

  1. Make sure to install the Varjo OpenXR (tutorial) and the Ultraleap (tutorial) plugins first.
  2. Import the samples of the Ultraleap plugin. (You don't need to import the Varjo Samples but can, if you want/need to, since this package uses some of the materials/models of the package.) If you use the HDRP pipeline, you might need to update the materials of the sample folders (only those materials, see "What about other pipelines").
  3. Don't forget to import the Sample folder of the Interaction Toolkit Plugin (which was installed automatically - if it doesn't show up in the Package Manager, install it by typing "com.unity.xr.interaction.toolkit") as well. With this object, you need to add all the different components to the assets and then change (with both the XRI LeftHand Interaction and XRI RightHand Interaction) "Select" (to triggerPressed), "Select Value" (to trigger).
  4. After this, go this package and download the samples you need. In order to just use the prefabs, download the "Core Prefabs" samples. If you want to get an example scene, download the "Simple Scene" sample. There are also some Asset models you might want to use.
  5. Add the layers (6: VRObjects, 7: ARObjects, 8: Raycasts) and the "Fraction", "Pickable" tag, if it doesn't exist already.
  6. Go to either RightHand or LeftHand Ray and to the Raycast object, go to "Interaction Layer Mask", tick "Add layer" and add "Raycasts" as Interaction Layer.

Note: You might want to switch the Input System to "Both" inside Project Settings -> Player -> Others, if you want to use scripts that use the old Input System.

If you want to start from scratch (with the prefabs and without the scene)

Drag and drop the following prefabs into your scene:

The other prefabs ("Controller Left" and "Controller Right") are only needed to be added inside the XR Rig -> Left/RightHand Controller -> XRController script -> Model Prefab.

Add the relations to the Prefab:

Noticeable mentions

Known Issues

Refer to the GitHub page for further information about current issues.