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

Optimizing Materials for Mobile Platforms

Moving away from the most powerful gaming and computing platforms means that we, as developers, have to adjust to less capable devices, and demanding elements, such as shaders, need to be tweaked in order to maintain performance.

In this chapter, we will take a look at how to bring our materials into a mobile environment and how to optimize them, using many of the built-in tools provided by Unreal.

In particular, we will learn about the following topics in this chapter:

  • Increasing performance through customized UVs
  • Creating materials for mobile platforms
  • Using the forward shading renderer for VR
  • Optimizing materials through texture atlases
  • Baking a complex material into a simpler texture
  • Combining multiple meshes with the HLOD tool
  • Applying general material optimization techniques

Here’s a sneak peek at what we will be creating:

Figure 6.1 – A look at some of the effects we’ll be looking at in the following recipes

Figure 6.1 – A look at some...

Technical requirements

As usual, you can find a link to the Unreal Engine project accompanying this book here:

https://packt.link/A6PL9

There you’ll find all of the assets that we will work on in this recipe, letting you replicate the same scenes you’ll see later.

Increasing performance through customized UVs

Games are generally computationally expensive, so it makes sense to improve performance whenever we can. With a computer’s GPU, a vertex shader is run for every vertex on a model, and pixel shaders are run for every pixel on the screen. For those cases when there are fewer vertices than pixels, Unreal has a feature called Customized UVs, which can give you a performance boost if you run it on just the vertex shader, instead of also using a pixel one. In this recipe, we’ll take a look at how to take advantage of that feature by tiling a texture more efficiently.

Getting ready

To easily see the differences in UVs, you should have a texture where you can easily tell where the edges of it are. In this case, I will be using the UE4_Logo texture, which is included in the Engine Content | VREditor | Devices | Vive folder in the Content Browser.

Tip

The UE4_Logo texture is an asset that is part of the engine – there...

Creating materials for mobile platforms

When developing materials for mobile platforms, there are some things that we need to be aware of related to performance. Due to a number of limitations with the hardware, the materials that we create for it need to be more humble, in terms of the effects that we can enable and the fidelity of the resources that we can use within it. As you spend more time building materials for mobile devices, you will discover that there are often trade-offs that are required, such as reducing complexity for the sake of your application size or frame rate. In this recipe, we will explore some of the limitations inherent to these platforms by creating a simple material that could be used on those devices, while also discussing different settings that we can take advantage of.

Getting ready

Any textures that you want to use on mobile platforms need to have a resolution of 2,048 x 2,048 or lower, preferably a square texture to the power of 2 (64, 128, 256...

Using the forward shading renderer for VR

Working with VR gives artists and designers a lot of interesting challenges. Even though VR experiences typically involve high-powered computers, we can still encounter performance issues due to the large screen size required. Unreal Engine 5 contains a different rendering system, called Forward Rendering, which will give us a good performance boost at the expense of removing certain graphical features. In this recipe, we’ll explore how to enable this alternative rendering method in our projects.

Getting ready

In order to play your game in VR, you will need to have a VR headset that is plugged in and ready to be used. Unreal gives us the option to check out our levels in VR mode once it detects a connected headset, which occurs when the VR preview button is clicked, located within the Change Play Mode and Settings area of the editor – we’ll see exactly where once we start the recipe. If the option is still grayed...

Optimizing materials through texture atlases

Often referred to as a sprite sheet in the game industry, texture atlases are a great way to optimize game projects. The general concept is to have one big image that contains a collection of smaller ones. This is often used when there are smaller textures that are used frequently, in order to reduce the overhead on the graphics card being used, which has to switch between different texture memory locations. In this recipe, we’ll explore how to take advantage of this technique, how to use texture atlases within a material, and how to access the different textures contained within it.

Getting ready

To complete this recipe, you will need to have a single texture that contains multiple smaller ones inside of it. If you do not have one, you can make use of the flipbook texture from the Engine content, located within the following folder – Engine Content | Functions | Engine_MaterialFunctions02 | ExampleContent | Textures...

Baking a complex material into a simpler texture

Studying different material techniques throughout this book has left us with a wide variety of tools at our disposal when it comes to creating shaders. Some of those instruments are more expensive to render than others, so we also looked at several optimization techniques in the previous recipes that should help us keep performance in check. Having said so, there are times when the best optimization approach is to simply bake down all of the complex node graphs we have created into simple textures, removing all of the computationally expensive functions in favor of standard, static textures.

In this recipe, we’ll learn how to decrease the rendering cost of a model by reducing both the complexity and number of shaders applied to it, all thanks to the Merge tool panel.

Getting ready

To get ready, you will want to have a mesh that contains two or more material slots placed within a scene you would like to use. If you don...

Combining multiple meshes with the HLOD tool

The amount of actors contained in a level affects the performance of the real-time experiences we create. Each unique model added to the scene represents another entity that the engine needs to track, and even though innovations such as Nanite have decreased the burden that having more and more polygons represents, we still need to tackle the problem we face when dealing with thousands of different, unique meshes.

The Hierarchival Level of Detail (HLOD) System takes center stage when trying to solve that problem. In essence, its function is to group different models based on how far we are from them and merge them into individual entities, thus reducing the burden that these objects have on the hardware that displays them. We’ll learn about this in the next few pages, so buckle up for the ride!

Getting ready

You should have a map that contains multiple static meshes within it in order to apply the techniques we are going...

Applying general material optimization techniques

One of the ways that we can develop materials that work on both low- and high-end devices is through the material quality-level system. This recipe will discuss the creation of materials with quality settings in mind, allowing us to create one material that can be used on a variety of devices.

Getting ready

In order to complete this recipe, you will need to have a material that you would like to look different, depending on what quality level your game is running on. We’ll create one in the following section, but feel free to use one of your own if you think that it would benefit from having different quality settings.

How to do it

To start, let’s create a simple material that we can use to demonstrate the material-optimization techniques we’ll be studying later on:

  1. Create a material and name it something along the lines of M_QualitySettings. Double-click on it to enter the Material Editor.
  2. ...
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