PacktLib: Unity Shaders and Effects Cookbook

Unity Shaders and Effects Cookbook

Credits

About the Author

About the Reviewers

www.PacktPub.com

Preface

Diffuse Shading

Introduction

Creating a basic Surface Shader

Adding properties to a Surface Shader

Using properties in a Surface Shader

Creating a custom diffuse lighting model

Creating a Half Lambert lighting model

Creating a ramp texture to control diffuse shading

Creating a faked BRDF using a 2D ramp texture

Using Textures for Effects

Introduction

Scrolling textures by modifying UV values

Animating sprite sheets

Packing and blending textures

Normal mapping

Creating procedural textures in the Unity editor

Photoshop levels effect

Making Your Game Shine with Specular

Introduction

Utilizing Unity3D's built-in Specular type

Creating a Phong Specular type

Creating a BlinnPhong Specular type

Masking Specular with textures

Metallic versus soft Specular

Creating an Anisotropic Specular type

Reflecting Your World

Creating Cubemaps in Unity3D

Simple Cubemap reflection in Unity3D

Masking reflections in Unity3D

Normal maps and reflections in Unity3D

Fresnel reflections in Unity3D

Creating a simple dynamic Cubemap system

Lighting Models

Introduction

The Lit Sphere lighting model

The diffuse convolution lighting model

Creating a vehicle paint lighting model

Skin shader

Cloth shading

Transparency

Introduction

Creating transparency with alpha

Transparent cutoff shader

Depth sorting with render queues

GUI and transparency

Vertex Magic

Introduction

Accessing a vertex color in a Surface Shader

Animating vertices in a Surface Shader

Using vertex color for terrains

Mobile Shader Adjustment

Introduction

What is a cheap Shader?

Profiling your Shaders

Modifying your Shaders for mobile

Making Your Shader World Modular with CgIncludes

Introduction

CgInclude files that are built into Unity

Creating a CgInclude file to store lighting models

Building Shaders with #define directives

Screen Effects with Unity Render Textures

Introduction

Setting up the screen effects script system

Brightness, saturation, and contrast with screen effects

Basic Photoshop-like blend modes with screen effects

The Overlay blend mode with screen effects

Gameplay and Screen Effects

Introduction

Creating an old movie screen effect

Creating a night vision screen effect

Index