Preface.....9
I. Topics we will see in this book.....10
II. Recommendations. ....11
III. Who this book is for. ....11
IV. Glossary. ....11
V. Errata. ....11
VI. Assets and donations.....12
VII. Piracy. ....12
Initial observations.....14
1.0.1. | Properties of a polygonal object. ....14
1.0.2. | Vertices.....15
1.0.3. | Normals.....16
1.0.4. | Tangents.....17
1.0.5. | UV coordinates.....17
1.0.6. | Vertex color.....18
1.0.7. | Render pipeline architecture.....19
1.0.8. | Application Stage.....20
1.0.9. | Geometry processing phase.....20
1.1.0. | Rasterization stage.....22
1.1.1. | Pixel processing stage.....23
1.1.2. | Types of render pipeline.....23
1.1.3. | Forward rendering.....25
1.1.4. | Deferred shading.....27
1.1.5. | What rendering engine should I use?....27
1.1.6. | Matrices and coordinates systems.....28
Shaders in Unity.....33
2.0.1. | What is a shader?....33
2.0.2. | Introduction to the programming language.....34
2.0.3. | Shader types.....35
2.0.4. | Standard surface shader.....37
2.0.5. | Unlit shader.....37
2.0.6. | Image effect shader.....37
2.0.7. | Compute shader.....37
2.0.8. | Ray tracing shader.....38
Properties, commands and functions.....39
3.0.1. | Structure of a vertex / fragment shader.....39
3.0.2. | ShaderLab shader.....43
3.0.3. | ShaderLab properties.....44
3.0.4. | Number and slider properties.....46
3.0.5. | Color and vector properties.....46
3.0.6. | Texture properties.....47
3.0.7. | Material property drawer.....50
3.0.8. | MPD Toggle.....51
3.0.9. | MPD KeywordEnum.....53
3.1.0. | MPD Enum.....55
3.1.1. | MPD PowerSlider and IntRange.....56
3.1.2. | MPD Space and Header.....58
3.1.3. | ShaderLab SubShader.....59
3.1.4. | ShaderLab Tags.....61
3.1.5. | Queue Tags.....62
3.1.6. | Render Type Tags.....64
3.1.7. | SubShader Blending.....69
3.1.8. | SubShader AlphaToMask.....74
3.1.9. | SubShader ColorMask.....75
3.2.0. | SubShader Culling and Depth Testing.....76
3.2.1. | ShaderLab Cull.....79
3.2.2. | ShaderLab ZWrite.....81
3.2.3. | ShaderLab ZTest.....82
3.2.4. | ShaderLab Stencil.....85
3.2.5. | ShaderLab Pass.....91
3.2.6. | CGPROGRAM / ENDCG.....93
3.2.7. | Data Types.....95
3.2.8. | Cg / HLSL Pragmas.....98
3.2.9. | Cg / HLSL Include.....100
3.3.0. | CG / HLSL vertex input & vertex output.....101
3.3.1. | Cg / HLSL variables and connection vectors.....105
3.3.2. | Cg / HLSL vertex shader stage.....106
3.3.3. | Cg / HLSL fragment shader stage.....108
3.3.4. | ShaderLab Fallback.....110
Implementation and other concepts.....112
4.0.1. | Analogy between a shader and a material. ....112
4.0.2. | Our first shader in Cg or HLSL. ....112
4.0.3. | Adding transparency in Cg or HLSL. ....114
4.0.4. | Structure of a function in HLSL. ....115
4.0.5. | Debugging a shader. ....119
4.0.6. | Adding URP compatibility.....122
4.0.7. | Intrinsic functions.....127
4.0.8. | Abs function.....127
4.0.9. | Ceil function.....132
4.1.0. | Clamp function.....137
4.1.1. | Sin and Cos function.....142
4.1.2. | Tan function.....147
4.1.3. | Exp, Exp2 and Pow function.....150
4.1.4. | Floor function. ....152
4.1.5. | Step and Smoothstep function.....157
4.1.6. | Length function.....160
4.1.7. | Frac function.....164
4.1.8. | Lerp function.....168
4.1.9. | Min and Max function.....172
4.2.0. | Timing and animation.....173
5.0.1. | Configuring inputs and outputs.....177
5.0.2. | Vectors.....182
5.0.3. | Dot product.....184
5.0.4. | Cross product.....187
Surface.....189
6.0.1. | Normal Maps.....189
6.0.2. | DXT compression.....196
6.0.3. | TBN Matrix.....201
Lighting.....203
7.0.1. | Lighting model.....203
7.0.2. | Ambient color.....203
7.0.3. | Diffuse reflection.....207
7.0.4. | Specular reflection.....216
7.0.5. | Environmental reflection.....228
7.0.6. | Fresnel effect.....238
7.0.7. | Structure of a Standard Surface shader.....246
7.0.8. | Standard Surface input & output.....249
Shadow.....251
8.0.1. | Shadow mapping.....251
8.0.2. | Shadow caster.....252
8.0.3. | Shadow map texture.....257
8.0.4. | Shadow Implementation.....261
8.0.5. | Built-in RP shadow map optimization.....265
8.0.6. | Universal RP Shadow Mapping.....269
Shader Graph.....276
9.0.1. | Introduction to Shader Graph.....276
9.0.2. | Starting in Shader Graph.....278
9.0.3. | Analyzing its interface.....280
9.0.4. | Our first shader in Shader Graph.....282
9.0.5. | Graph Inspector.....289
9.0.6. | Nodes.....290
9.0.7. | Custom Functions.....292
10.0.1 | Compute shader structure.....298
10.0.2 | Our first Compute shader.....302
10.0.3 | UV coordinates and texture.....316
10.0.4 | Buffers.....320
Sphere Tracing.....331
11.0.1 | Implementing functions with Sphere Tracing.....333
11.0.2 | Projecting a texture.....342
11.0.3 | Smooth minimum between two surfaces.....348
Ray Tracing.....353
12.0.1 | Configuring Ray Tracing in HDRP.....354
12.0.2 | Using Ray Tracing in our scene.....361
Index....364
Special Thanks....367
Learn shaders in Unity, starting with the basics and finishing with advanced concepts.The book includes a detailed explanation of languages like Cg, HLSL, ShaderLab, and Shader Graph.+370 informative pages on shader programming.From beginner to advanced linearly, starting with basic concepts (e.g. unlit shader) and ending with advanced ones (e.g. compute shader).Clear and direct.You will be able to find the differences and similarities between Built-in, Universal and High Definition Render Pipeline.Real-life examples.All the examples in this book could be applied to production-stage projects.