Understanding the Basics of PBR in Game Engines

Dec, 2017

- By Game Design Department of ICAT Design and Media College

- A quick peek into understanding surface detail and next-gen texturing for games

The evolution of the gaming industry is often directly attributed to the growth of computer technology. The gaming industry has been at the forefront of discoveries in computer science and engineering. With an unimaginable advancement in computer hardware, game developers, engineers and artists have found more ways to engage their audience through gripping stories, challenging gameplay and realistic graphics. When we look back at how graphics has evolved over the years from a few pixels moving around on the screen to hyper-realistic characters with multi-dimensional and in-depth personalities, we see a steady increase in the number of players too.

Physically Based Rendering (PBR), one of the key aspects of getting to that realistic feel in computer graphics, has made its mark in the industry and here we try to analyze how the technology behind it works, without going too much into the specifics. In other words, any individual without a background in game technology and some basic knowledge in physics and CGI can read this article as an introduction to a subject that has immense depth and requires good understanding of physics and mathematics. This article aims to intrigue the technical mind that wants to learn the technology behind developing next-gen games.


What is PBR?

In order for us to understand PBR, we need to start with what rendering is. Rendering is a vast topic that demands an extensive article in its own right. However, to keep things within the scope of this article, we will just briefly go over it. Rendering can be simply put as, displaying a 2 dimensional (2D) image composition from a 3 dimensional (3D) scene by using computer programs. This process, for games, is done by a “Game Engine”, which displays these images instantaneously as soon as the player looks at it. In animated movies and other Computer Generated Image (CGI) sequences, the rendering process is done before the viewer sees it; therefore, is not rendered instantaneously and can be rendered in much higher quality. Game engines have the immense task of doing this rendering as soon as the player looks at any part of the scene; all the 3D objects - the trees, grass, sky, enemies, vehicles etc., have to be rendered in a fraction of a second. Therefore, the game engine finds shortcuts in order to ‘fake’ the effects on screen. This kind of rendering is called real time rendering.

With the introduction of PBR, game engines can now show the actual physical attributes of any object as they exist in the real world.


Img.1: PBR shader compared to traditional shaders [Ref. meta3dstudios]


The Physical Attributes that PBR Show

The physical attributes are the physically measurable attributes that all living and nonliving objects around us have. These attributes may include Albedo, Metallicity and Roughness / Smoothness.

  • The surface Albedo is the ratio between the irradiance reflected to the irradiance received of the surface. We can find the surface Albedo for any surface; and as artists we try to imitate the same. For example: the Albedo value for the moon is 0.12 and the Earth is 0.33.
  • The metallicity is simply whether a surface is Metallic or not. Usually the Metallic values (for metallic objects) will be either close to 1 or (in the case of non Metallic objects) close to 0.
  • Roughness on the other hand is the microsurface detail, i.e. if a surface is rough to the touch or smooth. Roughness cannot just be tactile but visual too. For example, we can see how shiny a chrome surface is, whereas a wall might not reflect much of the surroundings. This is because of the microsurface of chrome is fairly even and the microsurface of the wall is highly irregular.

The one thing we notice commonly in all of these aspects of surface detail is that, it has everything to do with how light interacts with the surface.


Img.2: Interaction of light rays with a smooth microsurface (a) and a rough microsurface (b)


Importance of Light in PBR

Light is the key player here. As in reality, without light, we cannot see anything around us; it’s the same in game engines too. It calculates the surface detail from each light ray that bounces off a surface. When a light ray hits a surface and bounces back out, it carries all the information about the surface to the viewer — in our case, the player. When the angle of incidence ‘θi’ is equal to the angle of reflection ‘θr’, then the surface is perfectly smooth (mirror). It will reflect whatever is around it, i.e. -

θi = θr, for a perfectly smooth microsurface

But in cases of rough surfaces, the light ray is scattered, because the microsurface is irregular — ‘θi’ is not equal to ‘θr’, i.e. -

θi ≠ θr, for a rough microsurface

Regardless of how rough a surface is, the scattered light rays is still reflected out at some point carrying the base color information; or as Game Artists, call it the Albedo which in Latin translates to ‘whiteness’. The Albedo values while in use for Game Art may slightly vary as compared to physics. In game arts, we can have a black Albedo for an object, provided we give microsurface detail or roughness and metallicity (which would show the color of the object as black); but in physics, an Albedo value of black or ‘0’ means it's a black body (surface that completely absorbs all incident rays). In physics we deal with a lot more perfection but when it comes to game arts we go with ‘if it looks good, it is good’.


Img.3: PBR values as given by Unity Engine

That said, it also depends on the game mechanics. If it requires the physical attributes of the object to be scientifically correct, then the Artist will need to impart those values accurately in his/her texture as the physics in the game might use those attributes as a part of the core gameplay mechanics, which gets us to little bit more serious physics.


Texture Maps for PBR

PBR, in most cases depends on something called Bidirectional Reflectance Distribution Function (BRDF) which is just a fancy term for saying how the light will interact with the surface with the given texture values (or so to speak). Now what do we mean when we say texture values?  Each physical attribute including the Albedo, Metallicity, Roughness etc., are stored in something called texture maps. With each attribute having its own texture map. When a texture map is saved, it is generally saved in sRGB, which stands for standard Red Green Blue. Any Artist, who has even the most basic knowledge in CGI, knows that these are the primary colors for digital images. Often referred to as the red channel, blue channel and the green channel wherein each channel stores the amount of each of these colors in each pixel with values ranging from 0 to 255. So an RGB value of 0,0,0 would be completely black, whereas 255,255,255 would be completely white. These values when mixed and matched, give you the color information that you see in your texture image. Some of the texture maps can have only grayscale values (i.e. just one channel with different values of gray), such as the metallicity or metallic maps, which would just have values from 0 to 1 with 0 being non metallic and 1 being metallic.
These texture maps, when inputted to a PBR shader in the game engine, the engine will render the object with the attributes specified within the maps. The key strength of PBR shaders is that even with different lighting conditions, the object will interact exactly how it is supposed to under each lighting condition. So no more going back to the drawing board and recreating the textures because the director decided to change the lighting in the scene.

Img.4: A PBR shader under different lighting conditions [Ref. Marmoset]


PBR, even though it is widely used in the gaming industry now, the concept of using physical attributes of a surface for rendering has been around since the 1980s. The history of PBR is outside the scope of this article, however, what we can gather essentially from it is that technology keeps constantly evolving to add more realism in the look and feel of next-gen games. It's not easy to predict what technology has in store for graphics in video games a decade from now but without understanding the key concepts that led its evolution (such as PBR), it could prove challenging to understand them at much later, more evolved stage.