当前位置:网站首页>OpenGL jobs - shaders
OpenGL jobs - shaders
2022-07-07 22:08:00 【qq_ fifty-seven million two hundred and fifty-one thousand thre】
One 、 In the vertex shader , Invert a triangle
#version 330 core
layout (location = 0) in vec3 aPos;
out vec4 ourcolor;
void main()
{
gl_Position = vec4(aPos.x, -aPos.y, aPos.z, 1.0);
ourcolor=vec4(1.0, 0,0.2, 1.0);
}
Two 、 Use uniform Define a horizontal offset , Use this offset in the vertex shader to move the triangle to the right of the screen
#version 330 core
layout (location = 0) in vec3 aPos;
out vec4 ourcolor;
uniform float Pianyi_x;
void main()
{
gl_Position = vec4(aPos.x+Pianyi_x, aPos.y, aPos.z, 1.0);
ourcolor=vec4(1.0, 0,0.2, 1.0);
}
int vertexColorLocation = glGetUniformLocation(myshader.ID, "Pianyi_x");
myshader.use();
glUniform1f(vertexColorLocation,0.7f);
3、 ... and Use out
Keyword to output vertex positions to fragment shaders , And set the color of the clip to be equal to the vertex position ( Let's look at the result that even the vertex position values are interpolated in the triangle ). After that , Try to answer the following questions : Why is it black in the lower left corner of the triangle ?
I made a triangle
f
边栏推荐
- Embedded development: how to choose the right RTOS for the project?
- MIT6.S081-Lab9 FS [2021Fall]
- The strongest installation of the twin tower model, Google is playing "antique" again?
- Two kinds of updates lost and Solutions
- The maximum number of meetings you can attend [greedy + priority queue]
- What is the difference between the three values of null Nan undefined in JS
- 【Azure微服务 Service Fabric 】如何转移Service Fabric集群中的种子节点(Seed Node)
- Index summary (assault version)
- Open source OA development platform: contract management user manual
- ISO 26262 - considerations other than requirements based testing
猜你喜欢
嵌入式开发:如何为项目选择合适的RTOS?
Tcp/ip protocol stack
Solve the problem of uni in uni app Request sent a post request without response.
Customer case | China law network, through observing the cloud, greatly shortens the time of fault location
2022 how to evaluate and select low code development platforms?
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
[C language] advanced pointer --- do you really understand pointer?
NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
Latest Android advanced interview questions summary, Android interview questions and answers
谈谈制造企业如何制定敏捷的数字化转型策略
随机推荐
海外代理推荐
Arlo's troubles
Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
[JDBC Part 1] overview, get connection, CRUD
Jerry's manual matching method [chapter]
Jerry's power on automatic pairing [chapter]
Interview question 01.02 Determine whether it is character rearrangement - auxiliary array algorithm
【colmap】稀疏重建转为MVSNet格式输入
Talk about relational database and serverless
What is the difference between the three values of null Nan undefined in JS
TCP/IP 协议栈
Demon daddy B3 read extensively in a small amount, and completed 20000 vocabulary+
23. Merge K ascending linked lists -c language
Implementation method of data platform landing
Tupu digital twin coal mining system to create "hard power" of coal mining
应用实践 | 数仓体系效率全面提升!同程数科基于 Apache Doris 的数据仓库建设
Programming mode - table driven programming
Restapi version control strategy [eolink translation]
The little money made by the program ape is a P!
NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?