当前位置:网站首页>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
边栏推荐
- How to integrate Google APIs with Google's application system (1) -introduction to Google APIs
- How to turn on win11 game mode? How to turn on game mode in win11
- 嵌入式开发:如何为项目选择合适的RTOS?
- Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
- [open source] Net ORM accessing Firebird database
- Ternary expressions, generative expressions, anonymous functions
- 2022 how to evaluate and select low code development platforms?
- Devil daddy A0 English zero foundation self-improvement Road
- The new version of onespin 360 DV has been released, refreshing the experience of FPGA formal verification function
- Jerry's power on automatic pairing [chapter]
猜你喜欢
The new version of onespin 360 DV has been released, refreshing the experience of FPGA formal verification function
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
Google SEO external chain backlinks research tool recommendation
Cv2.resize function reports an error: error: (-215:assertion failed) func= 0 in function ‘cv::hal::resize‘
The latest Android interview collection, Android video extraction audio
客户案例|华律网,通过观测云大幅缩短故障定位时间
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
2022 how to evaluate and select low code development platforms?
How to make agile digital transformation strategy for manufacturing enterprises
Use blocconsumer to build responsive components and monitor status at the same time
随机推荐
Redis - basic use (key, string, list, set, Zset, hash, geo, bitmap, hyperloglog, transaction)
Time standard library
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
反爬通杀神器
The difference between NPM uninstall and RM direct deletion
Demon daddy B2 breaks through grammar and completes orthodox oral practice
Main functions of OS, Sys and random Standard Libraries
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Typescript TS basic knowledge type declaration
JNI primary contact
Nine degree 1201 - traversal of binary sort number - binary sort tree "suggestions collection"
MIT6.S081-Lab9 FS [2021Fall]
How to turn on win11 game mode? How to turn on game mode in win11
The whole network "chases" Zhong Xuegao
强化学习-学习笔记9 | Multi-Step-TD-Target
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
Jerry's configuration of TWS cross pairing [article]
怎样写一个增广矩阵到txt文件中
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法
Tsconfig of typescript TS basics JSON configuration options