shader graph

A recent Unity Labs paper introduces a new framework for blending normal maps that is easy and intuitive for both technical artists and graphics engineers. This approach overcomes several limitations of traditional methods.

Unity Labs最近发表的一篇论文介绍了一种用于混合法线贴图的新框架,该框架对于技术美术师和图形工程师而言都非常容易且直观。 这种方法克服了传统方法的一些局限性。

Since the introduction of normal mapping in real-time computer graphics, combining or blending normal maps in a mathematically correct way to get visually pleasing results has been a difficult problem for even very experienced graphics engineers. Historically, people often blend normals in world space, which produces incorrect and less than satisfactory results. The paper “Surface Gradient Based Bump Mapping Framework” introduces a new framework that addresses the limitations of traditional normal mapping. This new approach is easy and intuitive for both technical artists and graphics engineers, even where different forms of bump maps are combined.

自从 在实时计算机图形中 引入 法线贴图 以来 ,即使是非常有经验的图形工程师,以数学上正确的方式组合或混合法线贴图以获得视觉上令人愉悦的结果也是一个难题。 从历史上看,人们经常在世界空间中融合法线,这会产生不正确且不令人满意的结果。 论文“ 基于表面梯度的凹凸贴图框架 ”介绍了一个新的框架,该框架解决了传统法线贴图的局限性。 即使将不同形式的凹凸贴图结合起来,对于技术美术师和图形工程师而言,这种新方法都非常容易直观。

In modern computer graphics, material layering is critical to achieve rich and complex environments. To do this, we need support for bump mapping across multiple sets of texture coordinates as well as blending between multiple bump maps. Additionally, we want to be able to adjust the bump scale on object space normal maps and be able to composite/blend these maps correctly with tangent space normal maps and with triplanar projection.

在现代计算机图形学中,材料分层对于实现丰富而复杂的环境至关重要。 为此,我们需要支持跨多个纹理坐标集的凹凸贴图以及多个凹凸贴图之间的混合。 此外,我们希望能够在对象空间法线贴图上调整凹凸比例,并能够与切线空间法线贴图和三面投影正确地合成/混合这些贴图。

Traditionally, real-time graphics has supported bump mapping on only one set of texture coordinates. Bump mapping requires data for every vertex to be pre-calculated and stored (tangent space). Supporting additional sets of texture coordinates would require proportional amounts of extra storage per vertex. Further, doing so does not support procedural geometry/texture coordinates or advanced deformation of the geometry.

传统上,实时图形仅在一组纹理坐标上支持凹凸贴图。 凹凸映射要求预先计算和存储每个顶点的数据(切线空间)。 支持额外的纹理坐标集将需要每个顶点成比例的额外存储量。 此外,这样做不支持程序几何/纹理坐标或几何的高级变形。

The High Definition Rendering Pipeline (HDRP) solves this problem by leveraging the surface gradient-based framework for bump mapping. In HDRP, traditional tangent space, per vertex, is used for the first set of texture coordinates to support strict compliance with MikkTSpace. This is required for difficult cases such as baked normal maps made for low-polygonal hard surface geometry.

高清晰度渲染管线(HDRP)通过利用基于 表面梯度的凹凸映射框架 解决了此问题 。 在HDRP中,每个顶点的传统切线空间用于第一组纹理坐标,以支持严格遵守 MikkTSpace 。 这 对于困难的情况 是 必需的, 例如为低多边形硬表面几何图形制作的烘焙法线贴图。

For all subsequent sets of texture coordinates, we calculate tangent space on the fly in the pixel shader. Doing so allows us to support normal mapping across all sets of texture coordinates as well as using it with procedural geometry and advanced deformers beyond simple skinning.

对于所有后续的纹理坐标集,我们可以在像素着色器中动态计算切线空间。 这样做可以使我们支持跨所有纹理坐标集的法线贴图 ,以及将其与 除简单蒙皮之外的程序几何和高级变形器 一起使用 。

Correct blending is achieved by accumulating surface gradients as described in the paper.
Up until now, this framework has been available only when using shaders that are built into HDRP. However, a prototype version made for Shader Graph is now available on Github in a sample scene made with Unity 2019.3.0b4 and Shader Graph version 7.1.2. The framework itself is implemented entirely as subgraphs for Shader Graph, and each subgraph is made with only built-in nodes.

如本文所述,通过累积表面梯度可以实现正确的混合。
到目前为止,仅当使用内置在HDRP中的着色器时,此框架才可用。 但是,现在 可以在Github 上使用Unity 2019.3.0b4和Shader Graph版本7.1.2制作的示例场景中 为Shader Graph创建原型版本 。 框架本身完全作为Shader Graph的子图实现,并且每个子图仅由内置节点组成。

The method involves the following steps:

该方法包括以下步骤:

  1. Establish a surface gradient for each bump map.

    为每个凹凸贴图建立一个表面渐变。

  2. Scale each surface gradient by a user-defined bump scale.

    通过用户定义的凹凸比例缩放每个表面渐变。

  3. Add (or blend) all the surface gradients into one.

    将所有表面渐变相加(或混合)。

  4. Resolve to produce the final bump mapped normal.

    解析以生成最终的凹凸贴图法线。

By adhering to this framework, every single form of bump map produces a surface gradient, which allows for uniform processing. This includes tangent/object space normal maps, planar projection, triplanar projection and even bump maps in the form of a procedural 3D texture. This makes it much easier to correctly blend.

通过遵守此框架,凹凸贴图的每种形式都会产生表面梯度,从而可以进行统一处理。 这包括程序3D纹理形式的切线/对象空间法线贴图,平面投影,三面投影以及甚至凹凸贴图。 这样可以更轻松地正确混合。

The sample comes with several graphs that use the framework. Each graph illustrates a different use-case of the framework. We will go through some of these in the following sections.

该示例附带了几个使用该框架的图形。 每个图都说明了框架的不同用例。 我们将在以下各节中介绍其中一些内容。

基本法线贴图 (Basic normal mapping)

The graph for the shader basic illustrates the flow but also shows the difference between using vertex tangent space and using procedural tangent space.

着色器 基本 图形 显示了流程,但也显示了使用顶点切线空间和使用过程切线空间之间的区别。

  1. The subgraph basisMikkTS.shadersubgraph produces the conventional tangent and bitangent. This works for UV0 only.

    子图基础 MikkTS.shadersubgraph 产生常规切线和双切线。 这仅适用于UV0。

  2. A procedural tangent and bitangent is obtained with the subgraph GenBasisTB.shadersubgraph using any texture coordinate.

    使用任何纹理坐标 ,通过子图 GenBasisTB.shadersubgraph 获得过程切线和双切线 。

Since this sample uses UV0 specifically, a Boolean property on the Blackboard serves as a toggle. For any other UV set, the shader would have to use the second method.

由于此示例专门使用UV0,因此Blackboard上的Boolean属性用作切换。 对于任何其他UV集,着色器将必须使用第二种方法。

Note that a special subgraph – tex ts norm to deriv.shadersubgraph – is used to sample the tangent space normal map. Rather than returning a vector3, it returns a vector2 called a derivative. You can add or blend derivatives when you sample them using the same UV set. However, to support adding and blending when using different UV sets or even different forms of bump maps, you need to add or blend surface gradients.

请注意,一个特殊的子图 -tex ts norm to deriv.shadersubgraph- 用于采样切线空间法线贴图。 而不是返回vector3,而是返回称为 导数 的vector2 。 使用相同的UV集采样衍生物时,可以添加或混合它们。 但是, 要在使用不同的UV集甚至不同形式的凹凸贴图时支持添加和混合,则需要添加或混合表面渐变。

To produce a surface gradient, use the subgraph called Surfgrad TBN.shadersubgraph, shown above.

要产生表面渐变,请使用 上面显示的 名为 Surfgrad TBN.shadersubgraph 的子图 。

To adjust the bump scale on a surface gradient, use a simple multiply node. Alternatively, you can use a subgraph called Apply Bump Scale.shadersubgraph.

要在表面渐变上调整凹凸比例,请使用简单的乘法节点。 另外,您可以使用一个称为 Apply Bump Scale.shadersubgraph 的子图 。

Then you can convert the surface gradient into a final bump mapped normal by using the subgraph Resolve Surfgrad.shadersubgraph.

然后,可以使用子图 Resolve Surfgrad.shadersubgraph 将表面渐变转换为最终的凹凸贴图,以法线 表示

对象空间法线贴图 (Object space normal maps)

Object space normal maps are also integrated into the surface gradient-based workflow. This lets you adjust the bump mapping intensity and blend/add object space normal maps with other forms of bump maps.

对象空间法线贴图也已集成到基于曲面梯度的工作流程中。 这使您可以调整凹凸贴图的强度,并与其他形式的凹凸贴图混合/添加对象空间法线贴图。

Below is the graph called OS nmap basic.

下面是称为 OS nmap basic 的图 。

First, transform the sampled normal from object space into world space. For best results, this would be transformed as a normal, but Shader Graph’s built-in transformations do not support this, so direction is the best option. Then, convert the normal into a surface gradient by using the subgraph called Normal to surfgrad.shadersubgraph. Once the bump contribution is a surface gradient, proceed as you would for other forms of bump maps – adjusting the bump scale as described in the previous section and adding/blending multiple surface gradients until you resolve at the end to produce the final normal.

首先,将采样的法线从对象空间转换为世界空间。 为了获得最佳结果,可以正常进行转换,但是Shader Graph的内置转换不支持此操作,因此方向是最佳选择。 然后,通过使用称为 surfgrad.shadersubgraph的法线 的子图将法线转换为表面渐变 。 一旦凹凸贡献是一个表面梯度,就可以像处理其他形式的凹凸贴图一样继续进行–按照上一节中的说明调整凹凸比例,并添加/混合多个表面梯度,直到最终解析以生成最终法线。

三面投影 (Triplanar projection)

Triplanar projection represents a special case for a bump map as a 3D texture. The paper “Surface Gradient Based Bump Mapping Framework” describes the full calculations to correctly do this. Below, see conventional normal map blending (left) compared with the surface gradient-based approach (right) (from a Unity presentation at Siggraph 2018).

三面投影代表凹凸贴图作为3D纹理的一种特殊情况。 论文“ 基于表面梯度的凹凸贴图框架 ”描述了正确执行此操作的完整计算。 下面,请参阅常规法线贴图混合(左)与基于表面梯度的方法(右)相比(来自 Siggraph 2018 的 Unity演示 )。

The graph Triplanar uses this method for blending by using the subgraph Triplanar to surfgrad.shadersubgraph to produce a surface gradient from a triplanar projection. As before, you can modulate the surface gradient using a bump scale, blend/add the surface gradient to other surface gradients, and then resolve to obtain the final normal.

Triplanar 使用此方法进行混合,方法是使用子图 Triplanar进行surfgrad.shader 子图 以从三面投影产生曲面梯度。 和以前一样,您可以使用凹凸刻度调整表面梯度,将表面梯度混合/添加到其他表面梯度,然后解析以获得最终法线。

混合/添加多个凹凸贴图 (Blending/adding multiple bump maps)

One of the most valuable aspects of this framework is that it allows the correct blending of any category and number of bump maps, across any number of sets of texture coordinates, including procedural UVs. The example below shows three kinds of bump maps being blended: a tileable tangent space normal map, an object space normal map, and a bump map as a procedural 3D texture.

该框架最有价值的方面之一是,它可以跨任意数量的纹理坐标集(包括程序UV)正确混合任何类别和数量的凹凸贴图。 下面的示例显示了三种混合的凹凸贴图:可拼贴的切线空间法线贴图,对象空间法线贴图和作为过程3D纹理的凹凸贴图。

The graph Mixing performs blending in this way (see below). Note how each bump map results in a surface gradient that is modulated by its respective bump map intensity and also how the surface gradients can be combined by adding or blending them. In the end, the combined surface gradient is resolved to produce the final normal.

图形“ 混合” 以这种方式执行混合(请参见下文)。 请注意,每个凹凸贴图如何产生由其各自的凹凸贴图强度调制的表面梯度,以及如何通过添加或混合它们来组合表面梯度。 最后,解析组合的表面梯度以生成最终法线。

更多例子 (More examples)

The Unity sample scene includes several other examples such as triplanar projection applied to a normal mapped surface, detail normal mapping applied after parallax correction or parallax occlusion mapping (POM), bump mapping from a height map, bump mapping using a procedural 3D texture, and more.

的 统一样品场景 包括几个其它实例中,如三平面投影施加到一个正常映射表面,细节正常映射应用于视差校正或视差闭塞映射(POM),从一个高度图凹凸贴图,使用程序3D纹理凹凸贴图,后和更多。

2019.3的新功能 (What’s new in 2019.3)

You can now visually author shaders in Shader Graph and use them in Visual Effect Graph to create custom looks and rendering behaviors. We have added Shader Keywords, which can create static branches in your graph. Use this for things like building your own Shader LOD system. There is also added support for vertex skinning for DOTS animation which allows you to author better water and foliage. In addition, sticky notes improve your workflow by allowing you to leave comments and explanations for whomever is working on the project. Finally, procedural pattern subgraph samples show how math can be used to create procedural shapes and patterns.

现在,您可以在Shader Graph中直观地创建着色器,并在Visual Effect Graph中使用它们来创建自定义外观和渲染行为。 我们添加了着色器关键字,可以在图形中创建静态分支。 使用此功能构建自己的Shader LOD系统。 还为DOTS动画增加了对顶点蒙皮的支持,使您可以创作更好的水和树叶。 此外,s 尖刻的注释使您可以为项目的任何人留下评论和解释,从而改善了工作流程。 最后, 过程模式子图样本 显示了如何使用数学来创建过程形状和模式。

-

Please share your feedback in the Shader Graph forum!

请在“ Shader Graph” 论坛上 分享您的反馈

翻译自: https://blogs.unity3d.com/2019/11/20/normal-map-compositing-using-the-surface-gradient-framework-in-shader-graph/

shader graph

shader graph_在Shader Graph中使用表面梯度框架进行法线贴图合成相关推荐

  1. shader 获取法线_Unity Shader 入门到改行5——法线贴图

    the best of blur 1. 法线贴图理论 1.1 什么是法线贴图 一般的贴图中存储的是表面颜色值(RGBA),而法线贴图存放的则是法线信息(xyzw),假设某顶点处的 uv 坐标为 (u, ...

  2. Normal map (Bump mapping) 法线贴图(凹凸映射) Standard Shader系列10

    Normal map (Bump mapping) 法线贴图(凹凸映射) 本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>) 仅作为个人学习使用,不得作为商业用途,欢迎转 ...

  3. Unity Shader法线贴图(Normal Map)及其原理

    简介 以前经常听说"模型不好看啊,怎么办啊?"答曰"加法线","做了个高模,准备烘一下法线贴图","有的美术特别屌,直接画法线贴图 ...

  4. Unity 法线贴图、高光贴图、Cube Map shader

    Unity 相关纹理贴图 写unity shader有些时候了,出于寂寞,拿出来晒晒吧!!!! 先看一下Unity 法线贴图.高光贴图.Cube Map shader最终效果: 说老实话,我不怎么喜欢 ...

  5. Unity中的法线贴图、漫反射及高光

    我们都知道,一个三维场景的画面的好坏,百分之四十取决于模型,百分之六十取决于贴图,可见贴图在画面中所占的重要性.在这里我将列举一些贴图,并且初步阐述其概念,理解原理的基础上制作贴图,也就顺手多了. 我 ...

  6. shader graph_Shader Graph中的自定义照明:在2019年扩展图形

    shader graph With the release of Unity Editor 2019.1, the Shader Graph package officially came out o ...

  7. unity 线程断点时卡机_Compute Shader在Unity和UE4中的应用

    该文档为学习文档,如有错误欢迎指正. 1. D3D11 Compute Shader概述 Compute Shader 是一个通用计算 Stage.它利用了GPU的并行处理器,实现大量线程并发执行.它 ...

  8. 图数据库 graph_通过SQL Server中的自连接了解Graph数据库相对于关系数据库的好处

    图数据库 graph Earlier this year, I published several articles on SQLShack with an aim of demonstrating ...

  9. Unity Shader - 切线空间的法线贴图应用(T2W W2T)

    法线贴图 法线贴图(或是法线纹理)其实就是一张图片中的RGB通道分别存储着法线方向的纹理(有些为了数据压缩将X,Y存储在RG通道,Z是通过1-dot(xy,xy)来近似计算). 它的由来是因为高模运行 ...

最新文章

  1. Open3D面向机器学习的扩展库
  2. 4 app版本号 swift_已开源 app 实现检查更新的简单方式
  3. windows下查看dns缓存和刷新缓存
  4. 走过的弯路,你的套路
  5. Java8新特性总结 - 2.Optional类
  6. 用恋爱常识来解释编程术语
  7. html5 audio js控制进度,HTML5 audio标签使用js进行播放控制实例
  8. CentOS中恢复rm命令误删文件
  9. git学习(三)分支管理
  10. 通过计划任务使FlashFXP在晚上自动下载备份
  11. Log4net PatternLayout 参数
  12. 关于MAC中anaconda下python版本的问题
  13. JVM学习笔记 -- 从一段几乎所有人代码都会犯错的代码开始
  14. 《算法第四版》环境搭建
  15. Star CCM+ 2206安装
  16. VSCode 中常用的 PHP 编程插件
  17. springboot打jar包部署在linux(阿里云)服务器上项目启动成功但页面访问时提示无法访问此网站
  18. 使用腾讯云sms实现短信验证功能
  19. 用ARIMA模型做需求预测
  20. java生成二维码并导入excel中

热门文章

  1. Excel一个单元格中输入度分秒转换成小数(如256.3246(读256度32分46秒))
  2. java物业管理系统设计_JAVA版物业管理系统论文+设计源码
  3. Excel 如何将数字1显示为001?
  4. windows查看端口占用命令
  5. random和urandom的区别
  6. 基于stm32的无人机控制系统设计
  7. PaddleDetection进行路标检测
  8. Apache Apisix 安全漏洞(CVE-2020-13945)
  9. SPSS聚类分析(含k-均值聚类,系统聚类和二阶聚类)
  10. 简约木板背景论文答辩PPT模板