Light and media
Physics-based rendering and coloring theory
This article is very helpful for programmers and art producers, and I hope you will have a holistic understanding of the physics-based rendering after you have finished, this translation of the articles (the Comprehensive PBR Guide by Allegorithmic-vol. 1) Basically from the angle of art to explain the physics-based rendering, there is time I will be the program part of the knowledge to elaborate, including theory and implementation, I am also in the learning stage, mainly in the study of UE4 based on physical rendering, I hope to have a more detailed article in the next time to elaborate the implementation principle from the programmer's point of view.
by wind crush Snow
Blog: http://www.cnblogs.com/ghl_carmack/
Light is a complex phenomenon, because it has both the properties of waves and particles. Therefore, different models are created to describe the behavior of light. As the art of making stickers, we care about the light-ray model because it describes how light and media interact. It is important for us to understand how light interacts with the surface of the media, because our job is to create a map that describes that surface. The textures and textures we make are used to interact with light in the virtual world, and the more we know about how we see the surface, the better the textures we make.
In this guide, we will discuss the theory behind physics, which is based on the theoretical basis of a physical rendering model. Let's start with the light and then gradually expand to the key factors based on physical rendering.
Lighting (Light Rays)
The light model shows that light travels along a straight line in a homogeneous, transparent medium such as air, and it also indicates that the ray has a predictable behavior when it encounters a surface of an opaque object or passes through a different medium, such as air to water. In this way, it is possible to show the path of light from one starting point to the last converted to another form of energy such as thermal energy.
The light reaching the surface is called the incident light, and the angle of arrival to the normal is called the angle of incidence, shown in 01.
The light at the junction of the two media is incident. When the light reaches the surface, either or both of them occur:
- The light bounces off the surface and spreads in a different direction. It follows the law of reflection, which is equal to the angle of incidence (reflected light).
- Light travels from one medium to another in a straight line (refraction of light).
At this point, we can say that the light is divided into two directions: reflection and refraction. On the surface, light is reflected or refracted, and can eventually be absorbed by the medium. However, absorption does not occur on the surface.
Figure 01
Absorption and scattering (transparent and translucent)
When light travels in non-homogeneous or translucent materials, the light can be absorbed or scattered:
- By absorption, the intensity of light becomes smaller because it is converted into another form of energy (by means of heat), and its color is changed by the absorption of different wavelengths of light, but the direction of the light does not change.
- By scattering, the direction of light changes randomly, and the size of the deviation depends on the material. Scattering randomly alters the direction of light but does not change the intensity. The ear is a good example, because the ears are thin (absorbing less), so you can see the scattered light from behind the ear. If there is no scattering and very little absorption, then the light can pass directly through a surface such as glass. For example, if you swim in a pool and hope it is clean, then when you open your eyes, you will see a long distance in clean water. However, let's assume that in the same pond, but not very dirty, the small particles in the water scatter light so that the visibility of the water is much lower.
The farther the light travels in such a medium or material, the more it is absorbed or scattered. Therefore, the thickness of the object has an absolute effect on the degree of absorption or scattering of light. Then a thickness map can be used to describe the thickness of the object in the shader, as shown in 02
Figure 02
Diffuse and specular reflections
Specular reflection is the light reflected on the surface, as we discussed in the Light section. Light bounces off the surface and spreads in a different direction. It follows the law of reflection, on a perfectly smooth surface, with a reflective angle equal to the angle of incidence. However, it is important to know that most surfaces are irregular and that the direction of reflection is randomly changed according to the roughness of the surface. It changes the direction of light, but the intensity of light does not change.
A rough surface will have a larger and darker highlight. A smooth surface keeps the highlights gathered so that it will look brighter or stronger at a particular angle. In both cases, however, the same amount of light energy is reflected, as shown in 3.
Figure 03 The rougher the surface, the larger, darker the highlight
Diffuse reflection is the refraction of light. Light travels from one medium to another and scatters multiple times within an object. Then it is refracted away from the object into the original medium, and the position is almost the same point as the first entry, if shown in Figure 04.
Figure 04
Diffuse material is very absorbent, which means that if the refraction of light in the material is transmitted too long, it is likely to be fully absorbed. This means that the light does not come out of the material, and it may not transmit much distance. This is why the distance between the points entering and leaving the surface can be negligible. The Lambertian model, which has been used in the traditional coloring system for diffuse reflection calculation, does not take into account the influence of surface roughness, but also has the Oren-nayar model which considers the influence of roughness.
Materials with high scattering rates and low absorption rates are sometimes referred to as participating media (participating media) or translucent materials. such as smoke, milk, skin, jade, marble. It is possible to render the following three objects using an additional subsurface scattering model, which calculates the distance between the light entering and the point at which it is emitted. Accurate rendering of such varied, low-scattering and absorbing media as smoke and fog requires more sophisticated algorithms such as Monte Carlo simulations.
Micro-Surface theory
In theory, both diffuse and specular reflections depend on the degree of irregularity of the intersecting surface of the light, and the roughness is less affected by diffuse reflection because the scattering occurs inside the material. Therefore, the direction of exit is basically independent of the roughness of the surface and the direction of the incident. The deepest diffuse model (Lambertian) ignores it completely.
In this document, we call the roughness of the surface irregularities. In fact, it also has several other names, such as roughness, smoothness, gloss, or micro-surface, which are related to the use of a physical rendering workflow, but they all mean the same aspect of the surface, which is the geometric detail of the sub-Texel (sub-texel).
A surface irregularity is represented in the roughness or gloss map, depending on the workflow you use. A substrate physical bidirectional reflection distribution function (BRDF) is based on a micro-surface theory, which assumes that the surface is made up of so-called tiny detail surfaces in different directions. Each tiny plane reflects the light in one direction according to its normal direction, as shown in 05.
Figure 05
Surface normals reflect visible light in the middle of the direction of the light source and the direction of the line of sight. However, not all surface normals and half-width normals (half normal) have equal micro surfaces that reflect light, as some of them are obscured (light direction) or cloaked as shown in 05.
At the microscopic level, irregular surfaces cause diffuse reflection of light. For example, a blurred reflection is caused by the scattering of light. The reflected light is not equal, so the specular reflection we receive is blurred, as shown in 06.
Figure 06 An irregular surface on a microscopic level causes diffuse reflection of light
Color
The color of the surface (the color we see) is determined by the wavelength emitted by the light source and by the diffuse reflection and high light that the object absorbs and reflects. The remaining reflected wavelengths of light are the colors we see.
For example, most of the surface of an apple reflects red light. Only light with a red wavelength is scattered back to the surface, and the others are absorbed. As shown in 07.
Figure 07
It also has the same high light color as the light source, because the surface of an insulator like Apple has a high light reflection that is almost independent of the wavelength. As a result, the specular reflection of this material is basically not a modified color (same as the color of the light source) we will discuss the different materials (metal and nonmetal) in the following chapters.
Bidirectional reflection distribution Function (BRDF)
A bidirectional reflection distribution function is simply a function that describes the reflection properties of a surface. In computer graphics, there are many different BRDF models, some of which are not based on physics. For a BRDF to satisfy physical-based characteristics, it must be energy-conserved and reciprocal. For each other, I refer to the Helmholtz pour law, which shows that the incident and the emitted light can be exchanged without affecting the BRDF value.
The physical rendering-based shader used by substance (shaders) is based on the theoretical reflection model of Disney (Unreal Engine is also based on this theoretical modification Simplified), which is based on the GGX micro-surface distribution. GGX is better than other schemes in high-light distribution, it has a shorter high-light peak and a longer tail in the decaying part, so it looks more realistic. As shown in 08.
Figure 08
Conservation of energy
Conservation of energy plays a key role in physical rendering-based solutions. It indicates that the total energy (reflection and scattering) of the light being re-emitted by the surface is less than the total amount of energy it receives. In other words, the light that is reflected off the surface is not stronger than the light reaching the surface. As art, there is no need to worry about controlling conservation of energy. This is one of the best aspects of physical rendering, and energy conservation is ensured through shaders (shader). It is based on a part of the physical model, so that we can spend more time on how to make good results instead of focusing on physical implementations.
Fresnel effect (Fresnel Effect)
Fresnel reflection factor, as a factor of BRDF, is also a very important role in physics-based rendering. The Fresnel effect, discovered by French physicist Augustin-jean Fresnel, states that the amount of reflected light you see from a surface depends on the angle of observation you receive it.
For example, suppose you have a pond, and if you look straight down on the surface of the water, you can clearly see the bottom (assuming the water is clearer). In this way, the surface of the water is basically 0 degrees or the normal is the normal of the surface. Now, if you look at the surface of the water in a tangential direction and try to be parallel to the surface, you will see the specular reflections on the water become stronger and you may not be able to see the bottom.
The Fresnel effect based on physical rendering is not the same as we used in traditional shading models. Again, it is another physical feature of shader processing based on physical rendering. When the surface is observed at a tangent angle of incidence, all smooth surfaces become a hundred-percent reflector at 90 degrees of incident angle.
For rough surfaces, the specular highlights will be more, but will not achieve a high light reflection. This is when the normal of the surface and the angle of the light are not the normal of the macroscopic surface and the angle of the light. So the light is scattered in different directions and the reflections become softer and darker. At a macro level, the effect you see may be an average effect of all the Fresnel effects on the micro surface.
F0 (Fresnel reflection value at 0 degree angle)
When the light source reaches the surface vertically (at a 0 degree angle), some of the light is reflected back as a highlight. Using the refractive index of the surface (IOR), you can push to export the amount of reflection back, which is called F0 (Fresnel 0), as shown in 09. The number of light sources that are refracted into the surface is called 1-f0.
Figure 09 for rough surfaces, the specular highlights will be more, but will not reach a high light reflection
For ordinary insulators, the value of F0 is generally between 0.02 and 0.05, while for conductors the F0 range is typically between 0.5 and 1.0. Therefore, the reflective capacity of the surface is determined by the following refractive index formula, 10, it comes from Sebasien Lagarde's "Feeding a physically-based shading Model" this blog post.
Figure 10
The reflection value of F0 is what we need to focus on in the process of making the map. Non-metallic (dielectric/insulator) is generally a grayscale value, and the metal (conductor) will have an RGB value. With regard to physics-based rendering and interpreting reflection from an art perspective, we can say that for ordinary smooth insulator surfaces, the F0 will reflect 2% to 5% of the light, while the tangent angle will reflect the hundred rays, as shown in 09.
The reflection value of the dielectric is not very sharp, in fact, the change in the roughness of the actual value of the changes are basically not seen. However, the values will vary. In Figure 11, you can see a chart showing the F0 range of metal and non-metallic materials.
Note that the range of non-metallic F0 is not very different from other nonmetal. Gems are an exception and they have higher values. We will discuss F0 next, because it has a relatively large relationship with conductors and insulators.
Figure 11
Conductors and insulators (metal and Nonmetal)
When creating a material based on physical rendering, I found it useful to think about how to make metal and nonmetal. I will ask myself whether this surface is metal or non-metallic. If so, I will follow a series of guidelines, if not I will follow other guidelines. This method may be too simple because the material is not simply classified as metal or non-metallic, such as quasi-metal, but in the whole process of creating the material, it is a good way to differentiate between metal and nonmetal, except for the quasi-metal is an exception. To set some rules for making materials, we first have to understand what we are creating. Based on physical rendering, we can view the properties of metal and nonmetal to create guidelines.
The refraction light is absorbed, the color of the metal comes from the reflected light, so in our map, the metal has no diffuse color.
Metal
A metal (conductor) is a good conductor of heat and electricity. Simply put, the electrical field of the conductor metal is 0 and when a light wave consisting of electricity and magnetism reaches the surface, part of it is reflected and the other part is absorbed. The reflective value of polished metal is generally within a very high range of 70-100%, as shown in 12.
Figure 12
Some metals absorb light at different wavelengths. For example, gold absorbs blue light in the high-frequency region of the visible spectrum, so it appears to be slightly yellowish. However, the refraction of light is absorbed, the color of the metal comes from the reflected light, so in our map, the metal does not have a diffuse color. For example, in a specular/gloss workflow, a pure metal is colored black in a diffuse map, and the reflected value in a specular map is a shaded color value. For metals, the reflection value is an RGB value and can be adjusted for color. Because of the physics-based model we use, we need to give our metal reflection values using real-world measurements.
Another aspect of metal-making mapping is that metals can corrode. This means that weathering plays an important role in the reflective state of metals. For example, if the metal is rusty, it changes the reflective state of the metal and the corroded area needs to be treated as an insulator material, as shown in 13.
Figure 13
Painted metal is treated as non-metallic rather than metal. Paint is considered a layer on a pure metal. Only pure metal exposed from falling paint is treated as metal. The same applies to dust on metal or any medium that blocks pure metal.
As I mentioned above, I often ask myself whether a material is metal or not. More precisely, however, the problem should be getting a metal state, such as it is not painted, rusty or obscured by dust or grease. If it is not pure metal then it will be treated as a dielectric, and may also be due to weathering caused by the fusion of pure metal and nonmetal.
Weathering plays an important role in determining the reflective state of the metal.
Non - metallic
Non-metallic (insulator/dielectric) is a bad conductor of electrons. Refraction rays are scattered and absorbed (usually re-emitted from the surface) so they reflect a very small portion of the light compared to the metal, thus resulting in a diffuse color. As we said earlier, the F0 value calculated by the refractive index of the common insulator is between 2-5%. These values range from 0.017 to 0.067 in linear space (40-75 SRGB) 14. Gems are an exception, most non-metallic will not be greater than 4%.
Figure 14
As with metals, they also require real-world measurements, but the refractive index of opaque materials is difficult to find. However, the F0 values of most common dielectrics do not vary greatly, so we can follow some guidelines to find the reflected values that we will describe in volume 2.
The F0 reflection value of the common dielectric is between 2-5% and calculated by the refractive index (IOR).
Linear Space rendering
Linear space If you expand, you can write a whole article. So we don't go into the details. However, we need to know that the light calculation must be done in a linear space.
In simple terms, linear space rendering provides the correct mathematical way for lighting calculations. It creates an environment for light to behave like the real world. Within the linear crane, the gamma is 1.0. However, to make our human eyes look right, these textures need to be encoded using sRGB. In substance, if a picture is tagged with sRGB, it is converted to a linear space for later calculations and will eventually be converted to sRGB encoding to display to the screen. However, these images need to be in linear space when you store the values in the texture that represent only the roughness or the degree of the metal.
substance automatically handles linear and sRGB spatial transformations as transitions, and also gamma-corrects the results computed in the rendered viewport. As an art person, you don't need to be concerned with the calculation and conversion of linear spaces in substance. When using the substance material through the substance integration plug-in, the conversion of the linear space is automatically processed.
However, the understanding process is important because when the substance map is used as an export bitmap and is not using the substance material, you may need to handle the conversion manually based on the renderer you are using. You need to know that the base color/diffuse color is in the sRGB space, while the others are in the linear space.
Key points:
Now that we have browsed the basics behind basic physical rendering, we can get some key points for basic physical rendering.
- Conservation of energy. A reflected light is unlikely to be brighter than when it reaches the surface of the object. The conservation of energy is ensured by the shader (shader).
- Fresnel. The bidirectional reflection distribution function is handled by the shader. The F0 reflection value is similar to the common dielectric and ranges between 2-5%. The F0 value range of the metal is larger than 70-100%.
- Specular intensity is controlled by a bidirectional reflection distribution function (BRDF), roughness or gloss mapping, and F0 reflection values.
- The illumination calculation is performed in a linear space. All gamma-encoded maps, such as base color or diffuse reflection, are usually converted to linear space by shaders, but you may need to select the appropriate option in your game engine or renderer to ensure normal conversion. Maps that describe surface properties such as roughness, gloss, metal degree, or height should be set to be interpreted as linear spaces.
Reference:
1. physically-based shading at the Disney Brent Burley, Walt Disney Animation Studios.
Https://disney-animation.s3.amazonaws.com/library/s2012_pbs_disney_brdf_notes_v2.pdf
2. Microfacet Models for refraction through Rough surfaces
Http://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf
3. Feeding a physically-based shading Model by Sebastien Lagarde
http://seblagarde.wordpress.com/2011/08/17/feeding-a-physical-based-lighting-mode/
4. An Introduction to BRDF Models by Daniël Jimenez Kwast
Http://hmi.ewi.utwente.nl/verslagen/capita-selecta/CS-Jimenez-Kwast-Daniel.pdf
The entire file can also be downloaded PDF:HTTP://FILES.CNBLOGS.COM/FILES/GHL_CARMACK/%E5%9F%BA%E4%BA%8E%E7%89%A9%E7%90%86%E7%9A%84%E6%B8%B2 %e6%9f%93%e7%90%86%e8%ae%ba.pdf
Physics-based rendering detailed guide Volume 1 light and media: physics-based rendering and coloring theory