App SpaceWarp sample
Updated: May 11, 2026
This sample demonstrates Application SpaceWarp (ASW) artifacts and mitigation techniques across six interactive scenes. You learn to identify common artifacts, implement custom motion vector passes in shaders, and stabilize UI elements using compositor layers. Note that ASW does not fully support transparent objects, which require explicit motion vector handling to reduce artifacts.
- Identify common ASW artifacts such as disocclusion shimmer, texture distortion, and silhouette issues
- Implement motion vector passes in custom shaders using two approaches: simple include directives and custom motion vector calculations
- Toggle ASW on and off at runtime via
OVRManager.SetSpaceWarp() and query its status - Mitigate ASW artifacts on Unity UI using the poke-a-hole compositor layer technique
- Why transparent objects require motion vector implementations under ASW
- Meta Quest device
- Unity 6 with Universal Render Pipeline
For detailed SDK versions, build prerequisites, and toolchain setup, see the sample README.
Clone the repository from https://github.com/oculus-samples/Unity-AppSpaceWarp and open the project in Unity 6. Build and deploy to your Meta Quest device. Press the menu button on your controller to open the settings panel, where you can toggle ASW on and off, switch scenes, and show batons for manual interaction testing. For complete build instructions, see the sample README.
| File / Scene | What it demonstrates | Focus areas |
|---|
OpaqueObjects | ASW artifacts on opaque objects during motion | Disocclusion shimmer, texture distortion, velocity and silhouette effects |
Railings | Artifacts on thin geometry moving along its axis | Motion vector buffer resolution limits at discontinuities |
TransparentObjects | ASW behavior with transparent materials | Transparent objects with and without motion vectors |
UI | ASW artifacts on Unity UI elements | Poke-a-hole compositor layer technique via PlaneToRectTransform.cs |
CustomShaders | Custom shader motion vector implementations | Simple include directive vs. custom motion vector calculation |
ObjectControls.cs | Material and motion control | Toggles between transparent, opaque, and motion-vector materials |
SettingsMenu.cs | Runtime ASW control | OVRManager.SetSpaceWarp(), scene selection, baton toggle
|
StatsText.cs | Real-time ASW status display | OVRManager.GetSpaceWarp(), FPS with exponential moving average
|
When you run the sample, objects move across the scene in animated patterns. With ASW enabled, you see shimmer effects at object edges and texture distortion on high-frequency surfaces. Press the menu button to toggle ASW on and off and immediately compare artifact behavior. The stats overlay shows whether ASW is active and the current frame rate. In the CustomShaders scene, toggle materials to see how objects render with and without motion vector passes.
The sample uses OVRManager.SetSpaceWarp() to enable or disable ASW programmatically:
OVRManager.SetSpaceWarp(val); // SettingsMenu.cs
See SettingsMenu.cs for the complete implementation, including OpenXR version validation.
Simple motion vector include
The simplest approach for adding motion vector support to a custom shader uses #define APPLICATION_SPACE_WARP_MOTION with the URP include directive. When the MOTIONVECTORS_ON keyword is active, the shader outputs motion vectors; when disabled, it outputs zero. See URP_MotionVectorAndDepth.shader for the full pattern.
Custom motion vector calculation
For shaders requiring custom motion vector logic (such as alpha-clipped materials), the sample demonstrates manual motion vector calculation using CalcAswNdcMotionVectorFromCsPositions(). This approach gives you control over per-fragment motion vector output and includes a workaround for a Unity bug where particle system model matrices report as identity while previous-frame matrices are relative to the emitter transform. See URP_UnlitAlphaClip_WithMotionVectors.shader for the complete implementation.
Poke-a-hole compositor layer UI technique
Unity UI elements rendered in world space can exhibit ASW artifacts. The sample uses PlaneToRectTransform.cs to generate a mesh matching the UI’s world corners, then renders that mesh to a compositor layer that bypasses ASW. This “pokes a hole” in the ASW-processed frame where the UI sits. See the UI scene for the implementation.
ShaderGraph automatic motion vectors
ShaderGraph shaders automatically receive motion vector passes when using the Oculus-VR Unity-Graphics fork. The sample includes ShaderGraph_Opaque.shadergraph to demonstrate this zero-configuration approach. No custom code or defines are required.
- Add your own custom shaders to the CustomShaders scene and test whether they produce ASW artifacts when motion vectors are missing
- Modify ObjectControls.cs to introduce different motion patterns (circular, sinusoidal) and observe how artifact behavior changes with velocity
- Create a new scene comparing multiple transparent materials with varying alpha values to explore the limits of ASW’s transparent object support