VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity:...

58
Frontiers of VR II VR engines & Unity, latency, and eye tracking Gordon Wetzstein Stanford University EE 267 Virtual Reality Lecture 14 stanford.edu /class/ee267/

Transcript of VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity:...

Page 1: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Frontiers of VR IIVR engines & Unity, latency, and eye tracking

Gordon WetzsteinStanford University

EE 267 Virtual Reality

Lecture 14stanford.edu/class/ee267/

Page 2: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engine (so far)

Graphics

IO

Page 3: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engine

Graphics

Audio

Physics

IO

UI

Networking

Content Creation & Editing

Scripting

Animation

Model Loader

Page 4: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Audio

• middleware – between audio card and application (e.g. game)

• usually provides functionality for:

• loading different types of sound files• mixing and mastering

• 3D sound• occlusions, echoes, reverberation, …

Page 5: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Audio

• examples: • FMOD - www.fmod.org• OpenAL - “OpenGL for sound”

• SDL – provides basic functionality• …

Page 6: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – 3D Audio• start with mono sound • head-related impulse response

(HRIR) model time delay and attenuation via convolution

• basically different temporal shift for each ear

• but HRIR also includes other effects created by shape of ear and other factors

xA t( )

!hL t( )

!hR t( )

wik

iped

ia

Page 7: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – 3D Audio• sound, 3D sound, coupling sound and physics, accurate HRIR

or head-related transfer function gets much more complicated

• Prof. Doug James in CS is working on physics & sound, check out his recent SCIEN talk if you’re interested: “Physics-based Animation Sound: Progress and Challenges”

https://talks.stanford.edu/doug-james-physics-based-animation-sound-progress-and-challenges/

Page 8: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Physics

• framework to simulate:• rigid body dynamics (e.g. collision detection)• soft body dynamics (e.g. deformation, cloth, …)

• fluid dynamics (water, smoke, fire, …)

Page 9: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Physics

• examples:• Open Dynamics Engine (http://www.ode.org/): free J

but limited to rigid body dynamics & collision• Bullet Physics (http://bulletphysics.org/): free J, rigid &

soft body dynamics, widely used • havok (owned by Microsoft) – not free L but widely

used, real-time rigid body dynamics

Page 10: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Physicsrendered in blender, bullet physics - https://www.youtube.com/watch?v=-6Sl5CCxp3Q

Page 11: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – User Interface (UI)

Page 12: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – User Interface (UI)

• concept is straightforward: widgets, menus, buttons, checkboxes, …

• types of UIs:• non-diegetic – lives in screen space (e.g. player

status); doesn’t work in VR (no screen space)

• spatial UI – lives in the virtual world

• diegetic – menus in world

imag

es fr

om u

nity

Page 13: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - IO

• support for interfaces: keyboard, mouse, 3D mouse, standard haptic devices, …

• VR engine would provide functionality as well (e.g. Unity)

Page 14: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – Content Creation

• 3D modeling programs / Computer-aided Design (CAD):• Maya (production)• 3ds Max (games)

• Blender – free• SolidWorks – 3D printing & fabrication

• Tinkercad: free & online https://www.tinkercad.com/

Page 15: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines – Content Creation

• what’s involved?• conceptual design• 3D modeling

• animation and/or simulation• scripting behavior and artificial intelligence of

characters• testing

• … many different stages in application development …

Page 16: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Scripting

• core engine is usually designed for performance – C++• developing applications should be easy! the user almost never

wants to touch the C++ source but needs flexibilty• provide a script-based interface to allow user to change

anything they need for their application• create & manipulate objects• script behavior

• change shaders (e.g. change camera or fragment shader art)

Page 17: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

VR Engines - Networking

• manage low-level communication protocols (TCP/IP, UDP, …)• ensure that character states, graphics, sound, and everything

else is synchronized• connect to application that’s running as client• network updates, messages, …

Page 18: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Popular VR/Game Engines

• Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS & Android support, also came console APIs; personal license is free; seems to be the easiest to use so we’ll use it for Lab 6 and HW 6

• Unreal: very popular, lots of awards, unreal engine 4 is free

• CryEngine: popular game engine, just announced support for VR; free for non-commercial use

Page 19: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Additional Information• Unity game engine: https://unity3d.com/• Unity tutorials: https://unity3d.com/learn/tutorials

Page 20: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Other Aspects of VR Latency, Post-rendering Warp, Eye Tracking

Page 21: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Latency

• min acceptable: 20 ms• interactive applications <20 ms

(say target is 5 ms)

The latency between thephysical movement of auser’s head and updatedphotons from a headmounted display reachingtheir eyes is one of themost critical factors inproviding a high qualityexperience.

- John Carmack

Page 22: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Latency – where does it come from?

• IMU ~1 ms• sensor fusion, data transfer• rendering: depends on complexity of scene & GPU – a few ms

• data transfer again• display: LCD ~60 Hz = 16 ms; OLED <1 ms

Page 23: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Latency – how bad is it really?

• example: • 16 ms (display) + 16 ms (rendering) + 4 ms (orientation

tracking) = 36 ms latency total• head rotates at 60 degrees / sec (relatively slow)• 1Kx1K display over 100 degrees field of view

• in 36 ms, my head moved 1.92 deg ~ 19 pixels = size of thumb at arm’s length! too much

Page 24: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Display Pixel Updates

Raster Scan(e.g. electron beam in CRT)

Rolling Update(most LCDs)

Global Update(some LCoS, DLP, other)

Page 25: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Display Pixel Switching - Persistence

Full Persistence(most LCDs)

Half Persistence(strobe backlight)

Low Persistence(OLED, strobing )

time

inte

nsity

16 ms

time

inte

nsity

16 ms

time

inte

nsity

16 ms

• after the display pixel switched states, how long is it on?

example: switch from white to black to white to black as fast as possible

Page 26: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

20 degree rotation

Rapid relative motion

headmounted

display

headmounted

display

slides from Michael Abrash 2013

Page 27: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Space-time diagrams (static)x

time

slides from Michael Abrash 2013

Page 28: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Spatial movement over time

How photons end up on the retina

x

time

slides from Michael Abrash 2013

Page 29: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

slides from Michael Abrash 2013

Page 30: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Spatial movement over time

How photons end up on the retina

x

time

slides from Michael Abrash 2013

Page 31: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Pixel-based movementx

time

one frame

slides from Michael Abrash 2013

Page 32: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

slides from Michael Abrash 2013

Page 33: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Sequential RGB displayx

time

one frame

slides from Michael Abrash 2013

Page 34: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Time

slides from Michael Abrash 2013

Page 35: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Sequential RGB with eyes moving

How photons end up on the retina

x

time

one frame

slides from Michael Abrash 2013

Page 36: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Time

slides from Michael Abrash 2013

Page 37: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Full persistencex

time

one frame

slides from Michael Abrash 2013

Page 38: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Half persistencex

time

one frame

slides from Michael Abrash 2013

Page 39: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Zero persistence

How photons end up on the retina

x

time

one frame

slides from Michael Abrash 2013

Page 40: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Full persistence + head rotationx

time

one frame

slides from Michael Abrash 2013

Page 41: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console
Page 42: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Post-rendering Image Warp• also called time-warp by John Carmack• minimize end-to-end latency• original paper from Mark et al. 1997, also Darsa et al. 1997

• overview:1. get orientation from IMU, perhaps also position

2. render scene into off-screen buffer (larger than screen)3. read latest orientation from IMU 4. warp rendered image with latest orientation

• 2D image translation v 2D image warp v 3D image warp

Page 43: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

End-to-End Low-Latency Optical See-Through AR Pipeline

Tracker30,000 Hz

3D rotation + 3D translation

slides from Zheng et al. 2014

Page 44: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

End-to-End Low-Latency Optical See-Through AR Pipeline

Tracker30,000 Hz

Renderer30 Hz

Color + Depth

(> Disp. Res.)

3D rotation + 3D translation

Render resolution Display resolution

slides from Zheng et al. 2014

Page 45: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

End-to-End Low-Latency Optical See-Through AR Pipeline

Tracker30,000 Hz

Renderer30 Hz

Post-Rendering 3D Warp300 Hz

Color + Depth

(> Disp. Res.)Color

(> Disp. Res.)

3D rotation + 3D translation

3D rotation + 3D translation

Render resolution Display resolution

slides from Zheng et al. 2014

Page 46: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

End-to-End Low-Latency Optical See-Through AR Pipeline

Tracker30,000 Hz

Renderer30 Hz

Post-Rendering 3D Warp300 Hz

2D Warp3,000 Hz

Color + Depth

(> Disp. Res.)Color

(> Disp. Res.)

3D rotation + 3D translation

3D rotation + 3D translation

2D rotation + 2D translation

Render resolution Display resolution

Color

(> Disp. Res.)

slides from Zheng et al. 2014

Page 47: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

End-to-End Low-Latency Optical See-Through AR Pipeline

Tracker30,000 Hz

Renderer30 Hz

Post-Rendering 3D Warp300 Hz

2D Warp3,000 Hz

Color + Depth

(> Disp. Res.)Color

(> Disp. Res.)

3D rotation + 3D translation

3D rotation + 3D translation

2D rotation + 2D translation

2D Offset30,000 Hz

2D translation

Render resolution Display resolution

Color

(> Disp. Res.)

A cascade of successively simpler and faster renderers

running in GPU

slides from Zheng et al. 2014

Page 48: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Summary: Latency, Persistence, etc.

• predictive tracking (e.g. LaValle ICRA 2014) • post-rendering warp• design and build really great hardware & algorithms

• use OLED displays or strobing backlights for low persistence• design some type of a device to actually measure latency!

Page 49: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking

www.huffingtonpost.com

Page 50: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking

• necessary for gaze-contingency paradigm (foveatedrendering, gaze-contingent rendering, gaze-contingent focus, …)

• interaction

• eye contact• …

Page 51: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking

• many different techniques:• electro-oculography• contact lens tracking

• video-oculography• pupil / corneal reflection tracking

• dual Purkinje image

Page 52: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking• some interesting properties one can exploit:

• pupillary light reflex doesn’t work in near infrared (IR)• red-eye effect with co-axial camera - light source

• purkinje images for off-axis illumination

co-axial IR illumination off-axis IR illumination purkinje image

wikipedia

Page 53: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking – Pupil / Corneal Reflection

Page 54: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking – Pupil / Corneal Reflection • corneal reflection stays constant, pupil center moves relative!

Page 55: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking – Pupil / Corneal Reflection • corneal reflection stays constant, pupil center moves relative!

Page 56: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking – Dual Purkinje• track relative location of Purkinje images

http://ppw.kuleuven.be/home/english/research/lep/resources/purkinje

Page 57: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

Eye Tracking• where am I looking? what am I looking at?

http://www.getbusymedia.com/small-business-insights-eye-tracking/

Page 58: VR engines & Unity, latency, and eye tracking Gordon ...Popular VR/Game Engines •Unity: cross-platform, Direct3D (Win), OpenGL (Mac & Linux), iOS& Android support, also came console

References and Further Reading• Google Project Tango: https://developers.google.com/project-tango/

• Post-rendering warp: • W. Mark, L. McMillan, G. Bishop "Post-Rendering Warping," Proc. Symposium on

Interactive 3D Graphics 1997

• L. Darsa, B. Costa, A. Varshneyz “Navigating Static Environments Using Image-Space Simplification and Morphing“, 1997

• John Carmack “Time Warp”, 2013 (blogs)• Latency:

• F. Zheng, T. Whitted, A. Lastra, P. Lincoln, A. State, A. Maimonek, H. Fuchs “Minimizing

Latency for Augmented Reality Displays: Frames Considered Harmful”, ISMAR 2014