O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering Oculus Rift Development

Book Description

Explore the new frontier of virtual reality with the Oculus Rift and bring the VR revolution to your own projects

About This Book

  • Create immersive 3D games especially designed for the Oculus Rift platform
  • Build complex realistic virtual reality (VR) games with the Unity Engine
  • Create striking VR environments with advanced graphical techniques

Who This Book Is For

This book is for aspiring indie developers and VR enthusiasts who want to bring their ideas into virtual reality with a new platform that provides an unprecedented level of realism and immersion.

What You Will Learn

  • Increase immersion with 3D audio and intuitive interfaces
  • Create group VR experiences using multi-player networking
  • Design fun and engaging mechanics that utilize VR principles
  • Explore the best ways to navigate and interact using the Oculus Rift
  • Design intuitive ways to navigate and interact with scenes in VR
  • Add stunning realism to a scene with three-dimensional audio
  • Invent mechanics and features that take full advantage of VR hardware

In Detail

Virtual reality (VR) is changing the world of gaming and entertainment as we know it. VR headsets such as the Oculus Rift immerse players in a virtual world by tracking their head movements and simulating depth, giving them the feeling that they are actually present in the environment. We will first use the Oculus SDK in the book and will then move on to the widely popular Unity Engine, showing you how you can add that extra edge to your VR games using the power of Unity.

In this book, you'll learn how to take advantage of this new medium by designing around each of its unique features. This book will demonstrate the Unity 5 game engine, one of most widely-used engines for VR development, and will take you through a comprehensive project that covers everything necessary to create and publish a complete VR experience for the Oculus Rift. You will also be able to identify the common perils and pitfalls of VR development to ensure that your audience has the most comfortable experience possible.

By the end of the book, you will be able to create an advanced VR game for the Oculus Rift, and you'll have everything you need to bring your ideas into a new reality.

Style and approach

This book takes a step-by-step tutorial approach with illustrative examples to help you implement the projects on your own. The book lets you first get to grips with the Oculus SDK and then moves on to the Unity Engine to add realistic graphics and features in your games.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Mastering Oculus Rift Development
    1. Mastering Oculus Rift Development
    2. Credits
    3. About the Author
    4. About the Reviewer
    5. www.PacktPub.com
      1. Why subscribe?
    6. Customer Feedback
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Downloading the color images of this book 
          1. Errata
          2. Piracy
          3. Questions
    8. 1. Exploring a New Reality with the Oculus Rift
      1. The concept of VR
        1. Depth perception
      2. Common limitations of VR games
        1. Locomotion sickness
        2. Lack of real-world vision
        3. Unnatural head movements
        4. Vergence-accommodation conflict
      3. Constellation tracking
      4. Input with controllers, remotes, and more
      5. The importance of frame rate
      6. Asynchronous Timewarp
      7. Installing the Oculus runtime
      8. Summary
    9. 2. Stepping into Virtual Reality
      1. Getting started with Unity
        1. Installing the Unity3D engine
      2. Incorporating the Oculus Utilities package
      3. Taking your first steps in VR
        1. Scripting basic player movement
      4. Enabling interaction with gaze-based mechanics
        1. Implementing gaze-based teleporting
      5. Building and running your first VR app
        1. Configuring Unity Build Settings for VR
        2. Configuring Unity Quality settings for VR
      6. Summary
    10. 3. Improving Performance and Avoiding Discomfort
      1. Using the Unity profiler
        1. Analyzing CPU usage
      2. Using coroutines to split up complex work
      3. Mesh optimization
        1. Optimizing a mesh using Simplygon
      4. Displaying dynamic detail with LODs
      5. Keeping a handle on memory allocation
        1. Stack and heap memory
          1. Value types and reference types
          2. Boxing and unboxing
        2. Unity specifics
          1. foreach loops versus for loops
          2. Material references
          3. Comparing tags efficiently
      6. Object pooling
        1. Creating an object pool for strings
        2. Pooling Unity GameObjects
      7. Summary
    11. 4. Interacting with Virtual Worlds
      1. Designing basic player input
        1. Using Unity input axes
        2. Using the OVRPlayerController script
        3. Adding projectiles
          1. Implementing a firing mechanic
      2. Implementing gameplay around input
        1. Creating a target dummy
      3. Creating custom Unity input axes
      4. Summary
    12. 5. Establishing Presence
      1. Setting up the game environment
        1. Configuring lighting properties
        2. Adding some color to the scene
        3. Adding colliders to imported mesh objects
      2. Accentuating depth with particle effects
      3. Customizing the skybox
      4. Enabling player interaction with the world
        1. Creating the dynamic wall prefab
        2. Scripting our prefab
      5. Populating the game world with resources
        1. Making the practice dummies drop resources
      6. Using resources to interact with the environment
      7. Summary
    13. 6. Adding Depth and Intuition to a User Interface
      1. Adding a VR input module
      2. Constructing a simple menu
        1. Setting up a canvas
        2. Adding buttons to a canvas
        3. Adding functionality to UI elements
        4. Creating a GameManager script
      3. Adding UI elements to the game world
        1. Adding complexity to the dynamic walls
        2. Adding teams to the game
        3. Adding a health bar to the dynamic wall
      4. Summary
    14. 7. Hearing and Believing with 3D Audio
      1. The science of how we hear
        1. Lateral localization of audio
        2. Vertical localization of audio
      2. Learning the basics of Unity audio
        1. Spatial blending between 2D and 3D
      3. Implementing 2D stereo audio
        1. Playing a sound when a button is clicked on
        2. Playing a sound when a button is hovered
      4. Adding basic 3D spatialization
        1. Making an audio source 3D
      5. Immersing your player with HRTFs
        1. Sampling Unity's first-party HRTF
        2. Importing the ONSP
        3. Using the ONSP
        4. Adding sound reflections to the scene
      6. Filling the game world with sound
        1. Adding footstep sounds
        2. Adding projectile sounds
        3. Adding ambient looping to energy orbs
      7. Summary
    15. 8. Adding Tone and Realism with Graphics
      1. A simple breakdown of the rendering pipeline
        1. Defining the geometry
        2. Transforming the model into world space
        3. Transforming the world into camera space
        4. Lighting the objects in the scene
        5. Deriving a projection from the camera
        6. Clipping geometry outside the camera's frustum
        7. Rasterization and texturing
      2. Forward and deferred rendering
        1. Forward rendering
        2. Deferred rendering
        3. Demonstrating the value of deferred rendering
      3. Adding tone with color grading
        1. The basics of color grading
        2. Adding a color grading script to the camera
        3. Sampling a lookup texture
        4. Creating dramatic effects with vibrant LUTs
      4. Changing the appearance of objects with shaders
        1. A quick overview of ShaderLab shaders
        2. Importing a textured model
        3. An overview of ShaderLab's fundamental syntax
        4. Writing your first shader
          1. Defining a diffuse texture property
        5. Adding a normal map property to a shader
          1. Generating a normal map
      5. Summary
    16. 9. Bringing Players Together in VR
      1. Creating a lobby space for joining matches
        1. Setting up the lobby scene
        2. Creating the Create menu
        3. Adding event triggers to the Lobby menu
      2. Creating a networked game
      3. Defining player spawn points
        1. Assigning players to teams
      4. Using Unity's matchmaker system
        1. Creating a matchmaker game
        2. Joining a matchmaker game
      5. Tying together the multiplayer lobby
        1. Linking the menus together
      6. Synchronizing data in multiplayer matches
        1. Syncing player movement
        2. Handling object spawning on the network
        3. Detecting bullet collisions on the network
        4. Ending a match after a set time
      7. Summary
    17. 10. Publishing on the Oculus Store
      1. Packaging a final Unity build
        1. Adding a game icon
        2. Configuring final player settings
        3. Configuring final quality settings
        4. Getting to know the output log
      2. Meeting the Oculus submission guidelines
        1. Meeting the Oculus content policy
        2. Meeting the Oculus minimum technical requirements
          1. What about Asynchronous Timewarp and Spacewarp?
      3. Uploading your first build to Oculus
        1. Managing release channels
        2. Uploading submission information
        3. Other sections of the dashboard
      4. Summary