Unity 2021 Shaders and Effects Cookbook
eBook - ePub

Unity 2021 Shaders and Effects Cookbook

Over 50 recipes to help you transform your game into a visually stunning masterpiece, 4th Edition

John P. Doran

  1. 484 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Unity 2021 Shaders and Effects Cookbook

Over 50 recipes to help you transform your game into a visually stunning masterpiece, 4th Edition

John P. Doran

Book details
Book preview
Table of contents
Citations

About This Book

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.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Unity 2021 Shaders and Effects Cookbook an online PDF/ePUB?
Yes, you can access Unity 2021 Shaders and Effects Cookbook by John P. Doran in PDF and/or ePUB format, as well as other popular books in Informatica & Programmazione di giochi. We have over one million books available in our catalogue for you to explore.

Information

Year
2021
ISBN
9781839217692

Chapter 1: Post Processing Stack

It's great to write your own shaders and effects and fine-tune your project so that it looks just the way that you want it to, and this is what we will be spending the majority of the book looking into. However, it's also good to point out that Unity already comes with some prebuilt ways to get some of the more common effects that users like to have; users can implement these effects by using the Post Processing Stack.
For those who just want to get something up and running, the Post Processing Stack can be an excellent way for you to tweak the appearance of your game without having to write any additional code. Using the Post Processing Stack can also be useful in showing you what shaders can do and how they can improve your game projects as, behind the scenes, the Post Processing Stack provides several shaders as well as scripts that are applied to the screen via the aptly named screen shader.
In this chapter, we will cover the following recipes:
  • Installing the Post Processing Stack
  • Getting a filmic look using grain, vignetting, and depth of field
  • Mimicking real life with bloom and anti-aliasing
  • Setting the mood with color grading
  • Creating a horror game look with fog

Technical requirements

You can find the code files for this chapter on GitHub at https://github.com/PacktPublishing/Unity-2021-Shaders-and-Effects-Cookbook-Fourth-Edition/tree/main/Shaders-and-Effects-Cookbook-2021/Assets/Chapter%2001.

Installing the Post Processing Stack

Before we can use the Post Processing Stack, we must get it from the Package Manager. A Unity package is a single file that contains various assets that can be used in Unity, similar to a ZIP file. Previously, Unity used the Asset Store to share these files with users, but with time, the Package Manager has been added to give users an easy way to get free content from Unity. We will be using the Package Manager again in Chapter 13, Shader Graph – 2D, but for now, we will be using it for the Post Processing package that it contains.

Getting ready

To get started with this recipe, you will need to have Unity running and have created a new project with the 3D template. This chapter also requires you to have an environment to work from. The code files provided with this book contain a .unitypackage file called Chapter1_StartingPoint.unitypackage in the Unity Packages folder. It contains a basic scene and content for creating the scene with Unity's Standard Assets.
Open the Chapter 1 | Starting Point scene inside the Asset | Chapter 01 | Scenes folder from the Project browser. If all goes well, you should see something like this from the Game tab:
Figure 1.1 – Starting point scene
Figure 1.1 – Starting point scene
This is a simple environment that will allow us to easily see how changes that have been made with post-processing effects can modify how things are drawn on the screen.
Note
If you are interested in learning how to create the environment we've used here, check out my previous book, Unity 5.x Game Development Blueprints, also available from Packt Publishing.

How to do it...

To get started, follow these steps:
  1. Open Package Manager by going to Window | Pa...

Table of contents

  1. Unity 2021 Shaders and Effects Cookbook
  2. Fourth Edition
  3. Preface
  4. Chapter 1: Post Processing Stack
  5. Chapter 2: Creating Your First Shader
  6. Chapter 3: Working with Surface Shaders
  7. Chapter 4: Working with Texture Mapping
  8. Chapter 5: Understanding Lighting Models
  9. Chapter 6: Physically Based Rendering
  10. Chapter 7: Vertex Functions
  11. Chapter 8: Fragment Shaders and Grab Passes
  12. Chapter 9: Mobile Shader Adjustment
  13. Chapter 10: Screen Effects with Unity Render Textures
  14. Chapter 11: Gameplay and Screen Effects
  15. Chapter 12: Advanced Shading Techniques
  16. Chapter 13: Shader Graph – 2D
  17. Chapter 14: Shader Graph – 3D
  18. Other Books You May Enjoy