Book Image

Become a Unity Shaders Guru

By : Mina Pêcheux
5 (1)
Book Image

Become a Unity Shaders Guru

5 (1)
By: Mina Pêcheux

Overview of this book

Do you really know all the ins-and-outs of Unity shaders? It’s time to step up your Unity game and dive into the new URP render pipeline, the Shader Graph tool, and advanced shading techniques to bring out the beauty of your 2D/3D game projects! Become a Unity Shaders Guru is here to help you transition from the built-in render pipeline to the SRP pipelines and learn the latest shading tools. With it, you’ll dive deeper into Unity shaders by understanding the essential concepts through practical examples. First, you’ll discover how to create a simple shading model in the Unity built-in render pipeline, and then in the Unity URP render pipeline and Shader Graph while learning about the practical applications of both. You’ll explore common game shader techniques, ranging from interior mapping to adding neon outlines on a sprite or simulating the wobble of a fish. You’ll also learn about alternative rendering techniques, like Ray Marching. By the end of this book, you’ll have learned to create a wide variety of 2D and 3D shaders with Unity’s URP pipeline (both in HLSL code and with the Shader Graph tool), and be well-versed with some optimization tricks to make your games friendly for low-tier devices as well.
Table of Contents (23 chapters)
1
Part 1: Creating Shaders in Unity
3
Part 2: Stepping Up to URP and the Shader Graph
8
Part 3: Advanced Game Shaders
12
Part 4: Optimizing Your Unity Shaders
15
Part 5: The Toolbox

What this book covers

Chapter 1, Re-Coding a Basic Blinn-Phong Shader with Unity/CG, gives a quick reminder on how to create shaders in Unity with the built-in render pipeline and the Nvdia Cg language.

Chapter 2, The Three Unity Render Pipelines, details the differences between Unity’s built-in render pipeline and the two new render pipelines: the URP and the High-Definition Render Pipeline (HDRP).

Chapter 3, Writing Your First URP Shader, introduces the fundamentals of writing shaders for the new URP pipeline using HLSL instead of Cg.

Chapter 4, Transforming Your Shader into a Lit PBS Shader, builds on the previous chapter and shows how to integrate physically based shading in your URP shaders.

Chapter 5, Discovering the Shader Graph with a Toon Shader, introduces Unity’s new node-based visual shader editing tool, Shader Graph, and explains how to use it with a common example of custom shading – toon cel-shading.

Chapter 6, Simulating Geometry Efficiently, covers a few techniques for cleverly giving the illusion of extra geometry while maintaining correct real-time performance, such as billboarding, parallax mapping, and interior mapping.

Chapter 7, Exploring the Unity Compute Shaders and Procedural Drawing, discusses what compute shaders are and how we can use them to offload computation from the CPU to the GPU and increase the performance of our games.

Chapter 8, The Power of Ray Marching, dives into an alternative rendering method where you build your entire scene just using mathematics!

Chapter 9, Shader Compilation, Branching, and Variants, shifts the focus to shader optimization and tells you how you can use various keywords in your shaders to improve the performance of your final game after the build.

Chapter 10, Optimizing Your Code or Making Your Own Pipeline?, adds to the knowledge of the previous chapter and offers another set of tricks for optimizing your shaders, as well as a basic overview of custom render pipelines.

Chapter 11, A Little Suite of 2D Shaders, takes you through the creation of a series of shaders for your sprites ranging from simple color-swapping to outlining or dissolving effects.

Chapter 12, Vertex Displacement Shaders, explains how to use the vertex displacement technique to create procedural animations or simulate the waves on a water plane.

Chapter 13, Wireframes and Geometry Shaders, teaches you about geometry shaders and highlights the limitations of this tool, especially when targeting Mac users, before taking you through a common application of the technique to create a wireframe render.

Chapter 14, Screen Effect Shaders, wraps up this book by discussing fullscreen shaders, which make it easy to apply screen-wide effects and make a personal atmosphere for your game.

Appendix: Some Quick Refreshers on Shaders in Unity, compiles a few handy worth-remembering base concepts for creating shaders in Unity, be it with the built-in render pipeline or the new URP and HDRP pipelines.