Reader small image

You're reading from  Unity Virtual Reality Projects

Product typeBook
Published inSep 2015
Reading LevelIntermediate
PublisherPackt
ISBN-139781783988556
Edition1st Edition
Languages
Right arrow
Author (1)
Jonathan Linowes
Jonathan Linowes
author image
Jonathan Linowes

Jonathan Linowes is a VR/AR enthusiast, Unity, and full stack developer, entrepreneur, certified Unity instructor, and the owner of Parkerhill XR Studio, an immersive media, applications, and game developer. Jonathan has a bachelor of fine arts degree from Syracuse University, a master of science degree from the MIT Media Lab, and has held technical leadership positions at Autodesk and other companies. He has authored multiple books on VR and AR published by Packt Publishing.
Read more about Jonathan Linowes

Right arrow

Chapter 8. Walk-throughs and Rendering

Living room simulation scene by Krystian Babilinsky, used with permission

In this chapter, we'll dig a bit into level design, modeling, and rendering, and implement an animated walk-through that you can experience in VR. The scene is a photo gallery, where you design a simple floor plan and use Blender to extrude it vertically into the walls. Use your own photos. Then, we will take a simple tour of it. At the end, we'll have a technical conversation about optimization, performance, and comfort.

In this chapter, we are going to discuss the following topics:

  • Using Blender and Unity to build a simplistic art gallery

  • Creating an animated walkthrough of the gallery scene

  • Techniques that can be used to squeeze performance from complex scenes

Note that the projects in this chapter are separate and not directly required by the other chapters in this book. If you decide to skip any of it or not save your work, that's OK.

Building in Blender


Creating realistic models with convincing materials and lighting is an art and a science that extends beyond the scope of this book. Many people just find models online that are built by experts, including the Unity Asset Store. There is, of course, a wide range of design applications available, from the most advanced, such as 3D Studio Max (http://www.autodesk.com/products/3ds-max/) and Blender, to the most user-friendly, such as Home Styler (http://www.homestyler.com/) and SketchUp (http://www.sketchup.com/).

For this project, we just need something simple. We need a small art gallery exhibit room, about 24 by 36 feet. Keeping it minimal and instructive, I want to show how you can get started with building it in Blender.

Walls

To start, draw a simple floor plan on a piece of paper or use a drawing app. Mine is just an open space with two entrances and interior walls to display artwork (Gallery-floorplan.jpg), which looks like the following image:

Now, open Blender. We'll...

Assemble the scene in Unity


Now, we can use the gallery room model in Unity and add a floor and a ceiling with skylights. We will apply textures to the walls and add lighting.

The gallery room

First, we'll build the art gallery's room structure by performing the following steps:

  1. Create a new scene by navigating to File | New Scene.

  2. Create a floor plane by navigating to GameObject | 3D Object | Plane. Reset its Transform option and rename it to Floor.

  3. Create the material for the floor and color it beige.

  4. Our room is sized 24 by 36 feet, which in meters is 7.3 by 11. A Unity plane is 10 units square. So Scale it to (0.73, 1, 1.1).

  5. Import the gallery model (for instance, Gallery.blend). Drag a copy from Project Assets into the Scene. Reset its Transform option.

  6. Manually rotate and/or scale it to fit the floor, as needed (mine fits, but its Rotate Y value needed to be set to 90). It may help if you first change the Scene view to Top Iso.

  7. It is a good idea to add a collider to the walls so that a character...

An animated walk-through


Next, we'll implement an automated walk-through of the scene. In conventional games, this is often used for a cut-scene, that is, a canned fly-through animation as a transition from one level to another. In VR, it's somewhat different. Walk-throughs can really be the VR experience itself. Head tracking is still active. So, it's not simply a pre-recorded video. You can look around and experience it, and it is more like an amusement park ride. This is often called an on-the-rails VR experience.

Unity's animation system

Unity's animation system is a powerful multipart system that lets you build advanced and intricate animation behaviors. The animation system has different but similar sounding parts:

  • An Animation Curve defines a spline curve for a specific property that changes its value over time.

  • An Animation Clip is a named set of curves that can be applied to an object and played (it animates the object). It can be edited in the Animation View panel.

  • An Animator Controller...

Optimizing for performance and comfort


Admittedly, this chapter has been mostly about level design and is not specifically about virtual reality. However, I didn't want to just give you a pre-built Unity package and say, "Hey, import this so that we can do a walk-through!"

It should be abundantly clear by now that developing for VR has many facets (pun intended). Once you have a "fancy schmancy" scene created with models, textures, and lighting and you provide a thrilling ride-through for your visitors, you'll inevitably need to start thinking about rendering performance, frames per second, latency, and motion sickness.

 

We developers rapidly become immune to all but the most obvious rendering errors, and as a result we are the worst people at testing our own code. It introduces a new and exciting variation of the coder's defense that "it works on my machine" – in this case, "it works for my brain".

 
 --Tom Forsyth, Oculus

There are some very good articles that are written by experts and which...

Summary


In this chapter, we built an art gallery scene from scratch, starting with a plan drawing and going into Blender to construct an architectural structure. We imported the model into Unity and added some environmental lighting. Then, we built an artwork rig consisting of an image quad, a picture frame, and a spotlight, and placed instances of the rig on various walls throughout the gallery. Next, we imported a bunch of personal photos and wrote a script that populates the art frames at runtime. Finally, we wrote a script that takes the first-person camera on a walk-through of the scene, pausing to look at each picture one at a time for a nice, simple VR-on-rails experience.

Then, we had a detailed discussion about optimizing projects for performance and VR comfort, which means that you have to be mindful of your content and model complexity, the rendering pipeline, and the capabilities of your target platform.

In the next chapter, we will take a look at a different kind of VR experience...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unity Virtual Reality Projects
Published in: Sep 2015Publisher: PacktISBN-13: 9781783988556
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Jonathan Linowes

Jonathan Linowes is a VR/AR enthusiast, Unity, and full stack developer, entrepreneur, certified Unity instructor, and the owner of Parkerhill XR Studio, an immersive media, applications, and game developer. Jonathan has a bachelor of fine arts degree from Syracuse University, a master of science degree from the MIT Media Lab, and has held technical leadership positions at Autodesk and other companies. He has authored multiple books on VR and AR published by Packt Publishing.
Read more about Jonathan Linowes