Reader small image

You're reading from  Unreal Engine 5 Shaders and Effects Cookbook - Second Edition

Product typeBook
Published inMay 2023
PublisherPackt
ISBN-139781837633081
Edition2nd Edition
Concepts
Right arrow
Author (1)
Brais Brenlla Ramos
Brais Brenlla Ramos
author image
Brais Brenlla Ramos

Brais Brenlla Ramos is a passionate Architect, 3D artist, Unreal Engine 4 developer and first-time author based between A Corua and his place of work in London, UK. His passion for all things 3D-related dates back to when he was playing games as a child, experiences that fuelled his later studies in architecture and computer animation. His entrance into the professional 3D world happened at the same time as his studies were finishing, with initial projects undertaken in the field of architectural visualization for different studios. Since then, he's worked on many different 3D modeling and app development projects, first as a team member, and later as the Unreal Engine 4 lead developer at a company called AccuCities, based in London.
Read more about Brais Brenlla Ramos

Right arrow

Understanding Physically Based Rendering

Welcome to Unreal Engine 5 Shaders and Effects Cookbook!

In this first chapter, we’ll begin by studying the PBR workflow. PBR is an acronym that stands for physically based rendering – an approach to rendering a scene that takes into account how light behaves when it encounters 3D objects. This is at the core of the rendering pipeline, and the focus of the recipes you’ll encounter in the next few pages. In them, we’ll work with the building blocks of the PBR workflow – lights and materials – while also studying their impact on performance – things that we need to be aware of if we want to succeed in the rendering arena. With that in mind, this is what we are going to do:

  • Setting up a studio scene
  • Working inside the Material Editor
  • Creating our first physically based material
  • Visualizing a simple glass
  • Using IBL and Lumen to light our scenes
  • Using static lighting...

Technical requirements

To complete this chapter, you’ll need to get a hold of Unreal Engine 5, the main star of this book!

This can be done by following these simple steps:

  1. Download the Epic Games Launcher from the engine’s website, https://www.unrealengine.com/en-US/download, and follow the installation procedure indicated there.
  2. Once installed, get the latest version of the engine. You can do so by navigating to the Unreal Engine section of the launcher, and then to the Library tab. There, you’ll be able to see a + icon, which lets us download whichever version of Unreal we want.
  3. Launch the newly downloaded version of Unreal by clicking on the homonymous button:
Figure 1.2 – Location of the buttons you’ll need to click to complete the previous set of actions

Figure 1.2 – Location of the buttons you’ll need to click to complete the previous set of actions

Apart from that, we have provided all the assets that you’ll see me use throughout the different recipes in this book. You can download...

Setting up a studio scene

The first objective that we are going to tackle in this book is creating a basic scene, one that we’ll be able to reuse as a background level for some of the materials we’ll be creating later. This initial step will allow us to go over the basics of the engine, as well as get familiar with some of the tools and panels that we’ll revisit multiple times throughout the next few pages. Let’s jump right in!

Getting ready

First, we need to download Unreal Engine 5 before we can start creating the basic studio scene. I’ve started writing this book with version 5.0.3, but don’t hesitate to use the latest iteration available to you whenever you read this. Instructions on how to download and install it can be found on the previous page!

How to do it…

Having launched the engine as the last of the previous steps, let’s look at how to set up a studio scene right from the beginning:

  1. Go to the Games...

Working inside the Material Editor

Let’s get started working inside the Material Editor! This is where the magic explained in this book happens, as well as the place where we’ll spend most of our time, so we’d better get well acquainted with it, then! As with everything inside Unreal, you’ll be able to see that this space for creating materials is a very flexible one – full of customizable panels, rearrangeable windows, and expandable areas. And the best thing is you can place them wherever you want!

Because of its modular nature, some of the initial questions that we need to tackle are the following: how do we start creating materials? And where do we look for the most used parameters? Having different panels means having to look for different functionalities in each of them, so we’ll need to know how we can find our way around the editor. We won’t stop there, though – this new workspace is packed with plenty of useful little...

Creating our first physically based material

PBR is, at its core, a principle that several graphic engines try to follow. Instead of being a strict set of rules by which every rendering program needs to abide, it is more of an idea – one that dictates that what we see on our screens is the result of a study on how light behaves when it interacts with certain surfaces.

As a direct consequence, the so-called PBR workflow varies from one rendering engine to the next, depending on how the creators of the software have decided to program the system. For us, that means that we are going to be looking at the implementation that Epic Games has chosen for the rendering pipeline in Unreal Engine 5.

However, we are going to do so in our already established recipe process – that is, by creating materials that follow the PBR workflow so that we can see the results. Let’s get to it!

Getting ready

We don’t need a lot to get started working on this recipe &...

Visualizing a simple glass

In the previous recipe, we had the opportunity to create a basic material that followed the physically based approach that Unreal Engine uses to render elements on the screen. We saw how we could potentially create endless combinations by simply using nodes and expressions that affected the roughness and the metallic attributes of a material, letting us achieve the look of plastics, concrete, metals, or wood.

Those previous examples can be considered simple ones – for they use the same Shading Model to calculate how each element needs to be rendered. Most of the materials that we experience in our daily lives fall into that category, and they can be described using the attributes we studied previously. Despite that, there are always examples that can’t be exactly covered with one unique Shading Model. The way that light behaves when it touches glass, for example, needs to be redefined in those cases.

The same applies to other elements...

Using IBL and Lumen to light our scenes

This introductory chapter has covered the foundations of the PBR workflow that Unreal uses for its rendering pipeline. With that as our focus, we have already looked at several of its key components, such as different material parameters and Shading Models. However, we can’t dismiss the fact that the PBR workflow takes information from the lights in our scene to display and calculate how everything should look.

So far, we’ve only focused on the objects and the materials that are being rendered – but that is only part of the equation. One of the other parts is, of course, the lighting information. Lights are crucial to the PBR workflow: they introduce shadows, reflections, and other subtleties that affect the final look of the image. They work alongside the materials that we’ve previously applied by making sense of some of the properties we set up. Roughness textures and normal maps work in tandem with the lights...

Using static lighting in our projects

The arrival of Unreal Engine 5 has seen the introduction of very important and groundbreaking technologies into the real-time visualization realm. Nanite, Lumen, and Virtual Shadow Maps… these are all new features that move the industry forward, and they ultimately give us higher-fidelity results when it comes to rendering our scenes.

Perhaps accidentally, we’ve already looked at one of those new features – Lumen. As the new default dynamic global illumination and reflections system, we’ve seen its effects when we worked on the previous recipe. We only had to worry about placing a light and adjusting some of its attributes for the scene to look right; we didn’t have to create reflection captures, bake lightmaps, or use other techniques that might sound completely alien to you if you are starting your real-time journey with this version of the engine.

Despite that, we are going to take a quick look at the...

Checking the cost of our materials

So far, this introductory chapter has gone over the basics of the rendering pipeline – we’ve seen how to create a PBM, understood what the different Shading Models were, and saw how light played a key role in the overall look of the final image. However, we can’t move on to different topics just yet without learning a bit more about the impact that our materials have on the machines that are displaying them.

The first thing that we need to be aware of is that some materials or effects are more expensive in terms of their rendering cost than others. Chances are you have already experienced that in the past – think, for example, about frames per second in video games. The number of frames per second that are fed into our displays by the graphics cards directly influences how the game plays and feels. Many elements affect performance, but one crucial factor in that equation is the complexity of the materials we create.

...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unreal Engine 5 Shaders and Effects Cookbook - Second Edition
Published in: May 2023Publisher: PacktISBN-13: 9781837633081
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Brais Brenlla Ramos

Brais Brenlla Ramos is a passionate Architect, 3D artist, Unreal Engine 4 developer and first-time author based between A Corua and his place of work in London, UK. His passion for all things 3D-related dates back to when he was playing games as a child, experiences that fuelled his later studies in architecture and computer animation. His entrance into the professional 3D world happened at the same time as his studies were finishing, with initial projects undertaken in the field of architectural visualization for different studios. Since then, he's worked on many different 3D modeling and app development projects, first as a team member, and later as the Unreal Engine 4 lead developer at a company called AccuCities, based in London.
Read more about Brais Brenlla Ramos