Unity 2021 Shaders and Effects Cookbook - Fourth Edition

Book description

Overcome the challenges and complexities involved in creating your own shaders with high-level realism using practical solutions, best practices, and the latest features of Unity 2021

Key Features

  • Discover practical recipes for mastering post-processing effects and advanced shading techniques
  • Learn the secrets of creating AAA quality shaders without writing long algorithms
  • Create visually stunning effects for your games using Unity's VFX Graph

Book Description

Shaders enable you to create powerful visuals for your game projects. However, creating shaders for your games can be notoriously challenging with various factors such as complex mathematics standing in the way of attaining the level of realism you crave for your shaders.

The Unity 2021 Shaders and Effects Cookbook helps you overcome that with a recipe-based approach to creating shaders using Unity. This fourth edition is updated and enhanced using Unity 2021 features and tools covering Unity's new way of creating particle effects with the VFX Graph. You'll learn how to use VFX Graph for advanced shader development. The book also features updated recipes for using Shader Graph to create 2D and 3D elements. You'll cover everything you need to know about vectors, how they can be used to construct lighting, and how to use textures to create complex effects without the heavy math. You'll also understand how to use the visual-based Shader Graph for creating shaders without any code.

By the end of this Unity book, you'll have developed a set of shaders that you can use in your Unity 3D games and be able to accomplish new effects and address the performance needs of your Unity game development projects. So, let's get started!

What you will learn

  • Use physically based rendering to fit the aesthetic of your game
  • Create spectacular effects for your games by testing the limits of what shaders can do
  • Explore advanced shader techniques for your games with AAA quality
  • Use Shader Graph to create 2D and 3D elements for your games without writing code
  • Master the math and algorithms behind the commonly used lighting models
  • Get to grips with the Post-Processing Stack to tweak the appearance of your game

Who this book is for

This book is for game developers who want to start creating their first shaders in Unity 2021 and take their game to a whole new level by adding professional post-processing effects. The book assumes intermediate-level knowledge of Unity.

Table of contents

  1. Unity 2021 Shaders and Effects Cookbook
  2. Fourth Edition
  3. Contributors
  4. About the author
  5. About the reviewers
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
    4. Download the color images
    5. Conventions used
    6. Sections
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    7. Get in touch
    8. Share Your Thoughts
  7. Chapter 1: Post Processing Stack
    1. Technical requirements
    2. Installing the Post Processing Stack
      1. Getting ready
      2. How to do it...
    3. Getting a filmic look using grain, vignetting, and depth of field
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Mimicking real life with bloom and anti-aliasing
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Setting the mood with color grading
      1. Getting ready
      2. How to do it...
    6. Creating a horror game look with fog
      1. Getting ready
      2. How to do it...
      3. How it works...
  8. Chapter 2: Creating Your First Shader
    1. Technical requirements
    2. Creating a basic Standard Shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Adding properties to a shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    4. Using properties in a Surface Shader
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
  9. Chapter 3: Working with Surface Shaders
    1. Technical requirements
    2. Implementing diffuse shading
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Accessing and modifying packed arrays
      1. How to do it...
      2. There's more...
      3. See also
    4. Creating a shader with normal mapping
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Creating a Holographic Shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  10. Chapter 4: Working with Texture Mapping
    1. Technical requirements
    2. Adding a texture to a shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Scrolling textures by modifying UV values
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating a transparent material
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Packing and blending textures
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a circle around your terrain
      1. Getting ready…
      2. How to do it...
      3. How it works...
      4. There's more…
  11. Chapter 5: Understanding Lighting Models
    1. Technical requirements
    2. Creating a custom diffuse lighting model
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Creating a toon shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Creating a Phong Specular type
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a Blinn-Phong Specular type
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Creating an Anisotropic Specular type
      1. Getting ready
      2. How to do it...
      3. How it works...
  12. Chapter 6: Physically Based Rendering
    1. Technical requirements
    2. Understanding the metallic setup
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Adding transparency to PBR
      1. Getting ready
      2. How to do it...
        1. Semi-transparent materials
        2. Fading objects
        3. Solid geometries with holes
      3. See also
    4. Creating mirrors and reflective surfaces
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Baking lights into your scene
      1. Getting ready
      2. How to do it...
        1. Configuring the static geometry
        2. Configuring the light probes
        3. Baking the lights
      3. How it works...
      4. See also
  13. Chapter 7: Vertex Functions
    1. Technical requirements
    2. Accessing a vertex color in a Surface Shader
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    3. Animating vertices in a Surface Shader
      1. Getting ready
      2. How to do it…
      3. How it works…
    4. Extruding your models
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
        1. Adding extrusion maps
    5. Implementing a snow shader
      1. Getting ready
      2. How to do it…
      3. How it works…
        1. Coloring the surface
        2. Altering the geometry
      4. See also
    6. Implementing a volumetric explosion
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
  14. Chapter 8: Fragment Shaders and Grab Passes
    1. Technical requirements
    2. Understanding Vertex and Fragment Shaders
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
        1. Input semantics
        2. Output semantics
      5. See also
    3. Using grab passes to draw behind objects
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    4. Implementing a Glass Shader
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
    5. Implementing a Water Shader for 2D games
      1. Getting ready
      2. How to do it…
      3. How it works…
  15. Chapter 9: Mobile Shader Adjustment
    1. Technical requirements
    2. Techniques to make shaders more efficient
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Profiling your shaders
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Modifying our shaders for mobile
      1. Getting ready
      2. How to do it...
      3. How it works...
  16. Chapter 10: Screen Effects with Unity Render Textures
    1. Technical requirements
    2. Setting up a screen effects script system
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Using brightness, saturation, and contrast with screen effects
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Using basic Photoshop-like Blend Modes with screen effects
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Using the Overlay Blend Mode with screen effects
      1. How to do it...
      2. How it works...
  17. Chapter 11: Gameplay and Screen Effects
    1. Technical requirements
    2. Creating an old movie screen effect
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Creating a night-vision screen effect
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  18. Chapter 12: Advanced Shading Techniques
    1. Technical requirements
    2. Using Unity's built-in CgInclude files
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Making your shader work in a modular way with CgInclude
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Implementing a Fur Shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Implementing Heatmaps with arrays
      1. Getting ready
      2. How to do it...
      3. How it works...
  19. Chapter 13: Shader Graph – 2D
    1. Technical requirement
    2. Creating a URP-based Shader Graph project
      1. How to do it...
      2. How it works...
    3. Implementing a simple Shader Graph
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Exposing properties to the Inspector via Shader Graph
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Creating a Sprite Outline Shader
      1. Getting ready
      2. How to do it...
      3. How it works...
  20. Chapter 14: Shader Graph – 3D
    1. Technical requirements
    2. Implementing a glowing highlight system
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Portal Shaders in Unity
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Creating custom Shader Graph functions
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Why subscribe?
  21. Other Books You May Enjoy
    1. Packt is searching for authors like you
    2. Share Your Thoughts

Product information

  • Title: Unity 2021 Shaders and Effects Cookbook - Fourth Edition
  • Author(s): John P. Doran
  • Release date: October 2021
  • Publisher(s): Packt Publishing
  • ISBN: 9781839218620