unity vr开发_花粉VR:使用Unity 5开发高端视觉效果

unity vr开发

More stories from the adventures of an EMEA field engineer! Today, I wanted to share with you the development of Pollen VR. Mindfield Games are using Unity 5’s new graphics features and I have been able to follow their development of Pollen VR very closely.

更多来自EMEA现场工程师的冒险故事! 今天,我想与大家分享Pollen VR的发展。 Mindfield Games正在使用Unity 5的新图形功能,并且我能够非常密切地关注其对Pollen VR的开发。

I spoke with Ville Kivistö, CEO and Co-Founder of Mindfield Games, who is also their technical coder.

我与Mindfield Games的首席执行官兼联合创始人VilleKivistö进行了交谈,他也是他们的技术编码员。

您为Pollen VR使用Unity 5的哪些功能来实现如此高的视觉质量? (What Unity 5 features are you utilising for Pollen VR to achieve such high visual quality?)

New physically based shading and realtime lighting are the definitive features of Unity 5 and we are using them to the fullest. We have material maps basically for every surface and due to design restrictions, environments need to be dynamically lit. With the new global illumination everything looks gorgeous and combined with reflection probes, the surfaces really come alive. Having a 64-bit editor is also crucial to have as developing a high end PC game can consume huge amount of memory. We used to have tons of out-of-memory crashes with Unity 4, but those days are now long gone.

新的基于物理的阴影和实时照明是Unity 5的确定性功能,我们将充分利用它们。 我们基本上具有每个表面的材质贴图,并且由于设计限制,需要动态照明环境。 有了新的全局照明,一切看起来都非常漂亮,并与反射探针结合使用,表面真正变得栩栩如生。 拥有64位编辑器也至关重要,因为开发高端PC游戏会消耗大量内存。 过去,Unity 4曾发生过数次内存不足的崩溃,但是那些日子现在已经过去了。

pollen_interaction2_smaller

您为树叶使用了哪些技术? (What techniques did you use for the foliage?)

Foliage is a rather simple GPU particle effect. What makes it interesting though is how we got the lighting to work with it properly. As Graphics.DrawProcedural doesn’t integrate into Unity’s lighting passes and new CommandBuffer API doesn’t support compute buffers, we had to do a somewhat funky solution.

叶子是一种相当简单的GPU粒子效果。 然而,使我们变得有趣的是我们如何使照明正常使用。 由于Graphics.DrawProcedural没有集成到Unity的光照过程中,并且新的CommandBuffer API不支持计算缓冲区,因此我们不得不做一些时髦的解决方案。

We have a cube the size of foliage bounds, so we know that whenever the cube is visible, foliage needs to be rendered as well. Now, whenever the cube’s OnWillRenderObject() is called, we render the compute buffer particles to two render targets in a single pass with MRT and using the settings of currently rendering camera. One texture has diffuse and roughness data and the other one has normal and depth. When we get to rendering the actual cube, the cube shader just gets those buffers as parameters and outputs corresponding data. Depth is written manually, so we get perfectly Z clipping output. And the lighting of leaves is affected by all lights and shadows to make them look like we want them to.

我们有一个与叶子边界大小相等的立方体,因此我们知道,只要该立方体可见,就需要渲染叶子。 现在,每当调用多维数据集的OnWillRenderObject()时,我们都会使用MRT并使用当前渲染摄影机的设置,一次将计算缓冲区粒子渲染到两个渲染目标。 一种纹理具有漫反射和粗糙度数据,另一种纹理具有法线和深度。 当我们要渲染实际的多维数据集时,多维数据集着色器仅将这些缓冲区作为参数并输出相应的数据。 深度是手动编写的,因此我们可以获得完美的Z裁剪输出。 叶子的光照会受到所有阴影的影响,使它们看起来像我们想要的那样。

And because all the leaves are GPU particles, animating them is really cheap. So they aren’t just a static mesh, but can react to environment realistically (naturally with some limitations).

而且由于所有叶子都是GPU粒子,因此对其进行动画处理确实很便宜。 因此,它们不仅是静态网格物体,而且可以对环境做出实际React(自然有一些限制)。

pollen_hydro_l_smaller

您可以与“全局照明”共享任何技术或工作流吗? (Any techniques or workflows you can share with Global Illumination?)

For us it worked very well straight out of the box. Default values provide a good balance between bake times and quality. On day to day use we have quite conservative values to enable quick baking, but our automatic build system scales up the values to provide even better quality GI for our nightly build.

对于我们来说,它开箱即用时效果很好。 默认值可在烘烤时间和质量之间取得良好的平衡。 在日常使用中,我们具有非常保守的值来进行快速烘焙,但是我们的自动构建系统会按比例放大这些值,从而为我们的夜间构建提供更高质量的GI。

您是否将实时照明和烘焙照明混合使用? (Are you using a mixture of realtime and baked lighting?)

Our game design requires that all lighting is realtime. We don’t have a single static lightmap in the game.

我们的游戏设计要求所有照明都是实时的。 游戏中没有单个静态光照贴图。

In Unity 4, we used to work around that restriction by placing dozens of ambient point lights around the scene, trying to fake global illumination that way. In the end it was horrible, because the maintenance and designing was very tedious and time consuming. It was also pretty much impossible to keep all the lights from leaking through the walls.

在Unity 4中,我们过去通过在场景周围放置数十个环境点光源来解决该限制,试图以此方式伪造全局照明。 最后,这是可怕的,因为维护和设计非常繁琐且耗时。 要防止所有的灯都从墙壁泄漏出去,这几乎是不可能的。

Even the amount of draw calls and fillrate requirements caused by many lights was starting to be quite high, which in turn hampered the framerate. When we got our hands on the Unity 5 beta, we just enabled Enlighten and removed all the fake GI point lights and everything looked better, ran faster and GI worked perfectly in real-time when disabling or animating lights.

甚至许多灯光引起​​的绘图调用和填充速率要求也开始很高,这反过来又阻碍了帧速率。 当我们接触Unity 5 beta时,我们只是启用了Enlighten并删除了所有伪造的GI点光源,并且一切看起来更好,运行更快,并且在禁用或设置光源动画时GI可以实时完美地工作。

We also had a custom cubemap reflection system built, with box projection and everything. It worked rather well, but using it required dozens of custom shaders and the editor side was constantly missing features. We are very happy that new reflection probes basically replaced our own system. They require less maintenance and the workflow is much simpler.

我们还构建了一个自定义的立方体贴图反射系统,其中包括框投影和所有内容。 它工作得很好,但是使用它需要数十个自定义着色器,并且编辑器端一直缺少功能。 我们很高兴新的反射探头基本上取代了我们自己的系统。 他们需要更少的维护,工作流程也更简单。

pollen_lightshafts

您如何实现走廊的发光效果? (How did you achieve the glow effect in the corridors?)

We have a few different volumetric effects that we use throughout the game. For spotlights we like to use Robert Cupisz’ implementation, which gives very nice volumetrics for spotlights that perform very well. As spotlights are very versatile, it’s easy to use them to height based fog as well.

我们在整个游戏中会使用一些不同的体积效果。 对于聚光灯,我们喜欢使用Robert Cupisz的实现 ,它为性能很好的聚光灯提供了非常好的体积度量 。 由于聚光灯用途广泛,因此很容易将其用于基于高度的雾。

In some parts of the game you might see some fluid volumetrics for which we use Fluidity from the Asset Store. We use it in all scales, all the way from lighter fire to filling the room with gasses. It looks awesome and physics simulations always look yummy.

在游戏的某些部分中,您可能会看到一些流体体积度量 ,我们使用资源商店中的“流动性” 。 从打火到充满气体,我们一直在各种规模上使用它。 它看起来很棒,而且物理模拟总是很好吃。

For outdoors, we use our custom post process volumetric fog solution as we want the player to feel the density of Titan’s atmosphere.

对于户外,我们希望使用自定义的后期处理体积雾解决方案,因为我们希望玩家感受到泰坦大气的密度。

pollen_hydro_d

您使用什么工具来生成PBR纹理? (What tools do you use to generate your PBR Textures?)

Adobe Photoshop and Quixel Suite along with some reference materials. We have our own “playground” scene where artists can inspect models in various lighting conditions.

Adobe Photoshop和Quixel Suite以及一些参考资料。 我们拥有自己的“游乐场”场景,艺术家可以在其中查看各种光照条件下的模型。

您是否对Unity的新Standard Shader进行了修改? 如果是这样,有什么秘诀吗? (Have you made modifications to Unity’s new Standard Shader? If so, any tips’n’tricks?)

As our base is not tied to a single point in time and space, we need to be able to render the base differently. As we’re a small indie studio, we don’t have resources to start working on multiple assets that look different based on how old they are. Our solution was to do an extended version of the new Standard Shader that adds “grittyness” to materials. What’s best, it works for all objects and with the new material pipeline, we can have custom grittyness based on material type. Just one shader and few lines of code and we can change the look and feel completely.

由于我们的基础不限于时间和空间上的单个点,因此我们需要能够以不同的方式呈现基础。 由于我们是一家小型独立工作室,因此我们没有足够的资源开始处理根据资产的年限而有所不同的多种资产。 我们的解决方案是对新的标准着色器进行扩展,以增加材料的“坚韧性”。 最好的做法是,它适用于所有对象,并且借助新的材质管道,我们可以根据材质类型获得自定义的坚韧度。 只需一个着色器和几行代码,我们就可以完全改变外观。

Currently Unity doesn’t support code injection to Standard Shader, Our solution is to just copy the built-in shader and keep our code in include files, so we just have to write couple #includes into strategic places if the Standard Shader changes.

当前Unity不支持向标准着色器注入代码,我们的解决方案是仅复制内置着色器并将代码保留在包含文件中,因此,如果标准着色器发生更改,我们只需将几个#include写入重要位置。

pollen_grunge_on_smaller

您如何处理抗锯齿? (How did you deal with Anti aliasing?)

As MSAA doesn’t cope that well with deferred rendering, we have to comply with post processing solutions. The one we have chosen is SMAA as it provides a nice and clean resolve with good performance. Even if it lacks the subpixel and temporal anti-aliasing, the final result is good enough even for Oculus Rift.

由于MSAA不能很好地应对延迟渲染,因此我们必须遵守后处理解决方案。 我们选择的是SMAA,因为它可以提供良好而干净的解决方案以及良好的性能。 即使缺少亚像素和时间抗锯齿功能,最终结果对于Oculus Rift也足够好。

Unity 5的新图形是高端图形,性能如何? (Unity 5’s new graphics is high-end, how has performance been?)

Unity 5’s new MRT based deferred path basically increased the framerate about 30% when compared to the legacy two pass deferred path. Our draw calls can climb quite high and skipping one pass helps a lot to keep those calls down. As virtual reality is very important to us (we recommend playing Pollen with Oculus Rift), it’s crucial that framerate can be as high as possible. Therefore, we provide as many options as possible for tweaking the visuals to match players’ hardware and framerate requirements. With maximum settings Pollen can really turn on those GPU fans, but you can scale down the options a bit and play with an older GPU with Oculus Rift if you like.

与传统的两遍延迟路径相比,Unity 5的新基于MRT的延迟路径基本上将帧率提高了约30%。 我们的抽奖电话可以爬得很高,而跳过一次通行证则可以极大地减少通话次数。 由于虚拟现实对我们非常重要(我们建议与Oculus Rift玩《花粉》),因此帧速率必须尽可能高至关重要。 因此,我们提供了尽可能多的选项来调整视觉效果,以符合玩家的硬件和帧速率要求。 通过最大设置,Pollen可以真正打开这些GPU风扇,但是您可以根据需要稍微缩小选项并使用带有Oculus Rift的旧GPU玩。

pollen_rifteffect_smaller

对如此大的场景进行优化有什么建议吗? (Any advice on the optimisation for such a large scene?)

Unity’s occlusion culling is very efficient and it handles most of the things we want. However, occlusion culling deals only with the rendering and does that only in play mode.

Unity的遮挡剔除非常有效,可以处理我们想要的大多数事情。 但是,遮挡剔除仅处理渲染,并且仅在播放模式下进行。

As we have spent lots of time to make everything behave physically correctly, be it books, basketball, microwave or punching bag, we have huge amount of physical objects in the game. Unfortunately, Umbra doesn’t help us much with physics, so we had to write our own custom portal/culling system. Because the rooms of our moon station are efficiently separated by safety doors, we’ve been able to write a simple portal system based on those doors. We simply disable all the rooms the player can’t see. This helps with physics and even with Umbra as it has less culling work to do. In editor, we can also easily activate only a single room to keep draw calls and poly count low and editor responsive.

由于我们花了很多时间使所有事物在身体上都能正确运作,无论是书籍,篮球,微波炉还是沙袋,我们在游戏中都有大量的物理对象。 不幸的是,Umbra在物理方面对我们没有多大帮助,因此我们不得不编写自己的自定义门户/剔除系统。 由于我们月球站的房间被安全门有效地隔开,因此我们已经能够基于这些门编写一个简单的门户系统。 我们只是禁用玩家看不到的所有房间。 这对物理甚至对Umbra都有帮助,因为它要做的剔除工作较少。 在编辑器中,我们还可以轻松地仅激活一个房间,以保持绘图调用和多边形计数较低,并使编辑器响应。

Out the box Unity 5 handled everything else for us, we didn’t need to do any additional optimising for our large scenes, everything just worked!

Unity 5开箱即用,可以为我们处理其他所有事情,我们不需要为大型场景做任何其他优化,一切都可以正常工作!

感谢Ville与我交谈,迫不及待想看看这款游戏的发布! (Thanks to Ville for talking to me, can’t wait to see this game released!)

翻译自: https://blogs.unity3d.com/2015/02/16/pollen-vr-developing-high-end-visuals-with-unity-5/

unity vr开发

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值