Practical Shader Development.pdf

-
Vertex and Fragment Shaders for Game Developers This book is intended to be the gentlest introduction possible to the theory and practice of writing shaders for video games.
Practical Shader Development: Vertex and Fragment Shaders for Game Developers Kyle Halladay Bristol, UK ISBN-13(pbk:978-1-4842-44562 ISBN-13(electronic): 978-1-4842-4457-9 htps:/ doi. org/10.1007/978-1-4842-4457-9 Copyright o 2019 by Kyle Halladay This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Jonathan Gennick Development Editor: Laura Berenson Coordinating Editor: Jill Balzano CoverimagedesignedbyFreepik(www.freepik.com) Distributed to the book trade worldwide by Springer Science+ Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505, e-mail orders-ny@springer sbm.com,orvisitwww.springeronline.comApressMedia,LlcisaCaliforniaLlcandthesolemember (owner )is Springer Science Business Media Finance Inc(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation Forinformationontranslationspleasee-mailrights@apress.com,orvisitwww.apress.com/ rights-permissions Apress titles may be purchased in bulk for academic, corporate, or promotional use eBook versions and licenses are also available for most titles. For more information reference our print and eBook bulk sales webpageatwww.apress.com/bulk-sales Any source code or other supplementary material referenced by the author in this book is available to readersonGithubviathebooksproductpage,locatedatwww.apress.com/9781484244562.Formore detailedinformationpleasevisitwww.apress.com/source-code Printed on acid-free paper To my wife, Sarah Table of contents About the author About the technical reviewer ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■■■ Acknowledgments mmmmmmmmm BRBR RR RR RR ERRI EaEI E XVii Introduction Chapter 1: Hello, Game Graphics a What Is Rendering What is a mesh? 2 Vectors 101 4 Detining a Color in Computer Graphics...memenmemnnmnmnmmnm 10 The Rendering Pipeline 12 What is a shader? 14 Summary 15 Chapter 2: Your First Shaders mmm 17 Setting Things Up on Windows 18 Setting Up our project....……18 Creating Your First Triangle Your first vertex shader……22 The #version Preprocessor Directive 23 GLSL'S in Keyword 23 GLSL's vec Data Types 24 Writing to gl_ position…,,…, 24 Normalized device TABLE OF CONTENTS Your First Fragment shader 27 GLSL's out Keyword 27 Using Shaders in Our Project.…,… 28 Adding Color with Vertex Attributes. Introducing Fragment Interpolation…… .33 Introducing Uniform Variables. Summary…… 36 Chapter 3: Using Textures. aaaaaaasaaseassaamaataaaaaaaaaaamaaammammaaaaa mattaaaaaaaaasaasaasnannan. 37 Making a Quad… 38 Introducing UV Coordinates....................................40 Using Textures in Shaders 45 Scrolling UV coordinates 48 Adjusting Brightness with a Uniform... 52 Basic color math… 56 Mixing Textures with the"Mix" Instruction…… …60 Summary 63 Chapter 4: Translucency and Depth ■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■■■■■■口■■口 a65 EXample Project Setup…,,,,,…66 Drawing Our Little Green Man……,,… 66 Alpha Testing with Discard. Building a Scene with Depth Testing 70 Creating Clouds with Alpha blending…,,,,,…………72 GLSLs min( and max( Functions 75 How Alpha Blending Works 76 Adding Some Sun with Additive Blending….…………78 Animating with Sprite Sheets 83 Summary.aname.a.. 87 TABLE OF CONTENTS Chapter 5: Making Things Move a RRRsRaaIImaa IREassnaaamaIIRaaIIniaa 89 Making Our Character Walk Forward ,90 Scaling our cloud in shader code .mmmmmmmmmmmmmmmmmmmmmmmmmmmm. 93 Rotating Objects with a Vertex Shader 97 Introducing Transformation Matricesmmmmmmmmmman..n..mn.. 100 Animating a transformation Matrix ..mmmmm..mmmmmmmmmm.. 105 The Identity Matrix…… 109 Summary.,,,,,,,,,,,,, …111 Chapter6: Cameras and coordinates,,…,,…,…,,,,mm,m,m,m,m113 Using a view Matrix 114 Transform Matrices and coordinate spaces ..mmmmmmmmmmnmmm..118 Camera Frustums and projections.eeee nuns. 124 Summary…,,, 128 Chapter 7: Your First 3D Project ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■国■■国a■口■■ 129 Loading a mesh 129 Making a Perspective camera mmnememmnmmnmnamamannananmn 132 Summary Chapter 8: Diffuse Lighting ng137 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■口■■■■■■ Smooth vs. Flat Shading with Normals.,,.,.,,,,,………140 World Space Normals and Swizzling 142 The normal matrix mmm 144 Why lighting Calculations Need Normals .....m........m.......146 What's Shading with Dot Products 148 Your First Directional light 151 Creating a Rim Light Effect 154 Summary… ,160 TABLE OF CONTENTS Chapter 9: Your First Lighting Model mmmmmmmmmmmma 161 Specular Lighting 161 Your First Specular Shader ..................................................163 Combining diffuse and specular light. 167 Ambient Lighting. The Phong lighting Model . ..m.....mmmmm. 169 Binn- Phong Lighting… 172 Using Textures to Control Lighting 175 Summary ,179 Chapter 10: Normal Mapping. ummmanamn Imaan 181 What Is a normal map? ..mmmmmmmmmmmmmmmmmmmmmmmmmmmmm.m 182 Introducing Tangent Space Working with Tangent vectors ,185 Introducing Cross Products.mm. …186 How Normal Mapping Works.,,,,,,,,,,,,,,…,…,……,188 Writing a Water shader∴ 191 There's More to Normal Mapping.m... nn.n.....n.. 199 Summary.…200 Chapter 11: Cubemaps And skyboxes.aa. ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■口■■■■■■■■口■■■■■■口 201 What is a cubemap? Loading a cubemap in open Frameworks 203 Rendering a cubemap on a cube. ................m.m.. 203 Introducing Skyboxes.eaea.a. 207 The Perspective Divide. Skyboxes and the Perspective Divide. Finishing Our Skybox. Creating Cubemap Reflections 212 There's more to Cubemaps 215 Summary 215 TABLE OF CONTENTS Chapter 12: Lighting in Depth mmamammnmmmmmnmman 217 Directional Lights 217 Point Lights 219 Spot lights 226 Multiple Light Sources. A More Flexible Multi-light Setup.mmammmmnnnnnnnnnnnaaaaaammmnn 240 Taking Things Farther….,,,…, 246 Summary... …247 Chapter 13: Profiling Shaders amama mmammammaamna 249 How to Measure performance 249 CPU Time vs, GPU Time mmm. 250 Working Around VSync 251 Working around Your Computer 255 Practical Profiling 255 Introducing Nsight Graphics 259 Are We CPu or gPu bound? 262 A Handy Shortcut 265 Tracking down a Problem Shader 266 Summary 270 Chapter 14: Optimizing Shaders 271 Move calculations to Vertex shaders Avoid Dynamic Branching Get mad 277 Prefer glsl Functions over your own 278 Use Write masks 279 Avoid Unnecessary Overdraw 280 Final Thoughts 281 Summary..,,…,282 TABLE OF CONTENTS Chapter15: Precis0m,,,,,围围283 What Is Floating-Point Precision 283 Case Study: Animation over Time Working with Lower Precision Variables. Case Study: Point Light problem 294 Summary.........298 Chapter 16: Writing Shaders in Unity mmmm ammmmmmamamammaamaaammmamamnmamnn 299 Shaders and Materials in Unity…..,……,299 Introducing ShaderLab 300 A Solid color shader ,303 Porting Our Blinn-Phong Shader…..,.,,,,,,,,,,……,309 Translucent Shaders in Unity. Handling Multiple Lights 319 Passing Data from C# to Shader Code 323 Next Steps, ShaderGraph, and the Future Summary 325 Chapter 17: Writing Shaders in UE4 ■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■口■■■■■■■■■■■■■■■■口a口■■ 327 Shaders, Materials, and Instances( Making Things Red. UE4 Material Node Graph Fundamentals 334 Making a Rim Light Material.m..m.. 337 The Default Lit Material Inputs 340 rtex shader or Fragment Shader? 342 Working with Different Shading Models m. mmmnnaammnonnatmmennn. an 346 Blend Modes and Texture Sample Nodes. mmmmmnmammnemnmnmnmamnmnmnmnmnmmmmnmn 347 Passing Data from Code to Materials 348 How Does all this relate to shader code? 348 Summary.....,..349

-
2020-08-10
5.31MB
Programming Vertex Geometry and Pixel Shaders pdf
2009-12-19This book is intended for people that have some background in DirectX8 or DirectX9 programming and w
11.56MB
Practical Shader Developmen.pdf
2019-06-21书籍描述: 是时候停止认为遮影器是神奇的了。您可以使用着色程序将数据转换为惊人的视觉效果,并通过逐步向游戏和图形开发人员介绍着色程序开发,通过构建自己的着色程序来脏手。学习如何使阴影移动,着色,照亮,
12.15MB
Practical Shader Development
2019-05-17介绍着色器技术与开发的2019年新书,内容包括图形学基础、纹理、透明度、运动、相机、3D投影、灯光、着色器、Unity、UE4、Godot使用。
9.64MB
Practical Shader Development_ Vertex and Fragment Shaders
2019-04-15本书是为数不多的讲解有关渲染从原理到实战的一本书,既重视理论上的讲解,又有大量的示例,通过对本书的深入学习,及时Shader不会写的小白也能写出画面酷炫的Shader代码出来,并且能深入理解各种酷炫技
911KB
Chapter 13 The Compute Shader
2018-04-25Introduction to 3D Game Programming with Directx12 Chapter13 习题解答源码
76KB
jd抢购茅台脚本文件
2021-01-04抢购茅台抢购茅台抢购茅台
88KB
python 随机森林算法及其优化详解
2020-09-19主要介绍了ptyhon 随机森林算法及其优化详解,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下
Python数据殿堂:数据分析与数据可视化
2020-01-02【入门基础+轻实战演示】【讲授方式轻松幽默、有趣不枯燥、案例与实操结合,与相关课程差异化】利用python进行数据处理、 分析,并结合大量具体的例子,对每个知识进行实战讲解,本课程通过大量练习和案例对各个知识点技能进行详细讲解。通过本 课程,学生将懂得pandas、numpy、matplotlib等数据分析工具;通过实战,学生将了解标准的数据分析流程,学会使用可视化的 方法展示数据及结果。
2020华为HCIA/HCNA/数通/路由交换/实验/视频/教程/持续更新赠题库
2020-05-25本课程不仅可以帮助大家顺利考取华为HCIA证书,同时技术视频均为理论+实战配套讲解,讲解细致,通俗易懂,资料完整,可以让大家学到实实在在企业用到的网络技术,本课程包含完整的学习资料,视频+PPT课件,能够帮助你快速掌握HCIA数通网络技术,同时视频中3-4视频后面的附件课件包含了HCIA数通考试题库(带答案),适合从零基础学网络考HCIA的同学!
18.78MB
Android开发入门60个小案例+源代码
2013-08-24适合初学者,大量简单小例子,完整源代码。
程序员的数学:微积分
2019-09-28本课程介绍程序员必备的数学基础内容,在取材上侧重人工智能、数据分析等热门领域
大数据的入门视频教程
2018-07-26大数据技术入门视频课程,会从基础思想和原理架构开始,全面介绍大数据的思想体系和架构,为学员进一步学习大数据奠定良好的基础。内容涉及大数据的核心问题、大数据核心思想,Google的三篇论文、GFS,Google的分布式文件系统,MapReduce,BigTable、Hadoop和Spark生态体系以及具体应用演示。
24.46MB
图书管理系统(Java + Mysql)我的第一个完全自己做的实训项目
2019-01-04图书管理系统 Java + MySQL 完整实训代码,MVC三层架构组织,包含所有用到的图片资源以及数据库文件,大三上学期实训,注释很详细,按照阿里巴巴Java编程规范编写
16.88MB
2021CFA一级Notes1-5(完整版).zip
2021-01-072021CFA一级Notes1-5(完整版),有5本pdf。
8小时Python零基础轻松入门
2020-05-20
-
学院
微服务系列第七十一季-Introducing Spring Boot
微服务系列第七十一季-Introducing Spring Boot
-
博客
基于回溯法的数独求解(Python)
基于回溯法的数独求解(Python)
-
下载
软件开发工具实验-下拉菜单.rar
软件开发工具实验-下拉菜单.rar
-
下载
ArchVizPRO Interior Vol6资源包
ArchVizPRO Interior Vol6资源包
-
学院
西安航空学院软工毕业实训
西安航空学院软工毕业实训
-
博客
什么是向上管理?意义?
什么是向上管理?意义?
-
博客
你知道二维数组的两个维度分别代表什么吗
你知道二维数组的两个维度分别代表什么吗
-
下载
C++面向对象程序设计实验报告(计算器)
C++面向对象程序设计实验报告(计算器)
-
学院
(新)备战2021软考系统集成顺利通关套餐
(新)备战2021软考系统集成顺利通关套餐
-
下载
C++大作业简易计算器.rar
C++大作业简易计算器.rar
-
博客
PTA实验7-1-4 找出不是两个数组共有的元素 (20分)
PTA实验7-1-4 找出不是两个数组共有的元素 (20分)
-
下载
S3C2440.pdf
S3C2440.pdf
-
博客
力扣697:数组的度
力扣697:数组的度
-
学院
(新)备战2021软考网络规划设计师培训学习套餐
(新)备战2021软考网络规划设计师培训学习套餐
-
博客
LinuxProbe学习笔记(六)
LinuxProbe学习笔记(六)
-
学院
【数据分析-随到随学】Hive详解
【数据分析-随到随学】Hive详解
-
博客
MySQL删除重复数据的一种方法
MySQL删除重复数据的一种方法
-
博客
汉字统计
汉字统计
-
下载
大学生 毕业设计 项目实训 u3d楼盘漫游 unity3d室内漫游源码
大学生 毕业设计 项目实训 u3d楼盘漫游 unity3d室内漫游源码
-
学院
精通docker容器技术/compose/swarm/harbor
精通docker容器技术/compose/swarm/harbor
-
学院
前端实战案例之石头剪刀布游戏(零基础入门)
前端实战案例之石头剪刀布游戏(零基础入门)
-
学院
(新)备战2021软考网络工程师终极解密培训套餐
(新)备战2021软考网络工程师终极解密培训套餐
-
下载
MVS_WIN_STD_3.3.1_201207海康工业相机软件
MVS_WIN_STD_3.3.1_201207海康工业相机软件
-
下载
2021数字科技前沿应用趋势【发布版】
2021数字科技前沿应用趋势【发布版】
-
下载
ffmpeg-4.3-win32-gpl-shared-20210116.zip
ffmpeg-4.3-win32-gpl-shared-20210116.zip
-
下载
合肥工业大学计算机科学与技术16级数据库实验截图
合肥工业大学计算机科学与技术16级数据库实验截图
-
学院
微软人工智能AI量化投资平台Qlib技术教程
微软人工智能AI量化投资平台Qlib技术教程
-
博客
乐优商城(二)
乐优商城(二)
-
学院
21年新接口自动化测试视频postman教程 零基础接口测试
21年新接口自动化测试视频postman教程 零基础接口测试
-
博客
2021-01-16
2021-01-16