Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Unity 2021 Shaders and Effects Cookbook

You're reading from   Unity 2021 Shaders and Effects Cookbook Over 50 recipes to help you transform your game into a visually stunning masterpiece

Arrow left icon
Product type Paperback
Published in Oct 2021
Publisher Packt
ISBN-13 9781839218620
Length 484 pages
Edition 4th Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
John P. Doran John P. Doran
Author Profile Icon John P. Doran
John P. Doran
Arrow right icon
View More author details
Toc

Table of Contents (16) Chapters Close

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

Implementing a Water Shader for 2D games

The Glass Shader that we introduced in the previous recipe is static; its distortion never changes. It takes just a few changes to convert it into an animated material, making it perfect for 2D games that feature water. This uses a similar technique to the one shown in Chapter 7, Vertex Functions, in the Animating Vertices in a Surface Shader recipe:

Figure 8.11 – The result of the following recipe

Getting ready

This recipe is based on the Vertex and Fragment Shaders described in the Using grab passes to draw behind objects recipe, as it will rely heavily on GrabPass. Let's get started:

  1. Create a new Vertex and Fragment Shader. You can start by copying the one used in the previous recipe, Using grab passes to draw behind objects, as a base (GrabShader) by selecting it and hitting Ctrl + D to duplicate it. Once duplicated, change its name to 2DWaterShader.
  2. Create a material that will use the...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image