Mastering Oculus Rift Development
By Jack Donovan
()
About this ebook
- 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
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.
Read more from Jack Donovan
OUYA Game Development by Example Rating: 0 out of 5 stars0 ratingsSystemC: From the Ground Up, Second Edition Rating: 0 out of 5 stars0 ratings
Related to Mastering Oculus Rift Development
Related ebooks
Augmented Reality Game Development Rating: 0 out of 5 stars0 ratingsUnreal Engine 4 Virtual Reality Projects: Build immersive, real-world VR applications using UE4, C++, and Unreal Blueprints Rating: 0 out of 5 stars0 ratingsUnity Virtual Reality Projects Rating: 0 out of 5 stars0 ratingsA Beginner's Guide to 2D Shooter Games: Beginners' Guides, #2 Rating: 0 out of 5 stars0 ratingsGetting Started with Unity 5.x 2D Game Development Rating: 0 out of 5 stars0 ratingsOuya Unity Game Development Rating: 0 out of 5 stars0 ratingsMobile Game Design Essentials Rating: 0 out of 5 stars0 ratingsBlueprints Visual Scripting for Unreal Engine Rating: 0 out of 5 stars0 ratingsUnreal Engine 4 AI Programming Essentials Rating: 0 out of 5 stars0 ratingsExtending Unity with Editor Scripting Rating: 0 out of 5 stars0 ratingsBuilding Levels in Unity Rating: 0 out of 5 stars0 ratingsUnity Game Development Blueprints Rating: 0 out of 5 stars0 ratings3D Game Design with Unreal Engine 4 and Blender Rating: 0 out of 5 stars0 ratingsA Beginner's Guide to 2D Platform Games with Unity: Beginners' Guides, #1 Rating: 0 out of 5 stars0 ratingsMastering Unity 5.x Rating: 0 out of 5 stars0 ratingsUnity Game Development Scripting Rating: 0 out of 5 stars0 ratingsUnity Animation Essentials Rating: 0 out of 5 stars0 ratingsLearning Unreal® Engine iOS Game Development Rating: 0 out of 5 stars0 ratingsUnreal Engine Physics Essentials Rating: 1 out of 5 stars1/5Unity 5.x By Example Rating: 0 out of 5 stars0 ratingsGetting Started with Unity 5 Rating: 5 out of 5 stars5/5Unreal Engine Game Development Cookbook Rating: 0 out of 5 stars0 ratingsMastering Unity 2D Game Development - Second Edition Rating: 0 out of 5 stars0 ratingsGame Development with Unreal Engine 5: Learn the Basics of Game Development in Unreal Engine 5 (English Edition) Rating: 0 out of 5 stars0 ratingsUnity from Proficiency to Mastery (Artificial Intelligence): Unity from Proficiency to Mastery, #1 Rating: 0 out of 5 stars0 ratingsGame Development with Three.js Rating: 0 out of 5 stars0 ratingsUnreal Engine 4 Game Development Essentials Rating: 4 out of 5 stars4/5Unity from Zero to Proficiency (Beginner): Unity from Zero to Proficiency, #2 Rating: 5 out of 5 stars5/5Learning Unity iOS Game Development Rating: 0 out of 5 stars0 ratingsUnreal Engine from Zero to Proficiency (Foundations): Unreal Engine from Zero to Proficiency, #1 Rating: 0 out of 5 stars0 ratings
Internet & Web For You
Social Engineering: The Science of Human Hacking Rating: 3 out of 5 stars3/5How to Be Invisible: Protect Your Home, Your Children, Your Assets, and Your Life Rating: 4 out of 5 stars4/5How to Disappear and Live Off the Grid: A CIA Insider's Guide Rating: 0 out of 5 stars0 ratingsNo Place to Hide: Edward Snowden, the NSA, and the U.S. Surveillance State Rating: 4 out of 5 stars4/5Coding For Dummies Rating: 5 out of 5 stars5/5Coding All-in-One For Dummies Rating: 4 out of 5 stars4/5Get Rich or Lie Trying: Ambition and Deceit in the New Influencer Economy Rating: 0 out of 5 stars0 ratingsSix Figure Blogging Blueprint Rating: 5 out of 5 stars5/5Beginner's Guide To Starting An Etsy Print-On-Demand Shop Rating: 0 out of 5 stars0 ratingsEverybody Lies: Big Data, New Data, and What the Internet Can Tell Us About Who We Really Are Rating: 4 out of 5 stars4/5The Hacker Crackdown: Law and Disorder on the Electronic Frontier Rating: 4 out of 5 stars4/5Podcasting For Dummies Rating: 4 out of 5 stars4/5The Beginner's Affiliate Marketing Blueprint Rating: 4 out of 5 stars4/5The Gothic Novel Collection Rating: 5 out of 5 stars5/5The Logo Brainstorm Book: A Comprehensive Guide for Exploring Design Directions Rating: 4 out of 5 stars4/5Grokking Algorithms: An illustrated guide for programmers and other curious people Rating: 4 out of 5 stars4/5Remote/WebCam Notarization : Basic Understanding Rating: 3 out of 5 stars3/5Hacking : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Ethical Hacking Rating: 5 out of 5 stars5/5How To Start A Podcast Rating: 4 out of 5 stars4/5200+ Ways to Protect Your Privacy: Simple Ways to Prevent Hacks and Protect Your Privacy--On and Offline Rating: 0 out of 5 stars0 ratingsThe Internet Is Not What You Think It Is: A History, a Philosophy, a Warning Rating: 4 out of 5 stars4/5The Digital Marketing Handbook: A Step-By-Step Guide to Creating Websites That Sell Rating: 5 out of 5 stars5/5More Porn - Faster!: 50 Tips & Tools for Faster and More Efficient Porn Browsing Rating: 3 out of 5 stars3/5The Cyber Attack Survival Manual: Tools for Surviving Everything from Identity Theft to the Digital Apocalypse Rating: 0 out of 5 stars0 ratingsThe $1,000,000 Web Designer Guide: A Practical Guide for Wealth and Freedom as an Online Freelancer Rating: 5 out of 5 stars5/5Introduction to Internet Scams and Fraud: Credit Card Theft, Work-At-Home Scams and Lottery Scams Rating: 4 out of 5 stars4/5
Reviews for Mastering Oculus Rift Development
0 ratings0 reviews
Book preview
Mastering Oculus Rift Development - Jack Donovan
Table of Contents
Mastering Oculus Rift Development
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Exploring a New Reality with the Oculus Rift
The concept of VR
Depth perception
Common limitations of VR games
Locomotion sickness
Lack of real-world vision
Unnatural head movements
Vergence-accommodation conflict
Constellation tracking
Input with controllers, remotes, and more
The importance of frame rate
Asynchronous Timewarp
Installing the Oculus runtime
Summary
2. Stepping into Virtual Reality
Getting started with Unity
Installing the Unity3D engine
Incorporating the Oculus Utilities package
Taking your first steps in VR
Scripting basic player movement
Enabling interaction with gaze-based mechanics
Implementing gaze-based teleporting
Building and running your first VR app
Configuring Unity Build Settings for VR
Configuring Unity Quality settings for VR
Summary
3. Improving Performance and Avoiding Discomfort
Using the Unity profiler
Analyzing CPU usage
Using coroutines to split up complex work
Mesh optimization
Optimizing a mesh using Simplygon
Displaying dynamic detail with LODs
Keeping a handle on memory allocation
Stack and heap memory
Value types and reference types
Boxing and unboxing
Unity specifics
foreach loops versus for loops
Material references
Comparing tags efficiently
Object pooling
Creating an object pool for strings
Pooling Unity GameObjects
Summary
4. Interacting with Virtual Worlds
Designing basic player input
Using Unity input axes
Using the OVRPlayerController script
Adding projectiles
Implementing a firing mechanic
Implementing gameplay around input
Creating a target dummy
Creating custom Unity input axes
Summary
5. Establishing Presence
Setting up the game environment
Configuring lighting properties
Adding some color to the scene
Adding colliders to imported mesh objects
Accentuating depth with particle effects
Customizing the skybox
Enabling player interaction with the world
Creating the dynamic wall prefab
Scripting our prefab
Populating the game world with resources
Making the practice dummies drop resources
Using resources to interact with the environment
Summary
6. Adding Depth and Intuition to a User Interface
Adding a VR input module
Constructing a simple menu
Setting up a canvas
Adding buttons to a canvas
Adding functionality to UI elements
Creating a GameManager script
Adding UI elements to the game world
Adding complexity to the dynamic walls
Adding teams to the game
Adding a health bar to the dynamic wall
Summary
7. Hearing and Believing with 3D Audio
The science of how we hear
Lateral localization of audio
Vertical localization of audio
Learning the basics of Unity audio
Spatial blending between 2D and 3D
Implementing 2D stereo audio
Playing a sound when a button is clicked on
Playing a sound when a button is hovered
Adding basic 3D spatialization
Making an audio source 3D
Immersing your player with HRTFs
Sampling Unity's first-party HRTF
Importing the ONSP
Using the ONSP
Adding sound reflections to the scene
Filling the game world with sound
Adding footstep sounds
Adding projectile sounds
Adding ambient looping to energy orbs
Summary
8. Adding Tone and Realism with Graphics
A simple breakdown of the rendering pipeline
Defining the geometry
Transforming the model into world space
Transforming the world into camera space
Lighting the objects in the scene
Deriving a projection from the camera
Clipping geometry outside the camera's frustum
Rasterization and texturing
Forward and deferred rendering
Forward rendering
Deferred rendering
Demonstrating the value of deferred rendering
Adding tone with color grading
The basics of color grading
Adding a color grading script to the camera
Sampling a lookup texture
Creating dramatic effects with vibrant LUTs
Changing the appearance of objects with shaders
A quick overview of ShaderLab shaders
Importing a textured model
An overview of ShaderLab's fundamental syntax
Writing your first shader
Defining a diffuse texture property
Adding a normal map property to a shader
Generating a normal map
Summary
9. Bringing Players Together in VR
Creating a lobby space for joining matches
Setting up the lobby scene
Creating the Create menu
Adding event triggers to the Lobby menu
Creating a networked game
Defining player spawn points
Assigning players to teams
Using Unity's matchmaker system
Creating a matchmaker game
Joining a matchmaker game
Tying together the multiplayer lobby
Linking the menus together
Synchronizing data in multiplayer matches
Syncing player movement
Handling object spawning on the network
Detecting bullet collisions on the network
Ending a match after a set time
Summary
10. Publishing on the Oculus Store
Packaging a final Unity build
Adding a game icon
Configuring final player settings
Configuring final quality settings
Getting to know the output log
Meeting the Oculus submission guidelines
Meeting the Oculus content policy
Meeting the Oculus minimum technical requirements
What about Asynchronous Timewarp and Spacewarp?
Uploading your first build to Oculus
Managing release channels
Uploading submission information
Other sections of the dashboard
Summary
Mastering Oculus Rift Development
Mastering Oculus Rift Development
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: February 2017
Production reference: 1310117
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78646-115-5
www.packtpub.com
Credits
About the Author
Jack Donovan is a 24-year-old software engineer living in Brooklyn, New York. He graduated from Champlain College in Burlington, Vermont with a BS in game programming and soon after joined IrisVR, a startup founded in Burlington to create one-click software for architects to visualize models in virtual reality. IrisVR moved to New York City after being accepted into the startup incubator program Techstars and has since moved to an independent office in NoHo, where Jack continues to work.
Jack also wrote OUYA Game Development By Example, a book focused on the basics of developing games for the Android-powered OUYA console. Both books use the Unity3D engine for development, which Jack has been using to develop games and software in since 2010.
Thanks to Matt Gooding for being an invaluable friend and mentor, and Ezra Smith for his dedication and guidance in helping me put the finishing touches on this book. I’d also like to thank my parents, Paul Donovan and Jody Petersen, who have always supported me and inspired me to work hard on what I love. Lastly, I’d like to thank all of the brilliant people that I’ve been fortunate to work and grow with at IrisVR, especially the founders Shane Scranton and Nate Beatty for working tirelessly to make it all possible.
About the Reviewer
Ezra Smith is a software developer at IrisVR and one of the co-founders of FridgeCat Software. He's been writing mobile apps with Unity since 2011, and started experimenting with virtual reality in 2013. Ezra has been dreaming about playing video games in VR since he was a child, and is very excited to see those dreams becoming a reality.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt books and video courses, as well as industry-leading tools to help you plan your personal development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thank you for purchasing this Packt book. We take our commitment to improving our content and products to meet your needs seriously—that's why your feedback is so valuable. Whatever your feelings about your purchase, please consider leaving a review on this book's Amazon page. Not only will this help us, more importantly it will also help others in the community to make an informed decision about the resources that they invest in to learn.
You can also review for us on a regular basis by joining our reviewers' club. If you're interested in joining, or would like to learn more about the benefits we offer, please contact us: customerreviews@packtpub.com.
Preface
Welcome to Mastering Oculus Rift Development! With this book, you'll learn the fundamentals of creating complete virtual reality experiences for the Oculus Rift VR headset using the Unity3D game engine. Each chapter will guide new and experienced developers alike in building and expanding a project with basic gameplay, spatialized audio, and networked matchmaking. It also covers in-depth optimization and the process of publishing your game, ensuring you have everything you need to release a polished experience.
What this book covers
Chapter 1, Exploring a New Reality with the Oculus Rift, briefly outlines the basics of virtual reality and guides the user through getting set up with their Rift.
Chapter 2, Stepping into Virtual Reality, introduces the reader to the Unity3D game engine and implementing simple navigation in a new VR project.
Chapter 3, Improving Performance and Avoiding Discomfort, explains the importance of avoiding VR sickness by ensuring the game is optimized and always running smoothly.
Chapter 4, Interacting with Virtual Worlds, covers how to handle interaction and different input devices in Unity, including the controller and remote that ship with the Oculus Rift.
Chapter 5, Establishing Presence, teaches the reader about several factors that make VR experiences immersive and interesting, including 3D environments, particle effects, and interactive objects.
Chapter 6, Adding Depth and Intuition to a User Interface, guides the reader through setting up a user interface (UI) in VR and explains what makes it different from conventional game UIs.
Chapter 7, Hearing and Believing with 3D Audio, introduces the reader to the concept of spatialized audio and its importance in establishing presence and scale in any VR world.
Chapter 8, Adding Tone and Realism with Graphics, provides a detailed overview of rendering the pipelines and shaders that help establish both realism and artistic flair.
Chapter 9, Bringing Players Together in VR, teaches the reader how to create networked games and interact with other players in VR over the Web.
Chapter 10, Publishing on the Oculus Store, outlines all of the steps involved in packaging a VR game and publishing it on the Oculus Store for the world to download and play.
What you need for this book
The following software is recommended for use with this book:
Unity 5.4.0
CrazyBump 1.22
We will also need the following hardware:
Oculus Rift CV1
Xbox controller and Oculus remote (included with Rift)
Make sure you also have the following:
Internet connection
Windows 7+
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.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: Create a folder called Scripts to put your game's code in.
A block of code is set as follows:
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
Teleport();
}
}
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Expand the Horizontal tab to view its preset configuration.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of. To send us general feedback, simply e-mail feedback@packtpub.com, and mention the book's title in the subject of your message. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
Downloading the example code
You can download the example code files for this book 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 files e-mailed directly to you.
You can download the code files by following these steps:
Log in or register to our website using your e-mail address and password.
Hover the mouse pointer on the SUPPORT tab at the top.
Click on Code Downloads & Errata.
Enter the name of the book in the Search box.
Select the book for which you're looking to download the code files.
Choose from the drop-down menu where you purchased this book from.
Click on Code Download.
Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:
WinRAR / 7-Zip for Windows
Zipeg / iZip / UnRarX for Mac
7-Zip / PeaZip for Linux
The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Mastering-Oculus-Rift-Development. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!
Downloading the color images of this book
We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/MasteringOculusRiftDevelopment_ColorImages.pdf.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.
To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.
Piracy
Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.
Please contact us at copyright@packtpub.com with a link to the suspected pirated material.
We appreciate your help in protecting our authors and our ability to bring you valuable content.
Questions
If you have a problem with any aspect