Basic Theory of Physically-Based Rendering

Basic Theory of Physically-Based Rendering

基于物理渲染的基础理论

By Jeff Russell

Physically-based rendering (PBR) is an exciting, if loosely defined, trend in real time rendering lately. The term is bandied about a lot, often generating confusion as to what exactly it means. The short answer is: “many things”, and “it depends”, which is rather unsatisfying, so I have taken it upon myself to try to explain at some length what PBR represents and how it differs from older rendering methods. This document is intended for non-engineers (artists most likely), and will not present any mathematics or code.

基于物理渲染(PBR)是近年来在实时渲染上一个令人兴奋的趋势。这个术语已经传播得很广泛,但对于它究竟是什么,通常会造成一些困惑。简单的回答是:“代表很多”,和“基于实际的情况”,这会让人更不满意,所以我决定尝试详细说明PBR代表什么和它与旧的渲染方法的区别。这个文档主要为非工程师准备,而且不会呈现数学概念和公式。

Much of what makes a physically-based shading system different from its predecessors is a more detailed reasoning about the behavior of light and surfaces. Shading capabilities have advanced enough that some of the old approximations can now be safely discarded, and with them some of the old means of producing art. This means both the engineer and the artist should understand the motivations for these changes.

We’ll have to start with some of the basics so that they are well defined before we begin to highlight what is new, but if you’ll bear with me through the parts you may already know I think you’ll find it well worth the read. You may then want to also check out our own Joe Wilson’s article on creating PBR artwork.

让基于物理的着色系统不同于它的前任的原因是它提供更详细的光与表面的行为。着色能力已经足够进步以致于某些旧的近似着色方式能够安全地抛弃,顺带地使用这种旧的着色方式生成的美术资源也能够放弃了。这意味着工程师和艺术师应该理解这些改变的动机。

我们将会以基础的概念开始以使我们能够着眼什么东西是新的,但你需要忍受一下,当你已经理解了这些概念的时候,我认为你这些忍受是是值得的。

Diffusion & Reflection

Diffusion and reflection – also known as “diffuse” and “specular” light respectively – are two terms describing the most basic separation of surface/light interactions. Most people will be familiar with these ideas on a practical level, but may not know how they are physically distinct.

Diffusion和Reflection(通常指diffuse和specular)是两个描述最基础的表面和光交互的术语。大部分人都会在实践中对这两个术语有所了解,但可能并不熟悉他们在物理属性上的区别。

When light hits a surface boundary some of it will reflect – that is, bounce off – from the surface and leave heading in a direction on the opposing side of the surface normal. This behavior is very similar to a ball thrown against the ground or a wall – it will bounce off at the opposite angle. On a smooth surface this will result in a mirror-like appearance. The word “specular”, often used to describe the effect, is derived from the latin for “mirror” (it seems “specularity” sounds less awkward than “mirrorness”).

当光照射到表面时,它会从表面上被反射,并且会基于表面的法线,在照射的反方向反射出表面。这种行为与球击中墙壁或者地板后,以反方向反弹十分类似。在一个光滑的平面上,它的结果就是类似于镜面的现象。specular通常用来描述这个效果,这是一个从拉丁文中继承过来的,意思和镜子一样。(specularity听起来比mirrorness更好)

Not all light reflects from a surface, however. Usually some will penetrate into the interior of the illuminated object. There it will either be absorbed by the material (usually converting to heat) or scattered internally. Some of this scattered light may make its way back out of the surface, then becoming visible once more to eyeballs and cameras. This is known by many names: “Diffuse Light”, “Diffusion”, “Subsurface Scattering” – all describe the same effect.

然而,并不是所有光都会从表面上反射出来。通常来说,一些光线会浸透到被照射的物体内部。光线将会被材质吸收(通常会转化为热能)或者在内部被散射。那些在物体内部被散射的光线有可能会再被散射出物体的表面,然后一旦进入到眼睛或者摄像机就会被看到。这就是所谓的“Diffuse Light", "Diffusion", "Subsurface Scattering",都是用来描述这个效果的。

The absorption and scattering of diffuse light are often quite different for different wavelengths of light, which is what gives objects their color (e.g. if an object absorbs most light but scatters blue, it will appear blue). The scattering is often so uniformly chaotic that it can be said to appear the same from all directions – quite different from the case of a mirror! A shader using this approximation really just needs one input: “albedo”, a color which describes the fractions of various colors of light that will scatter back out of a surface. “Diffuse color” is a phrase sometimes used synonymously.

吸收和散射diffuse light会因为光中包含不同的波长的光会有不同的现象,这就会让物体出现颜色(例如,如果一个物体吸收大量的光,但会散射出蓝色,那么它看起来就是蓝色的)。散射光通常都是大量的、混沌的,而总体上看又像是同一个方向的,与镜子的情况十分不一样。着色器使用这种近似的方式通常只需要一个输入:“反射率(albedo)”。

Translucency & Transparency

半透明和透明

In some cases diffusion is more complicated – in materials that have wider scattering distances for example, like skin or wax. In these cases a simple color will usually not do, and the shading system must take into account the shape and thickness of the object being lit. If they are thin enough, such objects often see light scattering out the back side and can then be called translucent. If the diffusion is even lower yet (in for example, glass) then almost no scattering is evident at all and entire images can pass through an object from one side to another intact. These behaviors are different enough from the typical “close to the surface” diffusion that unique shaders are usually needed to simulate them.

在某些情况下,diffusion会更为复杂。例如,在有更广泛散射距离的材质中,像皮肤和蜡。在这些情况下,简单的color通常是不合适的,所以着色系统必须考虑到被照射的物体的形状和厚度。如果它们足够薄,这些物体通常能够从背面看到光的散射,这被叫做半透明。如果物体的散射程度比较低(如玻璃),那么几乎没有散射可以看到,因此整个背景都能够同过这个物体从一边看到另一边。这种行为足够区分开传统的“靠近表面(K:这个没有翻译准确)”散射,以至于统一的着色起通常需要模拟他们。

Energy Conservation

能量守恒

With these descriptions we now have enough information to draw an important conclusion, which is that reflection and diffusion are mutually exclusive. This is because, in order for light to be diffused, light must first penetrate the surface (that is, fail to reflect). This is known in shading parlance as an example of “energy conservation”, which just means that the light leaving a surface is never any brighter than that which fell upon it originally.

通过这些描述,我们现在已经有足够的信息得出一个重要的结论,那就是reflection和diffusion是相互排斥的。这是因为,为了光能够散射,光必须先渗透到表面(这就是说,不能够反射)。在着色领域下,这就是所谓的"能量守恒",意思是光线离开表面的时候,不再和它原来照射到表面上那么亮了。


This is easy to enforce in a shading system: one simply subtracts reflected light before allowing the diffuse shading to occur. This means highly reflective objects will show little to no diffuse light, simply because little to no light penetrates the surface, having been mostly reflected. The converse is also true: if an object has bright diffusion, it cannot be especially reflective.

这是很容易被着色系统所实现的:在diffuse着色之前,简单地减去反射的光线。这表明高度反射的物体将只会现实很少甚至没有diffuse。反过来也是对的:如果一个物体有很亮的diffusion,它不可能有特别强烈的反射。


Energy conservation of this sort is an important aspect of physically-based shading. It allows the artist to work with reflectivity and albedo values for a material without accidentally violating the laws of physics (which tends to look bad). While enforcing these constraints in code isn’t strictly necessary to producing good looking art, it does serve a useful role as a kind of “nanny physicist” that will prevent artwork from bending the rules too far or becoming inconsistent under different lighting conditions.

这种类型的能量守恒是基于物理着色的很重要的一个方面。它允许美术师处理一个材质的时候,使用reflectivity和albedo的值而不会意外地违反物理定律(这往往会看上去很糟糕)(K:reflectivity和albedo都是反射率的意思,而reflectivity是指高光的反射率而albedo指的是散射光的反射率)。在编码的时候,强制执行这些约束并不是产生出更好看的艺术效果的必然条件,但它扮演着一种如"nanny physicist"的角色,这种角色将会避免艺术工作偏离这个规律太远或者逐渐变成在不同光照条件下变得不一致。

Metals

金属

Electrically conductive materials, most notably metals, are deserving of special mention at this point for a few reasons.

电子导电材质,通常如金属,由于某些条件是值得特别注意的。

Firstly, they tend to be much more reflective than insulators (non-conductors). Conductors will usually exhibit reflectivities as high as 60-90%, whereas insulators are generally much lower, in the 0-20% range. These high reflectivities prevent most light from reaching the interior and scattering, giving metals a very “shiny” look.

首先,比起绝缘体(非导体)他们具有更高的反射。导体通常会显示出高达60%~90%的反射,然而绝缘体通常会更低,在0~20%的范围。这些高反射阻止大部分光到达物体的内部并发生散射,让金属看起来非常有光泽。

Secondly, reflectivity on conductors will sometimes vary across the visible spectrum, which means that their reflections appear tinted. This coloring of reflection is rare even among conductors, but it does occur in some everyday materials (e.g. gold, copper, and brass). Insulators as a general rule do not exhibit this effect, and their reflections are uncolored.

其次,导体的反射有时候在可见光谱中是不一样的,意味着它们的反射会出现彩色光带。然而在导体之间,反射的彩色带是罕见的,但它确实出现在日常的材质中(例如,黄金,铜和黄铜)。绝缘体一般来讲并没有这种效果,他们的反射是没有彩色光带的。

Finally, electrical conductors will usually absorb rather than scatter any light that penetrates the surface. This means that in theory conductors will not show any evidence of diffuse light. In practice however there are often oxides or other residues on the surface of a metal that will scatter some small amounts of light.

最后,导电体通常会将穿透到体内的光线进行吸收而不是散射。这意味着,理论上导体是不会显示出任何可见的diffuse light。在现实中,由于它们通常都会参杂一些氧化物或者其他一些残留的物体在表面上,所以还是会散射很少一部分的光线。

It is this duality between metals and just about everything else that leads some rendering systems to adopt “metalness” as a direct input. In such systems artists specify the degree to which a material behaves as a metal, rather than specifying only the albedo & reflectivity explicitly. This is sometimes preferred as a simpler means of creating materials, but is not necessarily a characteristic of physically-based rendering.

这是金属和金属以外物体的二元性,导致很多渲染系统都采用“金属镀”作为一个直接的输入。在这些系统中,艺术师指定对应的值到相应的材质中以表示为金属,而不是显式地指定albedo和reflectivity。有时候这是一种更受欢迎的易于用于创建金属的方法,但在基于物理的渲染中却不是必要的属性。

Fresnel

菲涅尔效应

Augustin-Jean Fresnel seems to be one of those old dead white guys we are unlikely to forget, mainly because his name is plastered on a range of phenomena that he was the first to accurately describe. It would be hard to have a discussion on the reflection of light without his name coming up.

Augustin-Jean Fresnel就像那些我们并不想忘记的old dead white guys,主要是因为他的名字已经和一系列现象黏上关系,这些现象是他第一个精确描述的。在讨论光的反射的时候很难不和他的名字带上关系。

In computer graphics the word Fresnel refers to differing reflectivity that occurs at different angles. Specifically, light that lands on a surface at a grazing angle will be much more likely to reflect than that which hits a surface dead-on. This means that objects rendered with a proper Fresnel effect will appear to have brighter reflections near the edges. Most of us have been familiar with this for a while now, and its presence in computer graphics is not new. However, PBR shaders have made popular a few important corrections in the evaluation of Fresnel’s equations.

在计算机图形学中,Fresnel指的是不同的角度下不同的反射率。特别地,光线以一个入射余角照射到一个表面上时比光线直接照射到表面上的情况会更容易会发生发射。这表示,物体渲染一个正确的Fresnel效果的时候,在临近这个入射余角的边界时会出现更亮的反射。我们都已经习惯于这行现象,而且它对于计算机图形学来讲也不陌生。然而,PBR着色器会添加一小部分重要的修正到Fresnel计算公式中。

The first is that for all materials, reflectivity becomes total for grazing angles – the “edges” viewed on any smooth object should act as perfect (uncolored) mirrors, no matter the material. Yes, really – any substance can act as a perfect mirror if it is smooth and viewed at the right angle! This can be counterintuitive, but the physics are clear.

首先,对于所有的材质来讲,在入射余角中反射率会达到最大——观察任何光滑物体的边缘都能够看到完美的镜面反射效果,不管是什么材质。任何的物体都可以表现得像一个完美的镜子只要它是光滑的和在正确的角度上观察!这是违反感知的,但这其中的物理是清晰的。

The second observation about Fresnel properties is that the curve or gradient between the angles does not vary much from material to material. Metals are the most divergent, but they too can be accounted for analytically.

关于Fresnel属性的第二个现象是不同材质的反射率/角度曲线不会变化很大。金属有最大的不一致,但他们也是可以分析的。

What this means for us is that, assuming realism is desired, artist control over Fresnel behavior should generally be reduced, rather than expanded. Or at the very least, we now know where to set our default values!

对于我们的来讲,假定希望获得真实的效果,艺术师控制Fresnel的行为应该减少而不是增加。或者至少,我们现在知道怎么设置相应的默认值。

This is good news of a sort, because it can simplify content generation. The shading system can now handle the Fresnel effect almost entirely on its own; it has only to consult some of the other pre-existing material properties, such as gloss and reflectivity.

这是一个好消息,因为它能够简化内容的生成。着色系统现在几乎可以完整地处理Fresnel效果。它只需要查阅一些预先已经存在的材质属性,如光泽度和反射率。

A PBR workflow has the artist specify, by one means or another, a “base reflectivity”. This provides the minimum amount and color of light reflected. The Fresnel effect, once rendered, will add reflectivity on top of the artist specified value, reaching up to 100% (white) at glancing angles. Essentially the content describes the base, and Fresnel’s equations take over from there, making the surface more reflective at various angles as needed.

一个PBR的工作流程需要艺术师通过各种方式指定一个"基础反射率"(K:前面提到的reflectivity和albedo)。这提供了最少的数量和反射光的颜色(K:这里翻译得不准确)。Fresnel效果会在入射余角达到100%的时候会添加艺术师指定的反射率。本质上这些内容描述了让表面在不同的角度下更具有反射性的基础,而这些都可以由Fresnel公式接管。

There is one big caveat for the Fresnel effect – it quickly becomes less evident as surfaces become less smooth. More information on this interaction will be given a bit later on.

对于Fresnel效果的警告是,随着表面变得不再平滑后效果就会变得越不明显。将会在后面提供更多相关的信息。

Microsurface

微表面

The above descriptions of reflection and diffusion both depend on the orientation of the surface. On a large scale, this is supplied by the shape of the mesh being rendered, which may also make use of a normal map to describe smaller details. With this information any rendering system can go to town, rendering diffusion and reflection quite well.

前面描述的反射和散射都是基于表面的朝向的。在大规模的场景中,这是通过正在渲染的网格形状提供的,它可能也利用了normal map来描述表面更细的细节。伴随着这些信息,任何的渲染系统都可以迅速有效地渲染diffusion和reflection。

However, there is one big piece still missing. Most real-world surfaces have very small imperfections: tiny grooves, cracks, and lumps too little for the eye to see, and much too small to represent in a normal map of any sane resolution. Despite being invisible to the naked eye, these microscopic features nonetheless affect the diffusion and reflection of light.

然而,还有一个重要的地方仍然缺少。大部分真实世界的表面都有很少的瑕疵:微小的凹槽,刮痕和结块太小而不能让眼睛看见,并且有很多都太小以致于一个合理分辨率的normal map都无法显示。尽管裸眼并不能看到,这些细微的特性仍然会影响到光的散射和反射。

Microsurface detail has the most noticeable effect on reflection (subsurface diffusion is not greatly affected and won’t be discussed further here). In the diagram above, you can see parallel lines of incoming light begin to diverge when reflected from a rougher surface, as each ray hits a part of the surface with a different orientation. The analog in the ball/wall analogy would be a cliffside or something similarly uneven: the ball is still going to bounce off but at an unpredictable angle. In short, the rougher the surface gets, the more the reflected light will diverge or appear “blurry”.

微表面细节最容易在反射效果中被主要到(次表面散射不会有很大的影响而且我们不会在这里讨论)。在上图中,你可以看到平行的入射光线开始偏离当从一个粗糙的表面上反射回来的时候,因为每个光线都会以不同的角度与一部分表面碰撞。这可以通过一个球体和凹凸不平的峭壁碰撞来模拟解析:球体依然会反弹回来,但会以一个不能预测的角度。简单来讲,表面越是粗糙反射光线就越是容易偏离或者出现模糊。

Unfortunately, evaluating each microsurface feature for shading would be prohibitive in terms of art production, memory use, and computation. So what are we to do? It turns out if we give up on describing microsurface detail directly and instead specify a general measure of roughness, we can write fairly accurate shaders that produce similar results. This measure is often referred to as “Gloss”, “Smoothness”, or “Roughness”. It can be specified as a texture or as a constant for a given material.

很不幸地,计算每个用于着色的微表面特性是禁止的,原因在于美术的效率,内存的使用和计算量。So,我们能够怎样做呢?结论是如果我们放弃直接描述微表面细节转而指定一个通用的粗糙度,我们可以简单地写出精确的着色器得出类似的效果。这个衡量的方法通常叫做“光泽度”,“平滑度”或者“粗糙度”。它可以在一个材质中通过一个纹理或者一个常量进行指定。

This microsurface detail is a very important characteristic for any material, as the real world is full of a wide variety of microsurface features. Gloss mapping is not a new concept, but it does play a pivotal role in physically-based shading since microsurface detail has such a big effect on light reflection. As we will soon see, there are several considerations relating to microsurface properties that a PBR shading system improves upon.

由于在真实世界中充满着广泛的微表面特性,对于任何的材质来讲,微表面细节是一个非常重要的特性。光泽贴图不是一个新概念,但它在基于物理着色中扮演着一个重要的角色,原因是微表面细节会对光的反射产生重要的影响。我们很快会看到,PBR着色系统会基于微表面属性相关的几个条件带来提升。

Energy Conservation (Again)

能量守恒(Again)

As our hypothetical shading system is now taking microsurface detail into account, and spreading reflected light appropriately, it must take care to reflect the correct amount of light. Regrettably, many older rendering systems got this wrong, reflecting too much or too little light, depending on the microsurface roughness.

对于我们假想的着色系统现在已经考虑了微表面细节,并且正确地传播反射光线,它必须处理好反射光的总量。遗憾的是,很多老的渲染系统会在这方面出错,基于微表面的粗糙度,反射太多或者太少的光线。

When the equations are properly balanced, a renderer should display rough surfaces as having larger reflection highlights which appear dimmer than the smaller, sharper highlights of a smooth surface. It is this apparent difference in brightness that is key: both materials are reflecting the same amount of light, but the rougher surface is spreading it out in different directions, whereas the smoother surface is reflecting a more concentrated “beam”:

当公式已经被调整到适当的平衡后,渲染器应该在显示粗糙的表面上有更大范围的反射高光并且会出现相应的衰减,这区别于平滑表面上范围更小,更尖锐的高光。这种在表面上看到的亮度不一致是关键所在:两种材质都反射相同数量的光线,但粗糙的表面会传播到更广泛的不同方向,然而平滑表面会反射出更聚焦的光线。

Here we have a second form of energy conservation that must be maintained, in addition to the diffusion/reflection balance described earlier. Getting this right is one of the more important points required for any renderer aspiring to be “physically-based”.

这里我们有第二种形式的能量守恒必须维持,加上之前描述到的diffusion/reflection。将这方面做对,对于任何有抱负的基于物理的渲染起都是其中更重要的一个方向。

All Hail Microsurface


And it is with the above knowledge that we come to a realization, a big one actually: microsurface gloss directly affects the apparent brightness of reflections. This means an artist can paint variations directly into the gloss map – scratches, dents, abraded or polished areas, whatever – and a PBR system will display not just the change in reflection shape, but relative intensity as well. No “spec mask”/reflectivity changes required!

在了解到上面的知识后,我们开始认识到:微表面光泽直接影响到表面上的反射光线的亮度。这表明艺术师可以直接绘制各种类型到光泽贴图中,这些类型包括如刮痕,凹陷,刮檫或者光亮的区域甚至更多——然后一个PBR的系统不但会在反射模型中显示相应的变化,而且对相应的强度也产生影响。没有任何的spec mask/反射率需要改变。

This is significant because two real world quantities that are physically related – microsurface detail and reflectivity – are now properly tied together in the art content and rendering process for the first time. This is much like the diffusion/reflection balancing act described earlier: we could be authoring both values independently, but since they are related, the task is only made more difficult by attempting to treat them separately.

这是重要的因为两个真实世界的变量是基于物理的—微表面细节和反射率—现在美术内容和渲染处理第一次以恰当的形式捆绑在一起。这很像之前描述到的diffusion和reflection的平衡一样:我们能够单独处理这两个变量,但自从将他们相关联起来后,尝试单独处理它们就会变得困难。

Further, an investigation of real world materials will show that reflectivity values do not vary widely (see the earlier section on conductivity). A good example would be water and mud: both have very similar reflectivity, but since mud is quite rough and the surface of a puddle is very smooth, they appear very different in terms of their reflections. An artist creating such a scene in a PBR system would author the difference primarily through gloss or roughness maps rather than adjusting reflectivity, as shown below:

更甚,在对现实世界的材料的研究中显示出反射率并不会出现非常大的不一样(看看之前关于导体的章节)。一个好的例子是水和泥土:它们都具有类似的反射率,但因为泥土相对更粗糙而水坑的表面非常平滑,它们在反射效果上有很大的不一致。艺术师在一个PBR系统中创建场景的时候,主要使用光泽或粗糙贴图,而不是通过调整反射率来让两种材质显得不一致,就如下面显示的:

Microsurface properties have other subtle effects on reflection as well. For example, the “edges-are-brighter” Fresnel effect diminishes somewhat with rougher surfaces (the chaotic nature of a rough surface ‘scatters’ the Fresnel effect, preventing the viewer from being able to clearly resolve it). Further, large or concave microsurface features can “trap” light – causing it to reflect against the surface multiple times, increasing absorption and reducing brightness. Different rendering systems handle these details in different ways and to different extents, but the broad trend of rougher surfaces appearing dimmer is the same.

微表面属性在反射上还有其他的细微效果。例如,在“边沿更亮”的Fresnel效果在粗糙表面会减少一些(粗糙表面的混沌属性“散射”Fresnel效果,阻止观察者能够清晰地观察到)。再者,大的或者凹陷的微表面能够“困住”光线—导致光线在表面上多次反射,增加了物体对光的吸收和减低了反射的亮度。不同的渲染系统使用不同的方法和范围处理这些细节,但对于粗糙表面出现的范围衰减处理的趋势是一致的。

Conclusion

结论

There is of course much more to say on the topic of physically-based rendering; this document has served only as a basic introduction. If you haven’t already, read Joe Wilson’s tutorial on creating PBR artwork. For those wanting more technical information, I could recommend several readings:

这当然还有很多关于基于物理渲染的内容;这个文档只是介绍基础为目的。如果你还没有准备好,在creating PBR artwork读一下Joe Wilson's的教程。为了那些想获取更多技术信息的,我会推荐下面几个阅读内容:

If there are any burning questions still left unanswered, I can usually be reached on twitter.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值