Unity 2018 Shaders and Effects Cookbook
Third Edition
Transform your game into a visually stunning masterpiece with over 70 recipes
John P. Doran
Alan Zucconi
BIRMINGHAM - MUMBAI
Unity 2018 Shaders and Effects CookbookThird Edition
Copyright 2018 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Kunal Chaudhari
Acquisition Editor: Larissa Pinto
Content Development Editor: Arun Nadar
Technical Editor: Surabhi Kulkarni
Copy Editor: Safis Editing
Project Coordinator: Sheejal Shah
Proofreader: Safis Editing
Indexer: Mariammal Chettiyar
Graphics: Jason Monteiro
Production Coordinator: Arvindkumar Gupta
First published: June 2013
Second edition: February 2016
Third edition: June 2018
Production reference: 1280618
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78839-623-3
www.packtpub.com
mapt.io
Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Mapt is fully searchable
Copy and paste, print, and bookmark content
PacktPub.com
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at service@packtpub.com for more details.
At www.PacktPub.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Contributors
About the authors
John P. Doran is a passionate and seasoned technical game designer, software engineer, and author who is based in Redmond, Washington. For over a decade, John has built games in roles ranging from game designer to lead UI programmer. Additionally, John has taught game development in Singapore, South Korea, and the United States. To date, he has authored over 10 books pertaining to game development.
Thanks so much to my wife Hien and my family for all of their support while working on this book.
Alan Zucconi is a passionate developer, author, and lecturer, recognized as one of Develop's 30 under 30 . His expertise has been built over the past 10 years, working in the intersection between creativity and education. Starting in 2015, he published a series of educational tutorials for other developers and machine learning enthusiasts
About the reviewers
Andrew Hlynka is a software engineer and game developer from Windsor, Ontario, Canada. He earned his MSc degree in Computer Science in 2015 from the University of Windsor and has worked in the industry for over five years on software projects involving multimedia, interactive displays, games, mobile apps, and hybrid simulation systems. He continues his research in innovative animation techniques for games as an independent developer, publishing his projects under Dust Scratch Games.
I would like to thank my professors at the University of Windsor for their support and encouragement during my research as a student, and for introducing me to the Unity3D game engine nearly a decade ago, forever changing my workflow in the world of game development.
Michael Miles is a Manufacturing Engineer working in the aerospace industry by day and is a Unity game designer, C#, JavaScript, and Python developer at all other times. With these skills, and upon discovering Unity3D and Blender, Michael began creating interactive training and production-ready instruction tools for the assembly of the aircraft his company builds.
When not in front of the screen of a computer, he likes to play games with family and friends or immerse himself in books whose genres range from fantasy to theoretical physics.
Thanks to my parents for always being, there supporting every decision I made, however unwise you thought it was at the time.
Packt is searching for authors like you
If you're interested in becoming an author for Packt, please visit authors.packtpub.com
and apply today. We have worked with thousands of developers and tech professionals,
just like you, to help them share their insight with the global tech community. You can
make a general application, apply for a specific hot topic that we are recruiting an author
for, or submit your own idea.
Table of Contents
Preface
Unity 2018 Shaders and Effects Cookbook is your guide to becoming familiar with the creation of shaders and post-processing effects in Unity 2018. You will start your journey at the beginning, exploring the Post Processing Stack to see some of the possible ways you can use shaders to affect what you see without having to write scripts at all. Afterwards, we learn how to create shaders from scratch, starting by creating the most basic shaders and learning how the shader code is structured. This foundational knowledge will arm you with the means to progress further through each chapter, learning advanced techniques such as volumetric explosions and fur shading. We also explore the newly added Shader Graph editor to see how you can create shaders through a drag and drop interface as well! This edition of the book is written specifically for Unity 2018 and will help you to master physically-based rendering and global illumination to get as close to photorealism as possible.
By the end of each chapter, you will have gained new skills that will increase the quality of your shaders and even make your shader writing process more efficient. These chapters have been tailored so that you can jump into each section and learn a specific skill from beginner to expert. For those who are new to shader writing in Unity, you can progress through each chapter, one at a time, to build on your knowledge. Either way, you will learn the techniques that make modern games look the way they do.