具体描述
Explore the world of Virtual Reality by building immersive and fun VR projects using Unity 3D
About This Book
Learn the basic principles of virtual reality applications and get to know how they differ from games and desktop apps
Build various types of VR experiences, including diorama, first-person characters, riding on rails, 360 degree projections, and social VR
A project-based guide that teaches you to use Unity to develop VR applications, which can be experienced with devices such as the Oculus Rift or Google Cardboard
Who This Book Is For
If you're a non-programmer unfamiliar with 3D computer graphics, or experienced in both but new to virtual reality, and are interested in building your own VR games or applications then this book is for you. Any experience in Unity is an advantage.
What You Will Learn
Create 3D scenes with Unity and Blender while learning about world space and scale
Build and run VR applications for consumer headsets including Oculus Rift and Google Cardboard
Build interactive environments with physics, gravity, animations, and lighting using the Unity engine
Experiment with various user interface (UI) techniques that you can use in your VR applications
Implement the first-person and third-person experiences that use only head motion gestures for input
Create animated walkthroughs, use 360-degree media, and build multi-user social VR experiences
Learn about the technology and psychology of VR including rendering, performance and VR motion sickness
Gain introductory and advanced experience in Unity programming with the C# language
In Detail
What is consumer “virtual reality”? Wearing a head-mounted display you view stereoscopic 3D scenes. You can look around by moving your head, and walk around using hand controls or motion sensors. You are engaged in a fully immersive experience. On the other hand, Unity is a powerful game development engine that provides a rich set of features such as visual lighting, materials, physics, audio, special effects, and animation for creating 2D and 3D games. Unity 5 has become the leading platform for building virtual reality games, applications and experiences for this new generation of consumer VR devices.
Using a practical and project-based approach, this book will educate you about the specifics of virtual reality development in Unity.
You will learn how to use Unity to develop VR applications which can be experienced with devices such as the Oculus Rift or Google Cardboard. We will then learn how to engage with virtual worlds from a third person and first person character point of view. Furthermore, you will explore the technical considerations especially important and possibly unique to VR. The projects in the book will demonstrate how to build a variety of VR experiences. You will be diving into the Unity 3D game engine via the interactive Unity Editor as well as C-Sharp programming.
By the end of the book, you will be equipped to develop rich, interactive virtual reality experiences using Unity.
So, let's get to it!
Style and approach
This book takes a practical, project-based approach to teach specifics of virtual reality development in Unity. Using a reader-friendly approach, this book will not only provide detailed step-by-step instructions but also discuss the broader context and applications covered within.
作者简介
Jonathan Linowes is the owner of Parkerhill Reality Labs, a start-up VR/AR consultancy firm. He is a veritable VR and 3D graphics enthusiast, full-stack web developer, software engineer, successful entrepreneur, and teacher. He has a fine arts degree from Syracuse University and a master's degree from the MIT Media Lab. He has founded several successful start-ups and held technical leadership positions at major corporations, including Autodesk Inc.
目录信息
Desktop VR 4
Mobile VR 5
The difference between virtual reality and augmented reality 5 Applications versus games 6 What this book covers 9
Who are you? 9
Types of VR experiences 10 Technical skills that are important to VR 11 Summary 12
Chapter 2: Objects and Scale 13 Getting started with Unity 14 Starting a new Unity project 14 The Unity editor 15 The default world space 16 Creating a simple diorama 17 Adding a cube 17 Adding a plane 18 Adding a sphere and some material 20
Changing the scene view Adding a photo
Coloring the ground plane
Measurement tools 25
Keeping a unit cube handy 26 Using a Grid Projector 26 Measuring the Ethan character 29
Importing from the Blender experiment 30 An introduction to Blender 31 A unit cube 34 A UV Texture image 35 Importing into Unity 38 A few observations 39 Summary 40
Chapter 3: VR Build and Run 41 VR device integration software 42 Unity's built-in VR support 42 The device-specific SDK 42 The OSVR project 43 WebVR 43 3D worlds 44 Creating the MeMyselfEye prefab 44 Build for the Oculus Rift 45 Build for Google Cardboard 46 The Android setup 47 The iOS setup 47 Installing the Cardboard Unity package 47 Adding the camera 48 The build settings 48 The Play Mode 49 Building and running in Android 49 Building and running in iOS 50 The device-independent clicker 50 How virtual reality really works 52 Stereoscopic 3D viewing 52 Head tracking 56 Summary 58
Chapter 4: Gaze-based Control 59 Ethan, the walker 60 Artificially intelligent Ethan 61 The Navmesh bakery 62 A random walker in the town 63 Interlude – a quick introduction to Unity programming 63
The RandomPosition script 66
"Zombie-ize" Ethan! 68
Go where I'm looking 69
The LookMoveTo script 70 Adding a feedback cursor 72 Observations 73
If looks could kill 74
The KillTarget script 74 Adding particle effects 77 Cleaning up 79
Summary 79 Chapter 5: World Space UI 81 A reusable default canvas 83 The visor HUD 87 The reticle cursor 89 The windshield HUD 91 The game element UI 93 The info bubble 96 An in-game dashboard with input events 99 Creating a dashboard with buttons 100 Linking the water hose to the buttons 103 Activating buttons from the script 104 Look to highlight a button 106 Looking and then clicking to select 108 Looking and staring to select 109 A responsive object UI with head gestures 111 Using the head position 111 Using head gestures 113 Summary 117 Chapter 6: First-person Character 119 Understanding the Unity characters 120
Unity components
The Camera component
The Rigidbody component
The Character Controller component
Unity Standard Assets ThirdPersonController AIThirdPersonController FirstPersonController RigidBodyFPSController
Making a first person 125
Move in the direction you're looking 126 Keep your feet on the ground 127 Don't pass through solid objects 127 Don't fall off the edge of the world 129 Stepping over small objects and handling uneven terrain 130 Start and stop moving 130 Using head gestures to start/stop 131
User calibrations 132
A character's height 132 Real-life height of a player 135 Recentering 136
Maintaining a sense of self 136
Head-body disconnect 136 Head and body... 137 ...And feet 138 The body avatar 140 Virtual David le nose 141 Audio cues 143
Locomotion, teleportation, and sensors 144 Managing VR motion sickness 146 Summary 148
Chapter 7: Physics and the Environment 149 Unity physics 150 Bouncy balls 152 Headshots 156 Trampoline and brick 160 A human trampoline 162
Like a brick 162
Like a character 163
Interlude – environment and things 167
Wispy Sky
The planet Earth
The corporate logo Blender
Unity
An elevator Jumping Summary
Chapter 8: Walk-throughs and Rendering 175 Building in Blender 176 Walls 176 Ceiling 181 Assemble the scene in Unity 184 The gallery room 184 The artwork rig 185 The exhibition plan 188 Adding photos to the gallery 190 An animated walk-through 193 Unity's animation system 193 Scripted animation 194 Optimizing for performance and comfort 196
Optimizing your implementation and content 198 Simplify your models 198 Using texture maps instead of complex meshes 198 Limiting the objects to be drawn 199 Lighting and shadow performance 199 Optimizing your scripts 200
Optimizing for the Unity rendering pipeline 200 Life's a batch 200 Multipass pixel filling 202 Other rendering tips 203
Optimizing for the target hardware and drivers 203
Unity Profiler
Summary
Chapter 9: Using All 360 Degrees
360-degree media
Crystal balls
Magic orbs
Panoramas
Infographics Equirectangular projections Globes
Photospheres
Field of view – FOV
Capturing a 360-degree media Summary
Chapter 10: Social VR Metaverse 229 Multiplayer networking 230 Networking services 230 The network architecture 231 Local versus server 232 The Unity networking system 234 Setting up a simple scene 235 Creating a scene environment 235 Creating an avatar head 236 Adding multiplayer networking 238 Network Manager and HUD 238 Network Identity and Transform 238 Running as a host 239 Adding spawn positions 239 Running two instances of the game 240 Associating avatar with the first-person character 241 Adding multiplayer virtual reality 243 The Oculus Rift players 243 The Google Cardboard players 245 Next steps 247 Building and sharing a custom VRChat room 248
Preparing and building the world
Host the world
Summary
Chapter 11: What's Next? Index
· · · · · · (收起)
读后感
用户评价
关于本书在“虚拟现实”特定领域的技术深度,我不得不提出最严厉的批评。它似乎在某些方面存在知识滞后性。书中反复强调使用Unity的旧版XR Legacy Input System来处理控制器输入,这对于所有已经转向新的Unity Input System(以及其内置的XR Interaction Toolkit)的开发者来说,是完全过时的信息。新的Input System提供了更统一、更面向行为的输入抽象层,这对于管理不同硬件(如Valve Index、Oculus Touch、WMR手柄)的输入映射至关重要。更令人担忧的是,它在涉及立体渲染和深度缓冲处理时,使用的代码示例非常基础,完全没有提及如何利用现代GPU的特性,比如异步计算或深度预通道(Depth Pre-Pass)来提升VR的渲染效率。VR对性能的苛刻要求,意味着任何低效的渲染调用都会被放大。这本书提供的解决方案,可能在十年前的移动VR上勉强可用,但在今天主流的PCVR或高性能一体机上,无疑会成为性能瓶颈的源头。因此,它更像是一部关于“如何用Unity制作3D游戏”的教材,而非真正聚焦于“如何为虚拟现实环境优化和设计沉浸式体验”的专业指南。
我对这本书的结构感到非常困惑,它似乎试图覆盖太多的领域,但每一个都只是蜻蜓点水。例如,它用了一整个章节来介绍如何导入和烘焙光照贴图,这在现代VR开发中,我们更多依赖实时光照或混合光照方案以保证动态感和沉浸感,硬生生地塞入一个完全针对非VR标准PC项目的旧式光照流程,显得非常突兀和不合时宜。更别提它对多人网络同步的处理,那部分内容简直是灾难性的——它只是粗略地提到了Mirror或Photon等框架的存在,却完全没有提供一个可运行的、针对VR空间位置和旋转同步的最小可行示例。要知道,VR多人协作或竞技的挑战性远高于传统桌面游戏,它涉及到低延迟的骨骼动画同步、环境遮挡剔除的优化、以及如何处理网络延迟对用户眩晕感的影响。这本书似乎完全忽略了这些至关重要的工程考量,给出的解决方案是那种需要读者自己去谷歌搜索“网络同步”的初级阶段方法。如果一本宣称是“项目实战”的书连一个健壮的网络模型都无法提供,那么它的实用价值就大打折扣了。
这本书的名字听起来倒是挺吸引人的,**《Unity Virtual Reality Projects》**,但恕我直言,我实际翻阅之后,发现它在内容深度和广度上,都与我期望中的“项目实战”指南相去甚远。 比如,它对VR头戴设备底层交互机制的讲解,简直像是一份停留在十年前的入门教程。我本以为会深入探讨如何利用Unity的最新渲染管线(如URP或HDRP)来优化VR体验,确保在各种目标平台上都能达到稳定的帧率,结果呢?它大部分篇幅都在重复讲解如何设置一个基础的Canvas,以及如何拖拽预设的组件来模拟一个简单的拾取动作。这对于任何一个已经接触过Unity半年以上,并且对VR开发有一定热情的读者来说,简直是浪费时间。真正的VR项目,需要的不仅仅是基础的场景搭建,更需要对性能调优、跨平台兼容性(尤其是Quest系列和PCVR的差异化处理)、空间音频的沉浸式应用、以及复杂用户输入系统的精细化设计有深入的剖析。这本书在这几个关键点上都浅尝辄止,留给读者的更多是“我知道该做什么”的模糊概念,而非“我如何高效地做到”的具体代码和最佳实践。我更希望看到的是如何解决那些在实际部署中才会遇到的棘手问题,而不是在光盘里就能找到的标准Demo的文字复述。
作为一名侧重于用户体验(UX)和沉浸感设计的开发者,我对于这本书中关于交互设计的论述感到非常失望。VR的灵魂在于交互,它要求我们重新思考“点击”和“拖拽”的物理意义。然而,这本书的交互部分几乎完全照搬了传统3D游戏的操作逻辑,例如,它推荐使用射线投射(Raycasting)来选中远距离物体,这在许多VR设计规范中已经被视为非沉浸式且容易引起疲劳的操作方式。我期待看到的是对手部追踪(Hand Tracking)、自然手势识别(如捏合、抓握的力度反馈),以及如何利用触觉反馈(Haptics)来增强临场感的设计模式。书中对这些前沿且关键的技术只是在脚注中一笔带过,没有提供任何实际的代码示例或设计原则。例如,一个优秀的VR项目应该详细解释如何根据用户的手部在世界空间中的实际位置来动态调整UI的距离和角度,以避免VR晕动症,但这本书里,UI永远是固定在摄像机前方的两块平面,这简直是扼杀了VR体验的潜力。
坦白说,这本书的“项目”部分更像是碎片化的功能集合而非连贯的开发流程。例如,它在第三章实现了一个简单的物理模拟,在第十章又突然插入了如何使用第三方SDK制作一个“可拍照”的功能。这两者之间的逻辑衔接生硬得像用胶水粘起来的。一个真正有价值的VR项目书,应该围绕一个核心主题或一个复杂应用场景,逐步引入新技术和挑战,让读者体验到从概念验证(PoC)到最终部署的完整生命周期。我希望看到的是,如何基于一个统一的叙事框架,将渲染优化、复杂输入处理、数据持久化以及性能分析等模块有机地整合在一起。这本书的问题在于,它更像是一本Unity官方文档中各个独立教程的拼凑,缺乏宏观的架构指导和深层次的工程哲学。读者读完后,可能会掌握几个孤立的技巧,但却难以建立起构建大型、复杂VR应用所需的系统性思维框架。这对于想要从“会做小Demo”过渡到“能交付产品”的开发者来说,帮助有限。
作为一本快速入门的VR的书籍来说再好不过
作为一本快速入门的VR的书籍来说再好不过
一本Step By Step的VR入门书,但也不仅仅局限于入门知识。很多Oculus工程师的设计思想穿插在其中,用以帮助VR设计开发者更好地去理解VR的短版及优势。
作为一本快速入门的VR的书籍来说再好不过
一本Step By Step的VR入门书,但也不仅仅局限于入门知识。很多Oculus工程师的设计思想穿插在其中,用以帮助VR设计开发者更好地去理解VR的短版及优势。