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

Array sort 2

2022 Henan Mengxin League game (3): Henan University L - synthetic game

UE4 keyboard control switch light

A series of problems about the number of DP paths

YAPI安装

Analyzing the curriculum design evaluation system of steam Education

Postman imports curl, exports curl, and exports corresponding language codes

QT compilation error sorting and remote module Download

Yapi installation

计算离散点的曲率(matlab)
随机推荐
【300+精选大厂面试题持续分享】大数据运维尖刀面试题专栏(八)
软考回顾及计划
Keil V5 installation and use
How does win11 22h2 skip networking and Microsoft account login?
机器学习之信用卡欺诈检测
SQL加解密注入详解
idea插件离线安装(持续更新)
2022杭电多校第二场 A.Static Query on Tree(树剖)
[uoj 429] runs (inclusive) + a little record about Lyndon tree and its application
Wu Enda's machine learning after class exercises - linear regression
Embedded practice -- CPU utilization statistics based on rt1170 FreeRTOS (24)
3、 @requestmapping annotation
三、@RequestMapping注解
解析Steam教育的课程设计测评体系
Threadpooltaskexecutor and ThreadPoolExecutor
Unable to find sygwin.s file during vscode debugging
MySQL only checks the reasons for the slow execution of one line statements
九、文件上传和下载
Spark Structured Streaming HelloWorld
UE4 获取玩家控制权的两种方式