2 min read

Shaders are simple programs used for graphics and effects, generally designed to run on GPU. These are specialized instruction sets than programming languages like HLSL, CG, or GLSL.

On the other hand, materials define how a surface should be rendered, by including references to the textures it uses, tiling information, color tints, and more. The available options for a material depend on which shader the material is using.

Types of Shaders

Surface Shaders: Surface Shaders in Unity is a code generation approach that makes it easier to write lit shaders than using low-level vertex/pixel shader programs. While these are widely used for modern games thanks to their robustness, they are expensive.

Vertex shaders: These perform operations on each vertex, and are very fast.

Fragment shaders: These shaders operate at the per-triangle level.

In the following video, Raymundo Barrer outlines the basic difference and relationship between shaders and materials. He also explains the material-shader connection and what a simplified 3D rendering pipeline looks like.

For more hands-on experience with relevant code samples for porting a game to mobile, adding downloadable content, and to track your game’s performance, do visit Raymundo’s course titled Hands-On Unity 2018.x Game Development for Mobile [Video]

About the author

Raymundo Barrera is a software engineer who has spent the better part of the last decade working on various serious, entertainment, and educational projects in Unity. He is currently working in education tech as director of mobile engineering at a well-known education company. You can connect with him on LinkedIn or on his personal website.

Read Next

Getting started with ML agents in Unity [Tutorial]

Working with shaders in C++ to create 3D games

Multi-agents environments and adversarial self-play in Unity [Tutorial]

Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.

* indicates required