当前位置:网站首页>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
边栏推荐
- Typescript TS basic knowledge type declaration
- The difference between NPM uninstall and RM direct deletion
- Node:504 error reporting
- Latest Android advanced interview questions summary, Android interview questions and answers
- An overview of the latest research progress of "efficient deep segmentation of labels" at Shanghai Jiaotong University, which comprehensively expounds the deep segmentation methods of unsupervised, ro
- Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
- Have you ever been confused? Once a test / development programmer, ignorant gadget C bird upgrade
- DNS series (I): why does the updated DNS record not take effect?
- [C language] advanced pointer --- do you really understand pointer?
- How polardb-x does distributed database hotspot analysis
猜你喜欢
如何选择合适的自动化测试工具?
[C language] advanced pointer --- do you really understand pointer?
Magic weapon - sensitive file discovery tool
Demon daddy B3 read extensively in a small amount, and completed 20000 vocabulary+
Record a garbled code during servlet learning
operator
Two kinds of updates lost and Solutions
Virtual machine network configuration in VMWare
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
嵌入式开发:如何为项目选择合适的RTOS?
随机推荐
The difference between NPM uninstall and RM direct deletion
It's worth seeing. Interview sites and interview skills
Win11如何解禁键盘?Win11解禁键盘的方法
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
Jerry's about TWS channel configuration [chapter]
Typescript TS basic knowledge type declaration
null == undefined
Take the intersection of two sets
Oracle advanced (VI) Oracle expdp/impdp details
100million single men and women "online dating", supporting 13billion IPOs
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
使用 CustomPaint 绘制基本图形
Crawler (17) - Interview (2) | crawler interview question bank
Open source OA development platform: contract management user manual
Validutil, "Rethinking the setting of semi supervised learning on graphs"
如何选择合适的自动化测试工具?
PDF文档签名指南
operator
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
Jerry's test box configuration channel [chapter]