Unity 2018 Shaders and Effects Cookbook

Book description

Bring realism to your games by mastering post-processing effects and advanced shading techniques in Unity 2018

About This Book
  • Learn the secrets of creating AAA quality shaders without writing long algorithms
  • Master shader programming through easy-to-follow examples
  • Create stunning visual effects that can be used in 3D games
Who This Book Is For

Unity Shaders and Effects Cookbook is for developers who want to create their first shaders in Unity 2018 or wish to take their game to a whole new level by adding professional post-processing effects. A solid understanding of Unity is required to get the most from this book.

What You Will Learn
  • Understand physically based rendering to fit the aesthetic of your game
  • Write shaders from scratch in ShaderLab and HLSL/Cg
  • Combine shader programming with interactive scripts to add life to your materials
  • Design efficient shaders for mobile platforms without sacrificing their realism
  • Use state-of-the-art techniques, such as volumetric explosions and fur shading
  • Master the math and algorithms behind the most used lighting models
  • Understand how shader models have evolved and how you can create your own
In Detail

Since their introduction to Unity, shaders have been seen as notoriously difficult to understand and implement in games. Complex mathematics has always stood in the way of creating your own shaders and attaining the level of realism you crave.

Unity 2018 Shaders and Effects Cookbook changes that by giving you a recipe-based guide to creating shaders using Unity. It will show you everything you need to know about vectors, how lighting is constructed with them, and how textures are used to create complex effects without the heavy math.

This book starts by teaching you how to use shaders without writing code with the post-processing stack. Then, you'll learn how to write shaders from scratch, build up essential lighting, and finish by creating stunning screen effects just like those in high-quality 3D and mobile games. You'll discover techniques, such as normal mapping, image-based lighting, and animating your models inside a shader. We'll explore how to use physically based rendering to treat light the way it behaves in the real world. At the end, we'll even look at Unity 2018's new Shader Graph system.

With this book, what seems like a dark art today will be second nature by tomorrow.

Style and approach

The recipes in this book contain step-by-step instructions, complemented with screenshots, code, and real-world examples.

Table of contents

  1. Title Page
  2. Copyrights and Credits
    1. Unity 2018 Shaders and Effects Cookbook Third Edition
  3. PacktPub.com
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the authors
    2. About the reviewers
    3. Packt is searching for authors like you
  5. 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
      2. Download the color images
      3. Conventions used
    4. Sections
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Get in touch
      1. Reviews
  6. Post Processing Stack
    1. Introduction
    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 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...
  7. Creating Your First Shader
    1. Introduction
    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
  8. Surface Shaders and Texture Mapping
    1. Introduction
    2. 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. 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
    5. Scrolling textures by modifying UV values
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Creating a shader with normal mapping
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Creating a transparent material
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Creating a Holographic Shader
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    9. Packing and blending textures
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Creating a circle around your terrain
      1. Getting ready
      2. How to do it...
        1. Moving the circle
      3. How it works...
  9. Understanding Lighting Models
    1. Introduction
    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 BlinnPhong 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...
  10. Physically-Based Rendering
    1. Introduction
    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 in 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
  11. Vertex Functions
    1. Introduction
    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
  12. Fragment Shaders and Grab Passes
    1. Introduction
    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 the grab pass 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...
  13. Mobile Shader Adjustment
    1. Introduction
    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...
  14. Screen Effects with Unity Render Textures
    1. Introduction
    2. Setting up the 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...
  15. Gameplay and Screen Effects
    1. Introduction
    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...
  16. Advanced Shading Techniques
    1. Introduction
    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 world 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...
  17. Shader Graph
    1. Introduction
    2. Creating a Shader Graph project
      1. How to do it...
      2. How it works...
    3. Implementing a simple a 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. Implementing a glowing highlight system
      1. Getting ready
      2. How to do it...
      3. How it works...
  18. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Unity 2018 Shaders and Effects Cookbook
  • Author(s): John P. Doran, Alan Zucconi
  • Release date: June 2018
  • Publisher(s): Packt Publishing
  • ISBN: 9781788396233