当前位置:网站首页>"Game engine light in light out" 4. shader
"Game engine light in light out" 4. shader
2022-07-26 04:35:00 【_ Captain】
4. Shaders
「 The game engine Shallow in, shallow out 」 Is an open source e-book ,PDF/ Code with the book / Download resources : https://github.com/ThisisGame/cpp-game-engine-book
Shader is Shader,Shader It's just a paragraph GPU Program source code .
We learned it in College C Language is CPU Program source code ,Shader and C There are many similarities in language , Write code, too 、 compile 、 link .
Use the following table to make a comparison .
| C Language | Shader | |
| Target hardware | CPU | GPU |
| Compilation process | Create project | establish GPU Program |
| Create multiple code files | establish Shader object ( The vertices Shader And clips Shader) | |
| Write multiple codes | Upload Shader Source code to Shader object | |
| Compile code | compile Shader | |
| Add to link list | Add to link list | |
| link | link |
Is it very similar !
Render an image , In fact, in the GPU On the implementation of Shader Code , Then set the vertex coordinates 、 Color data as input , Through Shader To deal with , Then output pixel data to the screen .
and C The difference in language is ,C Language only needs one main.c The file can be compiled successfully .
however Shader It is a supporting , Vertex Shader( Vertex shader )、Fragment Shader( Fragment Shader ), You can't have one without the other .
| C Language | Shader | |
| Target hardware | CPU | GPU |
| List of code files | main.c | main.vs(Vertex Shader) |
| ... | main.fs(Fragment Shader) |
Types of shaders
Vertex Shader( Vertex shader )、Fragment Shader( Fragment Shader / Pixel shader ) These two are what we hear most .
Geometry Shader、Computer Shader Yes, but I haven't used it in actual projects .
Tessellation Control Shader 、Tessellation Evaluation Shader These two have hardly heard of .
This is determined by the work content , Everyone is engaged in mobile game development .
Mobile phones on the market at present , A large part is still OpenGL ES3.0 Version of or lower .
Computer Shader stay OpenGL ES 3.1 The version just started to support .
Geometry Shader stay OpenGL ES 3.2 The version just started to support .
For more information, please refer to OpenGL Official website :
https://www.khronos.org/opengl/wiki/Category:Shaders
This book only introduces Vertex Shader( Vertex shader )、Fragment Shader( Fragment Shader ).
stay 3. Drawing simple figures In the supporting projects in this chapter ,ShaderSource.h There is... In it Vertex Shader and Fragment Shader Source code .
Here's the picture :

Look at this code , Also found and C Language similarities – All the entrances are main function .
| C Language | Shader | |
| Target hardware | CPU | GPU |
| entrance | void main() | void main() |
The current section is right Shader Just have a general image , The following chapters will introduce in detail .
边栏推荐
- How is the launch of ros2 different?
- The auxiliary role of rational cognitive educational robot in teaching and entertainment
- [C language foundation] 13 preprocessor
- 2022 a.static query on tree (tree section)
- 快恢复二极管工作原理及使用
- Postman imports curl, exports curl, and exports corresponding language codes
- 2022河南萌新联赛第(三)场:河南大学 L - 合成游戏
- RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程
- Integrated architecture of performance and cost: modular architecture
- I.MX6U-系统移植-6-uboot图形化配置
猜你喜欢

数据仓库

RTSP/Onvif协议视频平台EasyNVR服务一键升级功能的使用教程

Array sort 3

QT compilation error sorting and remote module Download

数组排序2

Steam science education endows classroom teaching with creativity

ASP. Net core actionfilter filter details

TIA botu WinCC Pro controls the display and hiding of layers through scripts

数据库启动报:ORA-29702: error occurred in Cluster Group Service

Use Baidu PaddlePaddle easydl to complete garbage classification
随机推荐
人脸数据库收集总结
建设面向青少年的创客教育实验室
【语义分割】2018-DeeplabV3+ ECCV
9、 File upload and download
TIA botu WinCC Pro controls the display and hiding of layers through scripts
UE4 two ways to obtain player control
Codeforces Round #807 (Div. 2)
Array sort 2
解决 Incorrect string value: ‘\xF0\x9F\x98\xAD“,...‘ for column ‘commentContent‘ at row 1 报错
Steam science education endows classroom teaching with creativity
MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection
SwiftUI一日速成
Credit card fraud detection based on machine learning
egg-sequelize JS编写
【学习笔记】AGC041
补位,稍后补上
Phaser(一):平台跳跃收集游戏
第三篇如何使用SourceTree提交代码
Face database collection summary
Recognized again | saining network security has been listed in the ccsip 2022 panorama of China's network security industry