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

Going Beyond Traditional Materials

Most of the materials and techniques we’ve seen so far had one thing in common: they were designed to affect the look of our 3D models. Having said that, we can also use materials to drive other interesting effects; we can highlight interactive elements within the game world, or capture the scene from a particular point of view to then display it back to the user as if we were dealing with a CCTV feed.

We are going to take a look at a few particular cases in this chapter, including the following ones:

  • Playing a video on an in-game TV
  • Capturing the scene through a CCTV camera
  • Highlighting interactive elements
  • Creating snow on top of objects using layered materials
  • Changing a sunny scene to a snowy one with a parameter collection asset
  • Moving between seasons using curve atlases
  • Blending landscape materials

As you can see, there are other interesting uses for materials that can help us with our game or...

Technical requirements

As usual, most of the materials that we’ll explore in this recipe can be tackled using assets that you can find both as part of the Starter Content or using the Unreal Engine project provided alongside this book. With that in mind, let me leave you with a link to the location of the UE project:

https://packt.link/A6PL9

Playing a video on an in-game TV

Something that amazed me back when I started to play video games was the fact that it was possible to display videos within those same games; it felt like the designers had woven another layer of interactivity to trick our brains into thinking that the worlds they had created were truly real. Videos within videos – that’s something that left me starstruck back in the day!

Honoring that memory, we’ll now proceed to tackle how to create a working television display and how to play back any videos that you might want to show using Unreal Engine’s media player capabilities, which allow us to use videos as textures. Buckle up for the ride!

Getting ready

Seeing as the main goal of this recipe is going to be streaming a video on an in-game TV, the two things that we are going to need are a 3D model of a screen and a video file. As always, you have the option to use the assets provided alongside the Unreal Engine project...

Capturing the scene through a CCTV camera

As we’ve seen by now, materials usually work hand in hand with textures to drive certain material parameters. Those usually come in different shapes and sizes: sometimes, textures are static 2D images that we use to drive the appearance of a model, while on other occasions we might rely on video files to create the effect of an animated sequence (as we saw in the last recipe).

Beyond those two examples, there is yet another type that doesn’t rely on existing data, but one that allows us to capture what is happening inside the level. This is called a Scene Capture component, and it allows us to create interesting functionalities, such as displaying what a camera placed inside our scene would see – mimicking the behavior of a CCTV camera. In this recipe, we’ll study how to work with this type of asset, known as Scene Capture, and how to put it to good use inside our materials.

Getting ready

Most of the assets...

Highlighting interactive elements

So far, we’ve had the opportunity to work with various materials; some of them more traditional, as seen in previous chapters, and some others more disruptive, as we are starting to see. Continuing with that trend, we are now going to take a look at a different type of shader that we haven’t yet tackled in this book.

I‘m talking about post process materials – a type of asset that taps into the post-processing pipeline that Unreal has in place, enabling us to create some very cool and interesting effects. We’ll explore one such example in the following pages, using it to highlight interactive elements within our games and apps. Let’s get started!

Getting ready

You’ll soon find out that the material we are about to create relies largely on math nodes and scripting, which means that there are not a lot of custom assets, such as textures or models, needed to tackle this recipe. As a consequence...

Creating snow on top of objects using layered materials

Introduced in a later version of Unreal Engine 4, material layers are a technique that takes different types of materials and puts them together using an easy-to-use interface. The layering mechanism comes with no additional pixel shader instructions, so relying on this technique doesn’t hinder our apps or games’ performance.

To see just how easy it is to put this together, we are going to see how we can use this concept to add snow to the top of a material based on the world. Let’s see how next!

Getting ready

Everything we’ll use in this recipe is part of the engine or provided as part of the Starter Content, so make sure that you have that in your project. And as always, feel free to open the level called 08_04_Start if you want to continue using the same assets I’ll employ. See you in a sec!

How to do it…

Creating a material layer is going to be very easy, so let’...

Changing a sunny scene to a snowy one with a parameter collection asset

One common issue faced by artists is making multiple materials change at the same time. We’ve already learned about parameters and how we can change them at runtime using Blueprints, in the recipe called Orienting ourselves with a compass back in Chapter 5. Having said so, we had to change each material parameter individually, which isn’t ideal when dealing with a large number of materials.

Material Parameter Collection actors allow us to create special variables that can be referenced across multiple materials and then modified either inside the editor or at runtime, through both Blueprints and/or C++. To see just how easily those can be used, we’ll see how we can make multiple materials change at the same time in this recipe, giving the impression that it has snowed in the level with which we’ll be working.

Getting ready

Material Parameter Collections are a type of asset that...

Moving between seasons using curve atlases

In our journey through Unreal’s material repertoire, we sometimes find ourselves using different types of parameters. Just in the last recipe, we looked at how we could garner the strength of both the Scalar and Vector types through the use of a Material Parameter Collection asset. Having said so, the two types of variables available there are best suited to drive certain fixed properties, such as the Roughness value used by a shader or the color needed to be displayed on a specific material.

More nuanced types of data can also be parameterized in Unreal thanks to the use of curves. These are special types of assets that can hold different values, meant to give a range of options as opposed to a single one. In this recipe, we’ll take advantage of that characteristic by creating a material that can sample different values from a single curve. We’ll use that feature to create a material that can display the most common...

Blending landscape materials

As we’ve seen throughout this book, materials can be used in plenty of places: in 3D models, in UI elements, as rendering passes, and so on. Another place where they are extremely useful is in landscape objects, a special category of 3D models that differ from standard 3D meshes in the way they are created. Unlike traditional static meshes, landscapes are usually huge in size, so the way we texture them needs to be inherently different just because of that reason.

To tackle that problem, Unreal comes bundled with a very powerful landscape system that allows you to have a single material that can blend between various textures through the use of the Landscape Layer Blend node. In this recipe, we will explore how to create and apply such a material.

Getting ready

Seeing how we’ll be working with landscapes, make sure that the level you decide to work on contains one such asset. If you don’t want to create one, feel free to open...

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