Zh/Adapting PBR Textures to Source: Difference between revisions

From Valve Developer Community
< Zh
Jump to navigation Jump to search
(Translation by myself :))
 
No edit summary
Line 11: Line 11:
== 分析 ==
== 分析 ==


First of all, it's helpful to figure out what Source and PBR do and the difference between them. Essentially, the traditional method, including Source's, is about the resulted rendering; PBR textures on the other hand is about the physics of the material, and the resulted rendering is predictable with human sense.
首先,了解起源引擎和PBR的做法及其区别是很有帮助的。本质上讲,包括起源引擎在内的传统方法针对的是渲染结果;而PBR纹理针对的则是材质的物理性质,然后通过人类的理解去推测渲染结果。


In specific, Source materials contain the following three layers:
具体而言,起源引擎的材质包含以下三个层次:


* [[Albedo]]
* [[Albedo|漫反射贴图]]
* [[$envmapmask|Specular map]]
* [[$envmapmask|镜面反射贴图]]
* [[Bump map|Normal map]]
* [[Bump map|法线贴图]]


The logic is simple. The total reflectivity of a surface is decomposed into two types: diffuse and specular, represented by the albedo and specular map, respectively. The normal map represents the local bumping.
这种逻辑很简单。一个表面的总反射率被分解为两个类别:漫反射和镜面反射,分别由漫反射贴图和镜面反射贴图来表示。法线贴图表示的是局部的凹凸。


PBR texture arts vary depending on providers. Apparently each texturist has their own approach, but a typical setting for non-metal textures include:
PBR纹理技艺因提供者而异。显然每位纹理家都有各自的做法,但非金属纹理的设定通常包括:


* Albedo (also called base color or diffuse map)
* 漫反射贴图(又称基本颜色)
* AO (for [[$ambientocclusion|ambient occlusion]])
* AO(即[[$ambientocclusion|环境光遮蔽]]
* Displacement map (also called [[heightmap]])
* 位移贴图(又称[[heightmap|高度贴图]]
* Roughness map (or glossiness/smoothness map)
* 粗糙度贴图(或者光滑度贴图)
* Normal map
* 法线贴图


For textures with metalness, an additional type of map, either specular map or metalness map, is used. The key is to understand what effects each map has on diffuse and specular reflectivity so that they can be simulated.
有金属性的纹理会使用一种附加的贴图,要么是镜面反射贴图,要么是金属度贴图。关键在于理解每个贴图对漫反射率和镜面反射率的影响,然后才能把它模仿出来。


== 非金属 ==
== 非金属 ==


For non-metallic materials, all we need is to construct a series of functions to convert the five maps of PBR to the three maps of Source.
对于非金属材料,我们只需要建立一系列函数,把PBR的五张贴图转换成起源引擎的三张贴图。


=== 法线贴图 ===
=== 法线贴图 ===
Line 41: Line 41:
:; normal<sub>Source</sub> = normal<sub>PBR</sub>  
:; normal<sub>Source</sub> = normal<sub>PBR</sub>  


=== Displacement Map ===
=== 位移贴图 ===


This shows the displacement or height of the surface. The information should have been addressed by the normal map, so it's probably alright to drop it. Alternatively, especially when AO isn't present, the displacement map may be baked into the albedo or the blue channel of the normal map. Let it screen, multiply, or overlay the other layer with opacity no more than 25%.  
This shows the displacement or height of the surface. The information should have been addressed by the normal map, so it's probably alright to drop it. Alternatively, especially when AO isn't present, the displacement map may be baked into the albedo or the blue channel of the normal map. Let it screen, multiply, or overlay the other layer with opacity no more than 25%.  
Line 61: Line 61:
Try letting it multiply the albedo with about 50% opacity.  
Try letting it multiply the albedo with about 50% opacity.  


=== Roughness Map ===
=== 粗糙度贴图 ===


The roughness map is a tricky one because it has to do with both diffuse and specular reflectivity. A rough surface reflects less specular light compensated by more diffuse light, and vice versa. The law of energy conservation applies, meaning that
The roughness map is a tricky one because it has to do with both diffuse and specular reflectivity. A rough surface reflects less specular light compensated by more diffuse light, and vice versa. The law of energy conservation applies, meaning that

Revision as of 05:13, 28 September 2019

English (en)中文 (zh)Translate (Translate)
Under construction.png
This page is actively undergoing a major edit.
As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.

近年来,基于物理渲染的(PBR)纹理及其相关工作流程已经成为最新的行业标准。起源引擎由于年代久远而无法利用之,结果无缘于最新、最优秀的纹理技艺。为了使起源引擎继续发挥余热,我们要求这些纹理适应起源引擎的实现。

目前,网上很难找到正式的研究,但依然可以凭经验推出一套转换公式。本教程就是一个尝试。

本教程针对的是固体材质,所以略过了比较复杂的冯氏贴图。确保你有一个图像处理程序来做这些转换。

分析

首先,了解起源引擎和PBR的做法及其区别是很有帮助的。本质上讲,包括起源引擎在内的传统方法针对的是渲染结果;而PBR纹理针对的则是材质的物理性质,然后通过人类的理解去推测渲染结果。

具体而言,起源引擎的材质包含以下三个层次:

这种逻辑很简单。一个表面的总反射率被分解为两个类别:漫反射和镜面反射,分别由漫反射贴图和镜面反射贴图来表示。法线贴图表示的是局部的凹凸。

PBR纹理技艺因提供者而异。显然每位纹理家都有各自的做法,但非金属纹理的设定通常包括:

  • 漫反射贴图(又称基本颜色)
  • AO(即环境光遮蔽
  • 位移贴图(又称高度贴图
  • 粗糙度贴图(或者光滑度贴图)
  • 法线贴图

有金属性的纹理会使用一种附加的贴图,要么是镜面反射贴图,要么是金属度贴图。关键在于理解每个贴图对漫反射率和镜面反射率的影响,然后才能把它模仿出来。

非金属

对于非金属材料,我们只需要建立一系列函数,把PBR的五张贴图转换成起源引擎的三张贴图。

法线贴图

The normal mapping technique hasn't changed in the slightest all these years, so it may be taken to Source as-is. It still varies case by case whether it should have its green channel inverted; that has nothing to do with PBR, though.

normalSource = normalPBR

位移贴图

This shows the displacement or height of the surface. The information should have been addressed by the normal map, so it's probably alright to drop it. Alternatively, especially when AO isn't present, the displacement map may be baked into the albedo or the blue channel of the normal map. Let it screen, multiply, or overlay the other layer with opacity no more than 25%.

If that loose advice doesn't make sense to you, just try:

albedoSource = multiply ((12.5%) displacementPBR, albedoPBR)

AO

This determines the reflectivity of ambient light. Not supported for brushes in Source, it has to be baked into the albedo. Supposedly it should multiply the albedo, but with high opacity the result can be gloomy. An opacity of 25% is a good starting point.

albedoSource = multiply ((25%) AOPBR, albedoSource)

An alternative way is to level it up before blending, as shown in picture.

Leveling the AO of a PBR texture before baking it into the albedo

Try letting it multiply the albedo with about 50% opacity.

粗糙度贴图

The roughness map is a tricky one because it has to do with both diffuse and specular reflectivity. A rough surface reflects less specular light compensated by more diffuse light, and vice versa. The law of energy conservation applies, meaning that

diffuse + specular = constant

In practice there's no human way to balance that equation, so some creative mind is useful. Inverting and applying a curve to the roughness map may give a satisfactory result for the specular map:

specularSource = curve (1 - roughnessPBR, 128 > 16)) in sRGB

where the curve looks like this:

Curve to turn inverted roughness map to specular map

An interesting result of the function is that roughness higher than 64% sRGB will render zero specular reflectivity. Most of such textures are for coarse earth, fabric, concrete, etc. In Source convention, these materials generally don't have a specular map indeed.

Instead, it may be favorable to increase diffuse reflectivity for such rough surfaces. One possible solution is:

albedoSource = dodge ((25%) curve (roughnessPBR, 127 > 0, 191 > 16, 255 > 64), albedoSource) in sRGB

where the curve looks like this:

Curve to turn the roughness map into a mask on albedo

金属

Metallic materials in this context are rare because most metals seen in the real world are oxidized or painted, which fall into the non-metal category. They don't have a bare metallic surface. Yet certain ceramics can have an extent of metalness as in some texture samples.

The following example shows a tile texture with homogeneous roughness overall but varying specular reflectivity. The lighter area in specular map represents increased metalness.

Ceramic texture example showing varying metalness

That increased metalness supposedly brings higher specular reflectivity. Hence, an additional function may be applied besides the steps above.

specularSource = screen (specularPBR, specularSource)

As for the rare, bare metal, its diffuse reflectivity is almost zero in reality. The perceived color is almost solely contributed by specular reflection. In Source, however, only diffuse reflection can be received by other surfaces in both diffuse and specular forms. Specular reflection can only be received by other surfaces in the same form, and even that requires running buildcubemaps multiple times. If you don't feel like messing with buildcubemaps and auxilliary lighting everywhere around the level, it's still recommended to take their perceptual color as albedo, just as non-metals. The distinction between metals and non-metals should be minimal, if any.

So if the texture has an albedo almost black, the idea is to light it with the specular map. Other processes should be similar to non-metals.

结论

至此,你应该已经有办法为起源引擎制备漫反射贴图、镜面反射贴图和法线贴图了。之后,你可能想要用老办法创建材质

Template:Note:zh-cn

本教程的公式是要给出比较中庸的风格,所以在一些特殊情况下不好用并不奇怪。笔者鼓励你自行尝试。实际上,更常见的是调整纹理以适应你的地图,而非试图重现原貌。

参见