令PBR纹理适应起源引擎

From Valve Developer Community
< Zh
Revision as of 18:49, 26 September 2019 by FloraC (talk | contribs) (Translation by myself :))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
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)纹理及其相关工作流程已经成为最新的行业标准。起源引擎由于年代久远而无法利用之,结果无缘于最新、最优秀的纹理技艺。为了使起源引擎继续发挥余热,我们要求这些纹理适应起源引擎的实现。

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

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

分析

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.

In specific, Source materials contain the following three layers:

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:

  • Albedo (also called base color or diffuse map)
  • AO (for ambient occlusion)
  • Displacement map (also called 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.

法线贴图

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

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%.

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.

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

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

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

参见