当前位置:网站首页>"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 .
边栏推荐
猜你喜欢

Li Kou daily question - day 42 -661. Picture smoother

What are the consequences and problems of computer system restoration

Codeforces Round #807 (Div. 2)

Wu Enda's machine learning after class exercises - logical regression

MySQL - multi table query - Cartesian product sum, correct multi table query, equivalent connection and unequal connection, inner connection and outer connection

UE4 键盘控制开关灯

Build a maker Education Laboratory for teenagers

Codeforces Round #807 (Div. 2)

Steam science education endows classroom teaching with creativity

Embedded practice -- CPU utilization statistics based on rt1170 FreeRTOS (24)
随机推荐
[300 + selected interview questions from big companies continued to share] big data operation and maintenance sharp knife interview question column (VIII)
10、 Interceptor
autocomplete禁止表单自动填充
MySQL usage
What if win11 cannot wake up from sleep? Solution of win11 unable to wake up during sleep
补位,稍后补上
计算离散点的曲率(matlab)
5、 Domain objects share data
MapReduce中分区数与ReduceTask个数关系比较
Use Baidu PaddlePaddle easydl to complete garbage classification
UE4 多个角色控制权的切换
2022杭电多校第二场 A.Static Query on Tree(树剖)
Face database collection summary
Tutorial on using the one click upgrade function of the rtsp/onvif protocol video platform easynvr service
MySQL only checks the reasons for the slow execution of one line statements
YAPI安装
这种是我的vs没连上数据库吗
Use of anonymous functions
Comprehensive evaluation and decision-making method
MySQL log classification: error log, binary log, query log, slow query log