Introduction 简介
The Lab Renderer is what Valve used in all of the Unity-created experiences in The Lab (everything except
Robot Repair). We are shipping this for free to Unity developers as an example of how we think current
generation VR rendering can provide the highest fidelity experience with the best performance.
Lab渲染器是Valve在所有用Unity引擎制作的The Lab游戏体验中所使用的渲染器(除了机器人修理以外的一切).我们将其
作为一个为什么我们认为当代VR渲染可以提供高保真体验的案例正在免费发布给Unity开发者.
This isn’t a complete rendering solution that is meant to replace Unity’s extensive rendering features, but it
does provide all of the features Valve used to ship The Lab. We are providing all source code and shader code
so developers can modify it to best fit their needs.
这不是一个完美的渲染方案来替代Unity引擎的可扩展渲染特性,但是它的确提供了所有Valve发布The Lab所使用到的功
能特性.我们提供所有的源代码和着色器代码,这样开发者可以将其改造成最适合自身需求.
Below is the list of features this renderer provides above the standard Unity renderer:
下面是一个渲染器所提供的基于Unity标准渲染器之上的特性列表:
Single-Pass Forward Rendering and MSAA 单通道正向渲染和多重采样抗锯齿
Forward rendering is critical for VR, because it enables applications to use MSAA which is the best known anti-
aliasing method for VR. Deferred renderers suffer from aliasing issues due to the current state of the art in
image-space anti-aliasing algorithms.
正向渲染对于VR来说是关键的,因为它可以让应用使用多重采样抗锯齿(公认是VR最好的抗锯齿方法).延迟渲染因为图像的
抗锯齿算法而饱受诟病.
Unity’s default forward renderer is multi-pass where geometry is rendered an additional time for each
runtime spotlight or point light that lights each object. The Lab’s renderer supports up to 18 dynamic,
shadowing lights in a single forward pass.
Unity引擎默认的正向渲染是多通道(其中几何体需要花额外的时间来渲染每一次运行聚光灯或者点光源所照亮的每一个物
体)
Adaptive quality 自适应质量
Valve presented the Adaptive Quality algorithm at GDC 2016 in a presentation by Alex Vlachos, “Advanced
VR Rendering Performance”. Slides and video of that presentation are available free on the GDC Vault:
http://www.gdcvault.com/play/1023522/Advanced-VR-Rendering
Valve在2016年的游戏开发者大会上由Alex Vlachos代表提出了自适应质量算法,优化VR的渲染性能.表述的幻灯片和视频
可以在游戏开发者大会广场上免费观看:http://www.gdcvault.com/play/1023522/Advanced-VR-Rendering
Adaptive Quality is a method for dynamically changing rendering fidelity to maintain framerate without
having to rely on reprojection methods that can cause judder and other visual artifacts. The parameters to the
Adaptive Quality algorithm are fully customizable per map.
自适应质量是一种动态改变渲染保真度来保持帧速率的方法(而不是依赖可以造成画面抖动和其他不良视觉效果的二次投
影方法).自适应质量算法的参数可以全部自定义.
Custom Shaders 自定义着色器
The plugin requires that all materials use The Lab’s shaders. If you have a mixture of Unity shaders and The
Lab shaders, Unity will render shadows multiple times, which will cost perf. There are menu options under
Valve->ShaderDev to help you convert your existing materials to use The Lab’s shaders. We recommend
backing up your project before running any of those helper commands.
We are shipping full shader source code, so you can customize the shaders to meet your product’s needs.
插件需要所有的材质都使用The Lab的着色器.如果你混合使用Unity和The Lab的着色器,引擎会重复渲染阴影,这样会消耗
性能.在Unity菜单中你可以找到Valve->ShaderDev选项来帮助你转换你现有的材质来使用The Lab的着色器.我们建议你
在运行任何那些帮助命令前先备份你的工程.
我们正在发布所有的着色器源代码,这样你可以自定义着色器来满足你项目的需求.
GPU Flushing 图形处理器运用
One of the least-known performance tricks in VR rendering is to flush the rendering API at a granularity that
ensures the GPU is fed often enough to keep busy and avoid bubbles. This plugin calls Unity’s GL.Flush() in
the main camera’s OnPostRender() and after shadow rendering for a total of up to 3 times per frame. This is
critical for ensuring the GPU is receiving the draw calls that are being queued in the DirectX runtime in a
timely manner.
一个在VR渲染中最不为人知的性能技巧是在一定的程度上预热渲染API,意味着要确保GPU随时保持运行并且避免冒泡.插
件会在主摄像机的OnPostRender()周期中调用Unity引擎的GL.Flush()方法,并且在阴影渲染之后最高每帧3次.这对于确保
GPU收到的绘制调用以时间顺序被排在DirectX运行队列中.
Quick Start Guide 快速开始指引
Using The Lab Renderer can be as simple as making these changes to your existing project:
使用The Lab渲染器可以通过在你现有的项目中进行以下简单的几步操作: