Passthrough Samples
Updated: Dec 17, 2024
Passthrough sample is available on
GitHub, and its use is explained in detail below. In addition, the following projects provide examples of passthrough used with other APIs:
- CoLocationHS: Shows how to implement colocation, where multiple users in the same room use passthrough.
- Occlusion Sample: Illustrates using the Depth API’s different options for integrating visual occlusion with passthrough.
- Scene Sample: Shows how to use the Scene API to interact with objects in the passthrough environment.
- Shared Scene Sample: Illustrates using shared anchors to share scene details with other users.
- Phanto: Shows how to use passthrough to create an entire mixed reality game.
Navigating through the samples
Open the Navigation Menu by pressing the Menu button on your left controller. Once in the Navigation Menu, you can see if your device supports passthrough, the name and description of your current level, and a list of levels you can travel to. Aim your right-hand controller at the desired level and press the right trigger to travel to it. Scroll through the list with the right thumbstick.
Passthrough background with augmented objects
A common use of passthrough is as a background, where you can place virtual objects (Passthrough AR). You can do this easily, starting from the PTBackground scene:
- Import your FBX or 3D object into your project.
- Place your object in the scene.
- Give your object a grab component and set its collision preset to PhysicsActor so it can be grabbed and moved around your room.
- Build and deploy.
Here are relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn.
BP_OculusLogo.uasset
: A standard actor with the default material.BP_Grafitti.uasset
: This is the same as BP_OculusLogo.uasset but with a custom material.
Darkening your space and lighting it in key areas is another common use of passthrough. From shining a top-down spotlight on a table game or art piece to isolating into a “focus mode” by blacking out everything except your immediate area or shining a volumetric flashlight paired with dynamic lighting, you can achieve much with passthrough even without scene understanding.
In the PTLighting level, you can find an example of using passthrough to create a focus mode. The general idea behind lighting passthrough is:
- Set passthrough as an underlay.
Darken the passthrough using Color Scale and Color Offset.
Create another passthrough layer component (UserDefined and Underlay, Texture Opacity Factor 0, no styling), it will act as the flashlight light cone.
- Using the Add Surface Geometry node, project the new layer onto the light cone.
- Use the Set Texture Opacity Node to turn the flashlight on/off.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a stylised passthrough layer to the player pawn.
BP_Flashlight.uasset
: This flashlight attaches to the right controller and has a lighted passthrough layer. Use Button A to switch it on/off.
You can draw a cone with one or multiple meshes. If you use multiple meshes, note the number of pixels drawn in every frame. Multiple overlapping, blended meshes will often result in many redrawn pixels. Pay careful attention to performance if you use large translucent meshes to simulate a volumetric look.
Using passthrough as an overlay
In the PTOpacity level, you can see an example of using passthrough as an overlay. In this sample, you use the slider widget (or the thumbstick on your right-hand controller) to adjust the opacity of the passthrough layer from 0% to 100%.
Here are relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn, sends the layer to the widget, and binds input for the right thumbstick.
- W_PTOpacity.uasset: Sets the texture opacity based on the slider value.
Using passthrough styles for colorful effects
The PTStyles level demonstrates some of the styling options available on passthrough layers. You can control the styling using the widget in the level:
- Color map Curve: Colorize passthrough using a predefined curve. The curves are defined in the
Content/Passthrough/Data/
folder and can be customized to achieve different colorizations. - Color map Controls: Use the Contrast/Brightness/Posterize sliders to apply image processing effects implemented using a color map of type “Grayscale To Color.”
- Edge Color: Use the Red/Green/Blue/Alpha sliders to adjust the color of salient edges in the image (extracted using a Sobel filter).
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn and sends the layer to the widget.
BP_Menu.uasset
: The menu actor with the menu widget.- W_PTStyler.uasset: The widget directly modifying the style of the passthrough.
Instead of specifying color effects via parameters (as demonstrated in the PTStyles level), you can define them as an array of 256 values that map each (grayscale) input value to a new color. The PTColorMap level provides an example of setting colors this way. With the in-game widget, you can modify the 256 color values and see the impact on the styling.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn and sends the layer to the widget.
W_PTColorMap.uasset
: The widget for viewing the color map array and editing each of its 256 values.
Color look-up tables (LUTs)
You can colorize passthrough using color LUTs. As demonstrated in the PTColorLut level, you can use two LUT types: Color LUT and Interpolated Color LUT. The second one will blend two LUTs (source and target) using the LUTWeight value.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn and sends the layer to the widget.
W_PTColorLUT.uasset
: The widget for viewing and editing LUTs.
Another way to colorize passthrough layers is to use color scale and offset. The PTColorScaleAndOffset level demonstrates this method and animates both of those settings. You can use the in-game widget to stop and edit the color scale and offset.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn, sends the layer to the widget, and animates the color scale and offset.
W_PTColorScaleAndOffset.uasset
: The widget for viewing and editing the color scale and offset.
Caution:
The lighting and color in this sample may cause seizures in people with epilepsy or sensitivity to light and color.
Passthrough layer placement The PTLayer_Placement level shows how the placement of passthrough layers can affect your scene. To change the order of passthrough layers, use the right trigger to switch the layer between the overlay and underlay or use the left trigger to toggle depth support.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn, binds inputs, and modifies layer placement.
The PTMaskedBrush and PTMasking levels demonstrate experiences where a passthrough layer is masked and only visible in certain screen areas. In the PTMaskedBrush sample, the controller can be used as a brush to draw a projected passthrough stroke by pressing the left and right triggers. PTMasking showcases a circle mesh with masked projected passthrough (using the mPokeAHoleMask material) that is attached to the controller, which allows you to see your hands (you can change the attached controller with the left/right trigger).
You can re-use and modify the mPokeAHoleMask.uasset
material to mask areas in your scene.
Here are the relevant assets in this scene that you can use and modify to fit your needs:
- Level Blueprint: Creates and adds a passthrough layer to the player pawn, binds inputs, and projects the passthrough to the circle.
- MaskedCircle: Actor on which you project the passthrough, using the
mPokeAHoleMask
material to smooth its border.
Surface-projected passthrough In the PTSurfaceProjected level, you can see an example of passthrough projected onto a mesh surface. Instead of mapping passthrough to a mesh reconstructed from stereo imagery, this takes an input static mesh and uses the vertex positions to calculate exact stereo mapping. Use this in cases where you have high confidence in real items matching virtual items, such as flat surfaces. For example, the demo scene looks like a TV setup with a view of the real world. Depth accuracy is better with surface-projected passthrough, especially at longer distances where a reconstructed passthrough mesh is less reliable.
This feature is also working for procedural meshes as demonstrated in the PTProceduralMesh level.
Note: The passthrough will not follow mesh modification after it has been added as a Surface Geometry, if you have modified your procedural mesh and want the passthrough to follow you’ll need to remove and add again your mesh.
In the PTSurfaceProjected level, you can see an example of a passthrough projected onto a mesh surface. Instead of mapping passthrough to a mesh reconstructed from stereo imagery, this takes an input static mesh and uses the vertex positions to calculate exact stereo mapping. Use this in cases where you have high confidence in actual items matching virtual items, such as flat surfaces. For example, the demo scene looks like a TV set up with a view of the real world. Depth accuracy is better with surface-projected passthrough, especially at longer distances where a reconstructed passthrough mesh is less reliable.
This feature also works for procedural meshes, as the PTProceduralMesh level demonstrates.
Note: The passthrough will not follow mesh modification after you add it as a Surface Geometry. If you have modified your procedural mesh and want the passthrough to follow, you must remove and add your mesh again.