Vismats

Basic theory of rendering based on real conditions

2019-10-14

The physics-based representation (PBR) is an exciting trend, if defined very basically, of real-time rendering. The term is widespread, which often creates confusion as to what it means exactly. The quick answer is: 'many things' and 'depends', which does not allow us to get a clear idea of ​​what it really is, so I have proposed to try to explain in detail the PBR what it represents and how it differs from the oldest rendering methods. This document is intended for people with zero or very basic knowledge of this topic and will not talk about any mathematical code.

Much of what makes a physics-based rendering system different from its predecessors is a deeper reasoning about the behavior of light and the surfaces involved in it. The rendering ability has advanced sufficiently so that some of the old approaches to this subject can now be considered obsolete and with them some of the old methods to generate something artistically remarkable. This means that both the engineer and the artist must understand the motivations of these changes.

We will start with some of the basic concepts so that they are well defined before starting to highlight what is new, if you continue reading through these first concepts that you will surely already know for sure it will be worth reading, you can also check our own article of Joe Wilson on the creation of PBR illustrations .

Diffusion and Reflection

Diffusion and reflection, also known as "diffuse" and "specular" light respectively, are two terms that describe the most basic separation of the interactions between the surface and the light. Most people will be familiar with these ideas on a practical level, but they may not know the physical differences that exist between them.

When the light strikes a surface, part of it will be reflected, that is, it will bounce, from the surface and will do so in the direction of the normal side of that surface. This behavior is very similar to that of a ball thrown against the ground or a wall: it will bounce at the opposite angle. On a fully polished surface, it will result in a "mirror" appearance. The word 'specular', which is often used to describe this “mirror” effect, comes from the Latin ' speculum ' (it seems that 'specularity' sounds more professional than “mirror effect”).

However, not all light is reflected from the surface. Usually, some rays of light will penetrate inside the illuminated object. There they will be absorbed by the material (generally they will be converted to heat) or dispersed internally. Some of this light can return to the surface, becoming visible once again to the eyes and cameras present. This is known by many names: "Diffuse light", "Diffusion", "Dispersion (Subsurface Scattering)": all describe the same effect.

The absorption and dispersion of diffused light are often quite different for different wavelengths of light, which is what gives color to objects (for example, if an object absorbs most of the light but disperses in blue , it will look blue). The dispersion is often so chaotic that it can be said that it looks the same in all directions, very different from the case of a mirror! A material that uses this approach really only needs one value: 'albedo', a unique color that describes the fractions of various colors of light that will disperse from the surface. 'Diffuse color' or 'Diffuse' is the name that is sometimes used as a synonym.

Translucency and Transparency

In some cases, diffusion is more complicated, for example, in materials that have wider dispersion distances, such as skin or wax. In these cases, a simple color generally does not work and during the rendering process the shape and thickness of the object being illuminated must be taken into account. If they are thin enough, such objects often see the light scattering on the back side and can therefore be called translucent. If the diffusion is even lower (for example, glass), then the dispersion is not evident and we can see completely what is on the other side clearly. These behaviors are sufficiently different from the typical 'near surface' diffusion, so special configurations are generally needed to simulate them.

Energy conservation

With the above descriptions we have enough information to reach an important conclusion, reflection and diffusion are mutually exclusive. This is because, in order for the light to be diffused, the light must first penetrate the surface (that is, not reflect). This is known in the rendering language as an example of 'energy conservation', which means that the light that comes out of a surface is never brighter than what originally came to it.

This is easy to apply in a rendering system: one simply subtracts the reflected light before allowing the diffused light effect to occur. This means that highly reflective objects will show little or no diffuse light, simply because little or no light penetrates through the surface, since it has mostly been reflected. The opposite is also true: if an object has a bright diffusion, it cannot be especially reflective.

Energy conservation of this type is an important aspect of rendering based on physical aspects. It allows the artist to work with reflectivity and diffusion values ​​(also known as albedo) for a material without accidentally violating the laws of physics (with which it tends to look bad). While compliance with these restrictions in the code is not strictly necessary to produce something that looks good, it serves a useful function as a type of 'protection' that will prevent the final work from greatly exceeding the established rules or becoming inconsistent under different conditions of lighting.

Metals

Electrically conductive materials, especially metals, deserve special mention at this point for several reasons.

First, they tend to be much more reflective than insulators (non-conductive). The conductors will generally exhibit high reflectivities between 60-90%, while the insulators generally have a lower reflectivity, in the range of 0-20%. These high reflectances prevent the majority of the light from reaching the interior and therefore being distributed, giving the metals a very 'bright' appearance.

Second, reflectivity in conductors will sometimes vary along the visible spectrum, which means that their reflections appear stained. This reflection coloration is rare even among conductors, but it occurs in some everyday materials (for example, gold, copper and brass). Non-conductors or insulators as a general rule do not exhibit this effect and their reflections are colorless.

Finally, electrical conductors will generally absorb instead of scattering any light that penetrates the surface. This means that, in theory, drivers will not show any evidence of diffused light. In practice, however, there are often oxides or other residues on the surface of a metal that will disperse some small amounts of light.

It is this duality between metals and almost everything else that leads some rendering systems to adopt 'metallicity' as a direct option. In such systems, artists specify the degree to which a material behaves like a metal, instead of specifying only albedo and reflectivity explicitly. Sometimes, this is preferred as a simpler way to create materials, but it is not necessarily a physics-based rendering feature.

Fresnel

Augustin-Jean Fresnel seems to be one of those deceased people that we probably won't forget, mainly because his name is engraved in a series of phenomena he was the first to describe accurately. It would be difficult to have a discussion about the reflection of the light without its name appearing.

In computer graphics, the word Fresnel refers to the different reflectivity that occurs at different angles. Specifically, the light that falls on a surface at an angle other than 90 ° will be much more likely to be reflected than the one that hits a surface directly. This means that objects rendered with an appropriate 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 materials have made some important corrections popular in the Fresnel equations.

The first is that for all materials, the reflectivity becomes total for extreme angles: the 'edges' seen on any smooth object must act as perfect mirrors (without color), regardless of the material. Indeed, any substance can act as a perfect mirror if it is soft and looks at the right angle. This may be contrary to intuition, but the physics is clear.

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

What this means to us is that, assuming realism is desired, control over Fresnel's behavior in a render should be reduced, rather than increased. Or at least, we now know where to set our default values!

This is good news, because it can simplify content generation. The rendering program can now control the Fresnel effect almost entirely; Just check some of the other properties of pre-existing materials, such as polishing and reflectivity.

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

There is a big "but" for the Fresnel effect: it quickly becomes less obvious as the surfaces become less soft, less polished. More information on this situation will be given a little later.

Microsurface

The above descriptions of reflection and diffusion depend on the orientation of the surface. Broadly speaking, this is due to the shape of the 3D mesh that is being rendered, which can also make use of a normal map to describe smaller details. With this information, any rendering system can work correctly, which makes diffusion and reflection visualize well.

However, a large piece is still missing. Most real-world surfaces have very small imperfections: small grooves, cracks and bumps too small for the eyes to see and too small to represent on a normal map of any sensible resolution. Despite being invisible to the naked eye, these microscopic features, however, affect the diffusion and reflection of light.

The detail of the microscopic surface has the most noticeable effect on reflection (the dispersion is not very affected and will not be discussed here anymore). In the diagram above, you can see how the parallel lines of the incoming light begin to diverge when they are reflected from a rougher surface, since each ray strikes a part of the surface with a different orientation. The analog in the typical example of the ball would be an extreme: The light on the ball is still going to bounce, but at an unpredictable angle. In summary, the rougher the surface, the more the reflected light will diverge or appear as 'blurry'.

Unfortunately, the evaluation of each characteristic of the micro surface in rendering would be prohibitive in terms of artistic production, memory use and calculation. Then what do we do? It turns out that if we give up describing the details of the micro surface directly and instead specify a general measure of roughness, we can obtain fairly accurate renderings that produce similar results. This measure is often called 'Brightness', 'Softness' or 'Roughness'. It can be specified as a texture or as a constant for a given material.

Energy conservation (again)

As our hypothetical rendering system is now taking into account the microscopic details of the surface and the diffusion of the reflected light properly, you should be careful to reflect the correct amount of light. Unfortunately, many old rendering systems are wrong to reflect too much or too little light, depending on the surface roughness.

When the equations are correctly balanced, a renderer must show rough surfaces that have larger reflections of reflection that appear dimmer than the smaller, sharper lights of a smooth surface. This apparent difference in brightness is the key: both materials are reflecting the same amount of light, but the rougher surface is extending it in different directions, while the softer 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 above. Having this aspect is one of the most important points required for any rendering program that aspires to be within what are called physics based.

Everything is microsurface

And it is with what has been commented previously that we reach the most important point: the polishing of the micro surface directly affects the apparent brightness of the reflections. This means that an artist can create variations directly on the polishing map (scratches, dents, worn or polished areas, whatever) and a PBR system will show not only the change in the way of reflection, but also the relative intensity.

This is significant because two real-world quantities that are physically related, surface detail and reflectivity, are now correctly linked to each other for the first time in the content of the technique and the representation process. This is very similar to the diffusion / reflection balancing act described above: we could be creating both values ​​independently, but as they are related, the task only becomes more difficult when treated separately.

In addition, an investigation of real-world materials will show that reflectivity values ​​do not vary widely. A good example would be water and mud: both have a very similar reflectivity, but since the mud is quite rough and the surface of a puddle is very soft, they seem very different in terms of their reflections. An artist who creates such a scene in a PBR system would be the author of the difference primarily through brightness or roughness maps instead of adjusting the reflectivity, as shown below:

The properties of the micro surface also have other subtle effects on reflection. For example, the Fresnel effect of 'brighter edges' decreases somewhat with rougher surfaces (the chaotic nature of a rough surface 'scatters' the Fresnel effect, preventing the viewer from seeing it clearly). In addition, large or concave microsurface features can 'trap' light, which causes it to reflect against the surface several times, which increases absorption and reduces brightness. Different rendering systems use these details in different ways and in different extensions, but the general trend of rougher surfaces that appear more tenuous is the same.

AliExpress WW