Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Unity 2018 Shaders and Effects Cookbook
Unity 2018 Shaders and Effects Cookbook

Unity 2018 Shaders and Effects Cookbook: Transform your game into a visually stunning masterpiece with over 70 recipes , Third Edition

Arrow left icon
Profile Icon John P. Doran Profile Icon Alan Zucconi
Arrow right icon
€32.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (8 Ratings)
eBook Jun 2018 392 pages 3rd Edition
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
Arrow left icon
Profile Icon John P. Doran Profile Icon Alan Zucconi
Arrow right icon
€32.99
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9 (8 Ratings)
eBook Jun 2018 392 pages 3rd Edition
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m
eBook
€32.99
Paperback
€41.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
Table of content icon View table of contents Preview book icon Preview Book

Unity 2018 Shaders and Effects Cookbook

Creating Your First Shader

In this chapter, you will learn about the following recipes:

  • Creating a basic Standard Shader
  • Adding properties to a shader
  • Using properties in a Surface Shader

Introduction

This chapter will cover some of the more common diffuse techniques found in today's game development shading pipelines. Let's imagine a cube that has been painted white uniformly in a 3D environment with a directional light. Even if the color used is the same on each face, they will all have different shades of white on them depending on the direction that the light is coming from and the angle that we are looking at it from. This extra level of realism is achieved in 3D graphics through the use of shaders, special programs that are mostly used to simulate how light works. A wooden cube and a metal one may share the same 3D model, but what makes them look different is the shader that they use.

This first chapter will introduce you to shader coding in Unity. If you have little to no previous experience with shaders, this chapter is what you need in order...

Creating a basic Standard Shader

In Unity, when we create a game object, we then attach additional functionality through the use of components. In fact, every game object is required to have a Transform component; there are a number of components included in Unity already, and we create components of our own when we write scripts that extend from MonoBehaviour.

All the objects that are part of a game contain a number of components that affect their look and behavior. While scripts determine how objects should behave, renderers decide how they should appear on the screen. Unity comes with several renderers, depending on the type of object that we are trying to visualize; every 3D model typically has a MeshRenderer component attached to it. An object should have only one renderer, but the renderer itself can contain several materials. Each material is a wrapper for a single shader...

Adding properties to a shader

Properties of a shader are very important for the shader pipeline as they are the method that you use to let the artist or user of the shader assign textures and tweak your shader values. Properties allow you to expose GUI elements in a material's Inspector tab without you having to use a separate editor, which provides visual ways to tweak a shader. With your shader opened in your IDE of choice, look at the block of lines two through seven. This is called the Properties block of the script. Currently, it will have one texture property in it called _MainTex.

If you look at your material that has this shader applied to it, you will notice that there is one texture GUI element in the Inspector tab. These lines of code in our shader are creating this GUI element for us. Again, Unity has made this process very efficient in terms of coding and the...

Using properties in a Surface Shader

Now that we have created some properties, let's actually hook them up to the shader so that we can use them as tweaks to our shader and make the material process much more interactive. We can use the Properties values from the material's Inspector tab because we have attached a variable name to the property itself, but in the shader code, you have to set up a couple of things before you can start calling the value by its variable name.

How to do it...

The following steps show you how to use the properties in a Surface Shader:

  1. Continuing from the previous example, let's create another shader with the name ParameterExample. Just like before, remove the _MainTex property in...
Left arrow icon Right arrow icon

Key benefits

  • • 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

Description

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.

Who is this book 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

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jun 29, 2018
Length: 392 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788390958
Languages :
Concepts :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want

Product Details

Publication date : Jun 29, 2018
Length: 392 pages
Edition : 3rd
Language : English
ISBN-13 : 9781788390958
Languages :
Concepts :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 124.97
Unity 2018 Shaders and Effects Cookbook
€41.99
Unity 2018 Artificial Intelligence Cookbook
€36.99
Unity 2018 Cookbook
€45.99
Total 124.97 Stars icon

Table of Contents

13 Chapters
Post Processing Stack Chevron down icon Chevron up icon
Creating Your First Shader Chevron down icon Chevron up icon
Surface Shaders and Texture Mapping Chevron down icon Chevron up icon
Understanding Lighting Models Chevron down icon Chevron up icon
Physically-Based Rendering Chevron down icon Chevron up icon
Vertex Functions Chevron down icon Chevron up icon
Fragment Shaders and Grab Passes Chevron down icon Chevron up icon
Mobile Shader Adjustment Chevron down icon Chevron up icon
Screen Effects with Unity Render Textures Chevron down icon Chevron up icon
Gameplay and Screen Effects Chevron down icon Chevron up icon
Advanced Shading Techniques Chevron down icon Chevron up icon
Shader Graph Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Half star icon Empty star icon Empty star icon 2.9
(8 Ratings)
5 star 25%
4 star 12.5%
3 star 25%
2 star 0%
1 star 37.5%
Filter icon Filter
Top Reviews

Filter reviews by




thomas Feb 08, 2019
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Great book, for those of you looking to learn some shader programming and are like me where you dont know where to start then this book is for you, i like how it takes you through set up and also provides demo materials which you can use as a guide or if you get stuck
Amazon Verified review Amazon
Adr Kindle Oct 17, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
I'm a professional web developer who's been into game programming for some time. Most Unity books cover 3D objects manipulation, game dynamics, etc. but they rarely touch on shaders' internals. Things like screen effects, different lighting types, liquids, fur, explosions - all seem like some kind of magic, written in a language with weird syntax and semantics that only few people understand.I've been trying to follow YouTube tutorials on writing shaders, reading blogs and articles, but always felt like I only understand a tiny piece of the puzzle. I was missing a holistic view and I couldn't find a good resource which would cover everything.This book is exactly what I've been looking for. It moves fast - reader is treated as a professional who doesn't need hundreds of examples for one topic - but it's also thorough. When you use a variable type, it tells you what other types there are and where to read about them more. It covers every topic I wanted to learn about plus some more. After reading the first few chapters I was already writing my own shaders, even coming up myself with ideas that were actually covered later in the book.The only thing that some readers may not like at first is the format of chapters. They follow this scenario: setting up a project, writing all of the code, running it, and then the explanation of what's going on. I'm personally more used to story-type tutorials where concepts are eased into. But very quickly I realised the potential of the approach this book takes. Every chapter is an entity of its own, allowing you to quickly come back to a specific topic when you need it, and gives you everything you need to see the concept in action.If you're a non-beginner software developer who wants to holistically understand shaders and write your own, this book is definitely worth reading.
Amazon Verified review Amazon
かるばどす Oct 29, 2018
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
例を示して動作を示す説明スタイルは、エントリーとしてとても解り易いです。残な点として、updateが最新に対応しきれていない点があり、ちょっと戸惑う点がある事です。まだunityで開発中の機能を説明しているので、タイムリーな更新が期待されます。
Amazon Verified review Amazon
M. HertZ Mar 12, 2019
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
It’s a decent primer if you’ve never worked with shader code before. The author does a decent job explaining the fundamentals of writing shader code. However for the price of the book and its subject, its pretty dissapointing that the images are low quality and in black and white. Furthermore getting the source code to follow along with the recipes is a pain. The publishers website provides confusing and inaccurate instructions. If you’re tired of reading blog posts and online tutorials then this book might be worth it for you.
Amazon Verified review Amazon
Amazon カスタマー Dec 22, 2019
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
シェーダーやポストプロセスの良い本だとは思うのですが、グラフィックスを扱う本なのにまさかのモノクロです。カラーページは一切ありません。それと当然ながら英語のみなので、注意してください。
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.