通过Universal Render Pipeline获得精美,可扩展和高性能的图形

Universal Render Pipeline is a powerful, ready-to-use solution with a full suite of artist tools for content creation. You should use this rendering pipeline if you want to make a game that has full Unity platform reach with best-in-class visual quality and performance. We covered the benefits of the Universal Render pipeline in this blog post. In this blog post, we’ll dive into how the Universal Render Pipeline was used to create the vertical slice Boat Attack demo.  

Universal Render Pipeline是一种功能强大且易于使用的解决方案,带有一整套用于内容创建的艺术家工具。 如果您想制作一款具有一流的视觉质量和性能的,具有完整Unity平台功能的游戏,则应使用此渲染管道。 我们在此 博客文章 中介绍了通用渲染管道的好处 。 在此博客文章中,我们将深入探讨如何使用Universal Render Pipeline创建垂直切片Boat Attack演示。

We first created the Boat Attack demo to help us validate and test the Universal Render Pipeline (which, at the time, was known as the Lightweight Render Pipeline). Producing a vertical slice as part of our development process was also an exercise in using real-world production processes in our feature development.

我们首先创建了 Boat Attack演示, 以帮助我们验证和测试 Universal Render Pipeline (在当时被称为“轻量级渲染管道”)。 在我们的功能开发中使用真实的生产过程也是在我们的开发过程中生产垂直切片的一种练习。

We have upgraded the Boat Attack demo considerably since we first created it. It now uses many of the Universal Render Pipeline’s new graphical features, along with recent Unity features such as the C# Job System, Burst compiler, Shader Graph, Input System, and more.

自从我们首次创建以来,我们已经对Boat Attack演示进行了大量升级。 现在,它使用了Universal Render Pipeline的许多新图形功能,以及最新的Unity功能,例如 C#作业系统Burst编译器Shader GraphInput System等。

You can download the Boat Attack demo now, and start using it today with Unity 2019.3.

您可以立即下载 Boat Attack演示 ,并立即从Unity 2019.3。开始使用。

演示 (The Demo)

The Boat Attack demo is a small vertical slice of a boat-racing game. It is playable and we are continually adjusting it to take full advantage of the latest Unity features.

划船比赛演示是划船比赛的垂直小片段。 它是可播放的,我们会不断对其进行调整,以充分利用Unity的最新功能。

The demo is designed to work well on a wide variety of platforms: mid- to high-range mobile devices, all current consoles and standalone apps. We demonstrated Boat Attack live at Unite Copenhagen 2019 on a range of devices, from the iPhone 7 to the PlayStation 4.

该演示旨在在各种平台上良好运行:中高端移动设备,所有当前控制台和独立应用程序。 我们在Unite Copenhagen 2019上使用从iPhone 7到PlayStation 4。

To use the demo, we suggest you install the latest version of Unity 2019.3, and then grab the project from GitHub (make sure to read the readme for usage instructions).

要使用该演示,我们建议您安装最新版本的Unity 2019.3,然后从 GitHub 获取项目 (请务必阅读自述文件以获取使用说明)。

着色器图 (Shader Graph)

Shader Graph is an artist-friendly interface for creating shaders. It’s a powerful prototyping tool for technical artists. We used Shader Graph to create some of the unique shading effects in the Boat Attack demo.

Shader Graph 是用于创建着色器的艺术家友好界面。 对于技术美术师来说,这是一个强大的原型制作工具。 我们使用着色器图在Boat Attack演示中创建了一些独特的着色效果。

Using Shader Graph allowed us to create great shading effects, and then painlessly maintain them across many versions of the Lightweight Render Pipeline and the Universal Render Pipeline.

使用“ Shader Graph”使我们能够创建出色的着色效果,然后在轻量级渲染管线和通用渲染管线的许多版本中轻松维护它们。

The cliff shader in Boat Attack demonstrates the effects you can achieve using mesh data – it’s easy to get data from a mesh in Shader Graph. We use the normal vector of the mesh to draw grass on the parts of the cliff face that are flat and facing upwards, and we use the world space height of the mesh to ensure that cliffs and rocks close to the water level will not have grass.

Boat Attack中的悬崖着色器演示了使用网格数据可以实现的效果–在Shader Graph中很容易从网格中获取数据。 我们使用网格的法线矢量在平坦且朝上的悬崖面上的部分上绘制草,并使用网格的世界空间高度来确保靠近水位的悬崖和岩石不会草。

From left to right: Y height mask, Y normal mask, height + normal mask remapped, final shader.

从左到右:Y高度蒙版,Y常规蒙版,高度+常规蒙版重新映射,最终着色器。

植被遮荫 (Vegetation shading)

The vegetation in Boat Attack was initially a custom vertex/fragment shader, but this was painful to maintain when the render pipeline was in early development and code was changing frequently. Recreating the shader in Shader Graph let us take advantage of Shader Graph’s easy upgradeability.

Boat Attack中的植被最初是一个自定义的顶点/片段着色器,但是当渲染管道处于早期开发阶段并且代码频繁更改时,维护起来很痛苦。 在Shader Graph中重新创建着色器使我们可以利用Shader Graph的易升级性。

This Shader Graph effect is based on an implementation from Tiago Sousa of Crytek, which makes great use of vertex colors to control wind animation via vertex displacement. In Boat Attack, we created a Sub-graph to house all the required nodes needed for calculating the wind effect. The Sub-graph contains nested Sub-graphs, which are a collection of utility graphs that perform repeating math calculations.

此着色器图效果基于 Crytek的Tiago Sousa 的实现 ,该实现充分利用了顶点颜色来通过顶点位移控制风的动画。 在Boat Attack中,我们创建了一个子图来容纳计算风效应所需的所有必需节点。 子图包含嵌套的子图,这些子图是执行重复数学计算的实用程序图的集合。

Individual vertex animations and their masks. From left to right: main bending from distance to origin, leaf edge from vertex color Red channel, and branches from vertex color Blue using vertex color Green channel for phase offset.

各个顶点动画及其蒙版。 从左到右:从距离到原点的主弯曲,从顶点颜色红色通道的叶边缘,从顶点颜色蓝色的分支,使用顶点颜色绿色的通道进行相位偏移。

Another big part of creating believable vegetation is subsurface scattering (SSS), which is currently not available with the Universal Render Pipeline. However, to create an SSS-like effect, you can use Shader Graph’s custom function node to retrieve lighting information from Universal Render Pipeline to create your own SSS-like effect.

创建可信植被的另一个重要部分是地下散射(SSS),这在Universal Render Pipeline中目前不可用。 但是,要创建类似SSS的效果,可以使用Shader Graph的自定义功能节点从Universal Render Pipeline中检索照明信息,以创建自己的类似SSS的效果。

Node layout. The SSS Mask is made from the vertex color Green (leaf phase) and the albedo texture map.

节点布局。 SSS遮罩由顶点颜色绿色(叶相)和反照率纹理贴图制成。

The custom function node gives you a lot of creative freedom. You can read up on custom rendering techniques here, or simply grab the code for the node in the Boat Attack repository to try out your own custom lighting ideas.

自定义功能节点为您提供了很多创作自由。 您可以在 此处 阅读自定义渲染技术 ,或者直接在Boat Attack存储库中获取该节点的代码,以尝试自己的自定义照明想法。

From left to right: without SSS, SSS only, final shader.

从左到右:没有SSS,仅SSS,最终着色器。

船定制 (Boat customization)

The boats needed to have multiple variations of colors. In Substance Painter, two livery masks were painted and stored in a packed texture containing Metallic (red), Smoothness (green), Livery 1 (blue) and Livery 2 (alpha). Using the masks via Shader Graph, we can selectively apply coloring to these masked areas.

船需要具有多种颜色。 在Substance Painter中,绘制了两个涂装口罩并将其存储在包含金属(红色),平滑度(绿色),Livery 1(蓝色)和Livery 2(alpha)的填充纹理中。 通过“明暗器图形”(Shader Graph)使用遮罩,我们可以选择性地将颜色应用于这些遮罩区域。

An overview of how the boats are colored. Using overlay blending allows subtle coloring to come through the base albedo map.

船只颜色的概述。 使用叠加混合可以使基础反照率图产生微妙的着色。

The node layout in Shader Graph, wrapped into a Sub-graph for easy use in the parent RaceBoats graph.

Shader Graph中的节点布局被包装到Sub-graph中,以便在父RaceBoats图中轻松使用。

房屋 (Houses)

Boat Attack covers a full day/night cycle. To enhance this illusion, we created a Shader Graph for the windows of the buildings throughout the level. The Shader Graph lights up the windows at dusk and switches them off at dawn.

泛舟攻击涵盖了一个完整的昼/夜周期。 为了增强这种错觉,我们为整个关卡中建筑物的窗户创建了一个着色器图。 着色器图在黄昏时照亮窗户,在黎明时将其关闭。

We achieved this using a simple emission texture that was mapped to a day/night value. We added an effect to slightly randomize the order, using the objects’ positions, so that the houses would light up at different times.

我们使用映射到白天/夜晚值的简单发射纹理实现了这一点。 我们添加了一种效果,可以使用对象的位置稍微随机化顺序,以便房屋在不同的时间亮起。

The node map that enables random emissions.

启用随机发射的节点图。

乌云 (Clouds)

Now that we have added changing lighting to Boat Attack, a simple high-dynamic-range imaging (HDRI) skybox is no longer sufficient. The clouds should be dynamically lit by the lighting in the Scene.

现在,我们已经在Boat Attack中增加了更改照明的功能,简单的高动态范围成像(HDRI)天空盒已不再足够。 云应该由场景中的照明动态地照亮。

But rendering big puffy clouds in real-time is demanding, especially with the need to run on mobile hardware. Because we don’t need to see the clouds from many angles, we decided to use cards with textures to save on performance.

但是,实时渲染大型浮云的要求很高,尤其是需要在移动硬件上运行时。 因为我们不需要从多个角度看云,所以我们决定使用具有纹理的卡来节省性能。

The whole current graph for rendering the clouds.

用于渲染云的整个当前图形。

Shader Graph was crucial in prototyping the look. We baked out some volumetric cloud data from Houdini, and created fully custom lighting in Shader Graph. These clouds are still a work in progress, but they prove that a wide range of surfaces can be created with the node-based editor.

Shader Graph对原型外观至关重要。 我们烘焙了来自Houdini的一些体积云数据,并在Shader Graph中创建了完全自定义的照明。 这些云仍在开发中,但是它们证明可以使用基于节点的编辑器来创建各种曲面。

从API渲染以实现无缝的平面反射 (Rendering from API for seamless Planar Reflections)

Unity’s goal with Scriptable Render Pipelines was to allow users to customize rendering code, instead of hiding it in a black box. Rather than simply opening up our existing rendering code, we pushed our rendering tech with new APIs and hardware in mind. 

Unity使用脚本化渲染管道的目标是允许用户自定义渲染代码,而不是将其隐藏在黑盒中。 我们不仅开放现有的渲染代码,还考虑了新的API和硬件来推动渲染技术。

The Universal Render Pipeline lets you extend its out-of-the-box rendering capabilities with your own C#. It exposes 4 hooks:

通用渲染管线允许您使用自己的C#扩展其即用的渲染功能。 它暴露了4个钩子:

  • RenderPipelineManager.beginFrameRendering

    RenderPipelineManager.beginFrameRendering

  • RenderPipelineManager.beginCameraRendering

    RenderPipelineManager.beginCameraRendering

  • RenderPipelineManager.endCameraRendering

    RenderPipelineManager.endCameraRendering

  • RenderPipelineManager.endFrameRendering

    RenderPipelineManager.endFrameRendering

These hooks let you easily run your own code before rendering the Scene or before rendering certain Cameras. In Boat Attack, we used these hooks to implement Planar Reflections by rendering the Scene into a texture before the main frame is rendered.

这些挂钩可让您在渲染场景之前或在渲染某些摄像机之前轻松地运行自己的代码。 在《快艇攻击》中,我们使用这些钩子在渲染主框架之前通过将场景渲染为纹理来实现“平面反射”。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值