Shaders and Materials - Overview

Tutorial

·

intermediate

·

+0XP

·

5 mins

·

(85)

Unity Technologies

Shaders and Materials - Overview

In this tutorial, we will define the role that shaders and materials play in rendering the 3D objects our project, along with the learning objectives for this project.

Languages available:

1. Overview

Shaders and Materials play a crucial role in determining how target hardware will process and render your 3D objects, so it’s important to understand how they function and can be optimized. If your Materials or Shaders aren’t configured correctly, it can result in severe bottlenecks that can strain mobile devices’ already limited resources.


In this project, you will:


  • Learn about optimized mobile Shaders that play well with Unity’s Universal Render Pipeline.

  • Compare different transparency implementations and their respective benefits/payoffs.

  • Explore best practices that will keep the shaders lightweight and fast when running on phones with limited resources.

2. What are Shaders and Materials?

A Shader is a small program that tells the GPU how to draw an object on the screen and every calculation that must happen in order to draw the object. For writing Shaders, there are two common scripting languages: High-Level Shading Language (HLSL) and OpenGL Shading language (GLSL).


Shaders are applied to GameObjects through Materials that define the look of that object. A Material is used to set the parameters made available by a Shader. For example, a Material might specify the colors, Textures, and numeric values referenced by a Shader.


The following screenshot shows an HLSL Shader applied to a Material in Unity:



Unity also provides a node-based tool called Shader Graph that lets you build your Shaders visually instead of via hand-written code. The following screenshot shows how you can build a Shader Graph by creating and connecting nodes in a graph network:



3. Conclusion

Materials and Shaders are a core part of the 3D rendering process; understanding how they work is essential to the optimization process. In the next tutorial, we’ll explore the best practices for optimizing Shaders for mobile platforms.


Complete this tutorial