Understanding the Difference Between Shaders and Materials

gaming unity unreal engine Sep 14, 2023
Understanding the Difference Between Shaders and Materials - Featured

 

Shaders and Materials are terms often tossed around interchangeably, but there are differences between the two. 

Let's talk about shaders and materials, the difference between the two, and how to think about these systems and workflows when approaching your next project.

What's the short answer? Well, the primary difference between a shader and a material is that shaders technically deal with how an object interacts with light, while materials deal with how the object looks and feels.

That's still a bit of an oversimplification, but it's necessary to start there. Confusion also stems from the difference between Unity and Unreal Engine and how they use different terminology. More on that in a bit. First, let's dive into Shaders.  

 

Understanding Shaders

Shaders are one of the most powerful tools you can use to create memorable FX and environmental assets. They can be technical, which can be intimidating, but we're going to try and simplify things for those more interested in the artistic side vs. the technical side of effects. 

Think of a shader as a program that tells a machine how to render an object. 

If you think about how a game engine takes a camera and renders out a scene, for every pixel that's on the screen, the “camera” will shoot out a ray. It will do so until the ray hits an object and then looks at the material that’s applied to that object.

 

 

Then it runs the shader calculations to determine what color it should render and display. This will continue until every pixel on the screen for every frame has been rendered. It's a program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene.

Now, not to further confuse you, but you should know that shaders have evolved to perform a variety of specialized functions in graphics, visual effects, and video post-processing, as well as general-purpose computing on GPUs (Graphics Processing Units). 

For this post, we're just going to focus on shaders for VFX in game engines. The key takeaway is that shaders determine which colors belong on the surface of an object, but you cannot apply a shader directly to an object. You need to apply materials to objects. 

Now originally, Shaders were created by writing code. Unity created the Shader Graph so artists and non-programmers could create shaders without all of the technical knowledge previously required.

Check out the Basics of the Shader Graph tutorial from Brackeys.

 

 

The Shader Graph allows visual artists to easily create shaders without having to code every aspect. 

 

 

An important element of the art of shaders is the use of color. Every color you see on the screen is created by combining three colors of light; red, green, and blue. Combining these three in some form or variation can produce any color you need to display on a monitor. 

 

 

If you want an example of a basic Shader, you can see above the two textures that make up the shader. For this example, we’re just adding one texture to the other using the same UV coordinates. They match up perfectly allowing us to combine the two. 

Another way to edit and customize a shader is through the emissive values. The emissive values tell us how much light is being emitted from any point on the surface. For this example, as you can see with this sphere, the whole thing is wrapped up in emissive values.

 

 

This is typically used when creating something like a neon sign, a magical orb, the glow from a fire, or even a lightsaber! However, it's important to know that emissive values on a surface do not truly emit light, this is simply just a post-processing effect applied to the sphere. Lighting is expensive to calculate! Using an actual light and calculating every point on the surface would be near impossible. To create the illusion of light, we typically add a “glow” to give off the appearance of illumination. 

The surfaces around your object will not be receiving light. You can however add a single light to the emissive surface (with the glow applied) and it will project the necessary light outward onto your surrounding surfaces. We call this process and effect “bloom”.

 

Understanding Materials

Now that we’ve talked about Shaders, let’s briefly discuss Materials and how they work with Shaders. First, a material hooks into a Shader and then uses that shader to render itself. 

Materials determine the blending, transparency, and colors of your particles and objects. This is the true creative side of FX work, creating materials that will be attached to shaders to be rendered out in games. You can adjust, scale, or combine textures in your materials to create amazing FX. 

 

 

So you can have one shader driven by multiple Materials and we can create different materials which are different variations of the same Shader. We've heard Materials referred to as "paint" that you apply to your object. There are pre-built materials you can apply to your object or character, or you can create the Materials yourself. 

In general, a Shader is always the math underneath each material. Materials have a broader definition based on the Engine you are using. This is the main point of confusion between Shaders and Materials between Unreal and Unity.

Unity takes the original meaning of the terms and enforces their use. You create a shader first, then create a material from it that you then apply to your mesh or particle system. Unreal is a little less rigid with this approach.  

In Unreal you create a "Material" that you then can use right away. Although it will still follow the same "rules". All objects with this Material applied to it will look and behave the same. To create more individual looks with the same underlying logic you have to create new Material instances, in which you then can change your parameter without affecting the base Material. 

You can take a look at how Materials are used and are planned to be used in the coming years with Unreal Engine's latest update. 

 

 

Shaders and Materials are two puzzle pieces that fit together to help your FX end up looking better, more believable, and more accurate on screen. 

 

Shader and Material FX Courses

Want to truly dive into what makes shaders and materials? We have two courses inside of VFX Apprentice All Access dedicated to materials in Unreal Engine 5 and Shaders in Unity

 

Start Your VFX Apprenticeship

Begin your journey towards mastering FX for games and animation. Join VFX-A All Access and discover cutting-edge 2D, 3D, and real-time FX training. 

Browse FX Courses

Learn from Professional VFX Artists

Our instructors have left their mark on AAA titles, indie games, animated films, television series, mobile games, and experiential events. They are here to help you make your own mark.

View All Instructors