当前位置:网站首页>Shader Language

Shader Language

2022-07-07 15:41:00 When can Xiaobai advance to success

One 、 Simple rectangle

1、 Vertex shader

Below is a triangle vertex shader

#version 330 core
//  input data  aPos The input is a (x,y) Vector 
// aColor It's a 4 Dimension vector 
attribute vec2 aPos;
attribute vec4 aColor;
//  Data output to clip shaders 
out vec4 Color;
void main()
{
	
	// color Not in vertex shaders , Direct output 
	Color=aColor;
	// gl_Position It's a built-in function , Here is 4 Parameters ,x,y,z also alpha value , temporary alpha The value is 1
    gl_Position = vec4(aPos, 0.0, 1.0);
}

2、 Fragment Shader

#version 330 core
//  Input from vertex shader 
in vec4 Color;

void main()
{    
	// gl_FragColor  It's a built-in function , Here is 4 Parameters 
    gl_FragColor = Color;
}

This rectangle has only color , No texture .

原网站

版权声明
本文为[When can Xiaobai advance to success]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130611524324.html