THE PBR GUIDE - PART 1——Light and Matter : The theory of Physically-Based Rendering and Shading

https://academy.substance3d.com/courses/the-pbr-guide-part-1

the theory of physical-based rendering and shading

light is a complex phenomenon as it can exhibit properties of both a wave and a particle. as a result, different models have been created to describe its behaviour.

as texture artists, we are interested in the ray model of light as it describes the interaction of light and matter. understanding how light rays interact with surface matter is important because our job is to create textures that describe a surface. the textures and materials we author ineract with light in our virtual world. the more we understand how light behaves, the better our textures will look.

in this guide, we will discuss the theory behind the physics of physically based rendering (PBR) models. we will start by examining the behaviour of light rays and work up to defining the key characteristic of PBR.

light rays
the ray model of light states that a light ray has the trajectory 轨迹 of a straight line in a homogenous transparent medium such as air. the ray model also says that the ray will behave in a predictable manner when encountering surfaces such as opaque objects, or when passing through a different medium such as from air to water.

this makes it possible to visualize the path of the light ray as it moves from its starting point to another point where it changes into another form of energy, such as heat.

a light ray that hits a surface is called the incident ray and the angle at which it hits is called the angle of incidence (figure 01).

在这里插入图片描述Figure 01: Angle of incidence, incident and reflected rays

a light ray is incident 入射 on a plane interface between two media. when a light ray hits a surface, one or both of the following events may occur:

  1. the light ray is reflected off the surface and travels in a different direction. it follows the law of reflection, which states the angle of reflection is equal to the angle of incidence (reflected light).
  2. the light ray passes from one medium to another in the trajectory of a straight line (refracted light).

At this point, light rays split into two directions: reflection and refraction. At the surface, the ray is either reflected or refracted, and it can be eventually absorbed by either medium. However, absorption does not occur at the surface of the material.

When traveling in an inhomogeneous medium or translucent material, light can be absorbed or scattered:
当在不均匀的介质或半透明材料中行进时,光可以被吸收或散射:
When light is absorbed, the light intensity decreases as it changes into another form of energy – usually heat. Its color changes as the amount of light absorbed depends on the wavelength, but the direction of the ray doesn’t change.

When light is scattered, the ray direction changes randomly, and the amount of deviation depends on the material. Scattering randomizes light direction, but doesn’t change its intensity. An ear is a good example of this phenomenon. The ear is thin (absorption is low), so you can see the scattered light radiating from the back of the ear, as shown in Figure 02.
在这里插入图片描述

If there is no scattering and the absorption is low, rays can pass directly through the surface. This is the case with glass. For example, imagine you are swimming in a clean pool. You can open your eyes and see a great distance through the clear water. However, if that same pool is relatively dirty, the dirt particles will scatter the light and lower the clarity of the water, and the distance you can see will be reduced as a result.

The further light travels in such a medium/material, the more it is absorbed and/or scattered. Therefore, object thickness plays a large role in how much the light is absorbed or scattered. A thickness map can be used to describe object thickness to the shader as shown in Figure 03.
在这里插入图片描述
Figure 03: Thickness map used with subsurface scattering within Substance Painte

Diffuse and Specular Reflection
Specular reflection refers to light that has been reflected at the surface, as we discussed in the light ray section. The light ray is reflected off the surface and travels in a different direction. It follows the law of reflection, which states that on a perfectly planar surface the angle of reflection is equal to the angle of incidence. However, most surfaces are irregular, and the reflected direction will vary randomly based on the surface roughness. This changes light direction, but the light intensity remains constant.

Rougher surfaces will have highlights that are larger, and that appear dimmer. Smoother surfaces will keep specular reflections focused, and they will appear to look brighter or more intense when viewed from the proper angle. However, the same total amount of light is reflected in both cases (Figure 04)
在这里插入图片描述
Figure 04: Reflected direction will vary randomly based on the surface roughness

Refraction is a change in a light ray’s direction. When light moves from one medium to another it changes speed and direction. The index of refraction, or IOR, is an optical measurement that describes the change in the direction a light ray is traveling. Essentially, the IOR value is used to determine how much the ray will be bent when it passes through one medium to another. For example, water has an IOR of 1.33, whereas plate glass has an IOR of 1.52. In figure 05 you can see a rendering of a straw placed in a glass of water. The straw appears bent due to refraction as the light travels through different mediums (air, water and glass).

在这里插入图片描述
Figure 05: The straw appears bent due to refraction

diffuse reflection is light that has been refracted. the light ray passes from one medium to another; as our example, we will assume that it enters an object. the light is then scattered multiple times wihtin this object. it is finally refracted again, out of the object, making its way back to the original medium at approximately the same point where it initially entered.
在这里插入图片描述
Figure 06: A light ray travelling from one medium to another scattering inside the object

microfacet theory
In theory, both diffuse and specular reflection are dependent on the surface irregularities where the light rays intersect with a medium. In practice however, the effect of roughness on diffuse reflection is less visible because of the scattering that occurs inside the material. As a result, the outgoing direction of the ray is fairly independent of surface roughness and the incident direction. The most common model for diffuse reflection (Lambertian) completely neglects roughness.

in this guide, we refer to these surface irregularities as surface roughness. surface irregularities can have several other names, including roughness, smoothness, glossiness or micro-surface, depending on the PBR workflow in use. all these terms describe the same aspect of a surface, which is sub-texel geometric detail.

These surface irregularities are authored in the roughness or glossiness map depending on the workflow that is being used. A physically-based BRDF is based on the microfacet theory, which supposes that a surface is composed of small-scaled planar detail surfaces of varying orientation called microfacets. Each of these small planes reflects light in a single direction based on its normal (Figure 07).

Micro-facets whose surface normal is oriented exactly halfway between the light direction and view direction will reflect visible light. However, in cases where the microsurface normal and the half normal are equal, not all microfacets will contribute as some will be blocked by shadowing (light direction) or masking (view direction) as illustrated in Figure 07.

在这里插入图片描述
Figure 07: Physically-based BRDF based on microfacet theory

The surface irregularities at a microscopic level cause light diffusion. For example, blurred reflections are caused by scattered light rays. The rays are not reflected in parallel, so we perceive the specular reflection as blurred (Figure 08).
在这里插入图片描述
Figure 08: Blurred reflections are due to scattered light rays

color
the visible color of a surface is due to the wavelengths emitted by the light source. these wavelengths are absorbed by the object and reflected both specularly and diffusely. the remaining reflected wavelengths are what we see as color.

For example, the skin of an apple mostly reflects red light. Only the red wavelengths are scattered back outside the apple skin, while the others are absorbed (Figure 09).
在这里插入图片描述
Figure 09: Red wavelengths are reflected to the eye

The apple also has bright specular highlights the same color as the light source because with materials that do not conduct electricity (dielectrics) – like the skin of an apple – specular reflection is almost independent of wavelength. For these materials, the specular reflection is never colored. We will discuss the different type of materials (metals and dielectrics) in later sections.

Substance PBR shaders use the GGX microfacet distribution.

BRDF
a bidiectional reflectance distribution functoin (BRDF) is a function that describes the reflectance properties of a surface. in computer graphics, there are different BRDF models——some of which are not physically plausible. for a BRDF to be physically playsible, it must be energy conserving and exhibit reciprocity. reciprocity refers to the helmholtz reciprocity principle, which states that incoming and outgoing light rays can be considered as reversals of each other without affecting the outcome of the BRDF.

TThe BRDF used by Substance’s PBR shaders are based on Disney’s principled reflectance model. This model is based on the GGX microfacet distribution. GGX provides one of the better solutions in terms of specular distribution: with a shorter peak in the highlight and a longer tail in the falloff, it looks more realistic (Figure 10).

在这里插入图片描述
Figure 10: GGX vs Blinn specular distribution – GGX provides one of the better solutions in terms of specular distribution

Energy Conservation
Energy conservation plays a vital role in physically-based rendering solutions. This principle states the total amount of light re-emitted by a surface (reflected and scattered back) is less than the total amount received. In other words, the light reflected from the surface will never be more intense than it was before it hit the surface. As artists, we don’t have to worry about controlling energy conservation. This is one of the advantages of PBR: energy conservation is always enforced by the shader. This is part of the physically-based model and it allows us to focus on art rather than physics.

Fresnel Effect
the fresnel reflection factor also plays a vital role in physically-based shading as a coefficient of the BRDF. the fresnel effect, as observed by french physicist augustin-jean fresnel, states that the amount of light reflected from a surface depends on the viewing angle at which it is perceived. think of a pool of water. if u look straight down, perpendicular to the water surface, u can see down to the bottom. viewing the water surface in this manner would be at zero degrees or normal incidence, normal being the surface normal. if u look at the pool of water at a grazing incidence, more parallel to the water surface, u will see that the specular reflections on the water surface become more intense and u may not be able to see below the surface of the water at wall.

fresnel is not sth. that we would in PBR as we did in traditional shading. again, this is another aspect of physics that is handled by the PBR shader. when viewing a surface at a grazing incidence, all smoothed surfaces will become reflectors at nearly 100% at a 90-degree of incidence.

for rough surfaces, reflectance will become increasingly specular but will not approach 100% specular reflection. the most important factor here is the angle between the normal of each microfacet and the light, rather than the angle between the normal of the ‘‘macrosurface’’ and the light. Because the light rays are dispersed in different directions, the reflection appears softer, or dimmer. What occurs at a macroscopic level is somewhat similar to the average of all the Fresnel Effect you would observe for the collective microfacets.

F0(fresnel reflectance at 0 degrees)
When light hits a surface straight on or perpendicularly (at a 0-degree angle), a percentage of that light is reflected as specular. Using the index of refraction (IOR) for a surface, you can derive the amount that is reflected. This is referred to as F0 (Fresnel zero) (Figure 11). The amount of light that is refracted into the surface is referred to as 1–F0.

在这里插入图片描述
Figure 11: For a smooth dielectric surface, F0 will reflect between 2-5% of light and 100% at grazing angles

The F0 range for most common dielectrics will be from 0.02-0.05 (linear values). For conductors, the F0 range will be 0.5-1.0. The reflectivity of a surface is therefore determined by the refractive index as shown in the equation below (Lagarde 2011).
在这里插入图片描述
It is the F0 reflectance value that we are concerned with in regards to authoring our textures. Non-metals (dielectrics/insulators) will have a greyscale value and metals (conductors) will have an RGB value. With regards to PBR and from an artistic interpretation of reflectance, we can state that for a common smooth dielectric surface, F0 will reflect between 2% and 5% of light and 100% at grazing angles as was shown in Figure 11.

The dielectric (non-metal) reflectance values don’t actually change very drastically. In fact, when altered by roughness the actual changes in value can be hard to see. However, there is a difference in the values. In Figure 12, you can see a chart that shows the F0 ranges for both metal and non-metal materials.

Notice that the ranges for non-metals do not deviate from each other drastically. Gemstones are an exception as they have higher values. We will discuss F0 as it specifically relates to conductors and insulators a bit later.

Conductors and Insulators (Metals and Non-Metals)
When creating materials for PBR, it is helpful to think in terms of metal or non-metal. Ask yourself if the surface is metal or not. If it is, you will need to follow one set of guidelines. If it is not, you will need to follow another.

This can be a simplistic approach as some materials may not fall into these categories such as metalloids (a mix of metal and non-metal), but in the overall process of creating materials, distinguishing between metal and non-metal is a good approach and metalloids are an exception. To set up guidelines for materials, we must first understand what we are trying to create. With PBR, we can look at the properties of metals (conductors) and non-metals (insulators) to derive this set of guidelines as shown in Figure 12.

在这里插入图片描述
Figure 12: F0 ranges for both metal and non-metal materials

Refracted light is absorbed, and the color tint of metals comes from the reflected light, so in our maps, we don’t give metals a diffuse color.

Metals
Metals are good conductors of heat and electricity. The electric field in conducting metals is zero, and when an incoming light wave made of electric and magnetic fields hits the surface, the wave is partially reflected, and all the refracted light is absorbed. The reflectance value for polished 光滑的 metal is high at a range of about 70-100% reflective (Figure 13).
在这里插入图片描述
Figure 13: The reflectance value for metal is around 70-100% specular

Some metals absorb light at different wavelengths. For example, gold absorbs blue light at the high-frequency end of the visible spectrum, so it appears yellow. However, since the refracted light is absorbed, the color tint of metals comes from the reflected light. In our maps, therefore, we don’t give metals a diffuse color. For example, in the specular/gloss workflow, raw metal is set to black in the diffuse map and the reflectance value is a tinted color value in the specular map. With metals, the reflectance value will be RGB and can be tinted. Since we are working within a physically-based model, we need to use real-world measured values for the metal reflectance in our maps.

Another important aspect of metals in terms of texturing is their tendency to corrode. This means that weathering elements can play a large role in the reflective state of metal. If the metal rusts, this changes the reflective state of the metal. The corroded areas are then treated as a dielectric material denoted by a black value in the metallic map as shown in Figure 14. As we will discuss in Part 2, the shader in the metallic/roughness workflow hardcodes the F0 value for dielectrics to be 4% reflective. Figure 14 shows the rusted areas in the base color map as diffuse reflected color with a hardcoded F0 value of 4%.

Also, painted metal is treated as a dielectric rather than a metal. The paint acts as a layer on top of the raw metal. Only the raw metal exposed from chipped paint is treated as metal. The same goes for dirt on metal or any matter that obscures the raw metal.

As noted at the beginning of this chapter, it is helpful to ask if a material is a metal or not when creating PBR materials. To be even more precise, the question should also include information about the state of the metal: whether it is painted, rusted or covered in another matter like dirt or grease. 说的更精确些,就是要知道金属的状态,比如:金属的表面是否生锈了,是否沾有灰尘或者油脂。
The material will be treated as dielectric if it is not raw metal. Depending on weathering, there could be some blending between metal and non-metal as weathering elements play a role in the reflective state of a metal. 如果不是原始的金属,那么材质将会被视为电解质 。由于风华因素,金属和非金属将会有一定的混合。

在这里插入图片描述
Figure 14: Corrosive areas 腐蚀区域 are treated as a dielectric with an F0 value of 4% reflective

Non-Metals
Non-metals (insulators/dielectrics) are poor conductors of electricity. The refracted light is scattered and/or absorbed (often re-emerging from the surface), so they reflect a much smaller amount of light than metals and will have an albedo color.
对于绝缘体,反射占了很小一部分,但部分的光被折射,而折射进物体的光,部分转化为能量,部分又再次射出表面,形成一个叫做albedo的光,即是漫反射的光。而那个很小的一部分直接被反射的光,则也是镜面光,不过很少很少。

We stated earlier that the value for common dielectrics is around 2-5% based on the F0 as computed by the index of refraction. These values are contained within the linear range of 0.017-0.067 (40-75 sRGB) as shown in Figure 14. Apart from some non-metal materials such as gemstones 宝石, most dielectrics will not have an F0 value greater than 4%.
绝缘体的反射率很小,F0一般不会超过4%

As with metals, we need to use real-world measured values, but it can be difficult to find an index of refraction (IOR) for other materials that are not transparent. However, the value between most common dielectric materials does not change drastically, so we can use a few guidelines for reflectance values. We will cover them later in this guide.

The value for common dielectrics is around 2-5% based on the F0 as computed by the IOR. You can see this range illustrated in Figure 15.

在这里插入图片描述

Figure 15: Conversions from sRGB to linear were done using the gamma 2.2 approximation – see the section on linear space rendering for more details

Linear Space Rendering
Linear space rendering is a highly complex subject. For this guide, we will take a simplistic approach in stating that linear space rendering provides the correct math for lighting calculations. It creates an environment that allows light interactions to be represented in a credible real-world manner. For a discussion on linear space rendering, we must introduce the concept of gamma correction. When encoding images for display and storage purposes, gamma correction is the optimization process of reducing bandwidth and bit allocation. This process leverages the human eye’s perception of brightness, which approximately follows the cube root of luminance.

The Human Visual System (HVS) is more sensitive to relative differences in darker tones rather than brighter tones. Because of this, not using gamma correction is wasteful as too many bits will be allocated to tonal regions where the HVS cannot distinguish between tones.

In a typical digital image creation process, the image is encoded using an encoding gamma function, such as sRGB OETF or gamma 1 / 2.2[1], for presentation on a display device. The display device circuitry then decodes the image using its own decoding gamma function, the EOTF[2]; a computer monitor will frequently have a gamma setting of 2.2.

A linear color space intrinsically has no gamma correction. This is equivalent to an effective gamma of 1.0, which yields correct linear computations. However, in order to present the rendered image correctly to the viewer, it needs to be encoded into gamma space[3].

Computations of color values and operations on colors are performed in linear space. The process decodes gamma-encoded values into linear values from our color maps, and from colors chosen while viewing on a monitor via a color picker. In a color-managed workflow, this process typically involves tagging a texture map to be interpreted either as linear or as encoded with sRGB OETF or gamma 1 / 2.2. The computations are then carried out in linear space and the final rendered result is gamma-encoded with sRGB OETF or gamma 1 / 2.2

A simplistic way of considering which maps need to be decoded is that if the map exported from Substance Painter or Substance Designer represents color that you see (diffuse reflected color) - such as the color tint of a metal or the green color of grass - then it should be flagged as gamma-encoded for the shader to interpret the map correctly. The maps to be flagged as gamma-encoded in a PBR workflow are base color, diffuse, specular and emissive. If the map represents data, such as how rough the surface is (the roughness map), or if the material is metal (the metallic map), then it should be flagged as linear. The maps to be flagged as linear in a PBR workflow are roughness, ambient occlusion, normal, metallic, and height.

Within Substance Designer and Substance Painter, the conversion between linear and gamma space on inputs to the shader is handled automatically. So is gamma correction on the computed result in the rendered viewport. As artists, we don’t usually need to worry about the linear computation and conversions within the Substance software, as the software will handle this by default.

When using Substance materials via the Substance Integration plugin, outputs are flagged for linear/gamma space automatically via the integration and the host application’s color management. However, it’s important to understand the process: when Substance maps are used as exported bitmaps rather than Substance materials, you may need to manually flag the textures as gamma-encoded or linear depending on the renderer you are using. Usually .png, .jpg, .tga or .tif files are gamma-encoded while sRGB OETF and .exr files are linear.

The sRGB decoding function (EOTF) converting from gamma space to linear space is used in Substance Painter and Substance Designer*, and is defined by the IEC 61966-2-1:1999 Standard as follows:
在这里插入图片描述

*At the time of this writing, the linear to rgb and rgb to linear nodes in Substance Designer do not use this formula for optimization reasons. This may change in a future release.

For the sake of simplicity, for all the conversions in this guide we have used the following simplified (but approximate) conversion functions instead:

在这里插入图片描述

Key Characteristics of PBR
Now that we have explored the basic theory behind the physics, we can derive some key characteristics of PBR:

  1. Energy conservation. A reflected ray is never brighter than the value it had when it first struck the surface. Energy conservation is handled by the shader.
  2. Fresnel. The BRDF is handled by the shader. The F0 reflectance value has minimal change for most common dielectrics and falls within a range of 2-5%. The F0 for metals is a high value, ranging from 70-100%.
  3. Specular intensity is controlled through the BRDF, roughness or glossiness map and the F0 reflectance value.
  4. Lighting calculations are computed in linear space. All maps that have gamma-encoded values such as base color or diffuse are usually converted by the shader to linear, but you may have to ensure that the conversion is properly handled by checking the appropriate option when importing the image in your game engine or renderer. Maps that describe surface attributes such as roughness, glossiness, metallic and height should be set to be interpreted as linear.

[1.] The technical name for a gamma encoding function is Opto-Electronic Transfer Function (OETF)

[2.] The technical name for a gamma decoding function is Electro-Optical Transfer Function (EOTF)

[3.] It is critically important to disambiguate the sRGB OETF from the sRGB colorspace; the OETF is only one of the three components that make an RGB colorspace:

a. The primaries chromaticity coordinates define the gamut (the triangle of colours) that can be encoded by a given RGB color space.

b. The white point defines the white color for a given RGB color space.

c. The transfer functions perform the mapping between the linear light components (tristimulus values) and a non-linear RGB video signal (most of the time for coding optimization and bandwidth performance).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值