This commit is contained in:
Jie
2024-02-20 11:16:08 +08:00
commit 7be6ecc9a3
13 changed files with 482 additions and 0 deletions

25
shaders/fragShader.frag Normal file
View File

@@ -0,0 +1,25 @@
#version 330 core
out vec4 FragColor;
in vec2 TexCoord;
uniform sampler2D textureY;
uniform sampler2D textureU;
uniform sampler2D textureV;
void main(){
vec3 yuv, rgb;
vec3 yuv2r = vec3(1.164, 0.0, 1.596);
vec3 yuv2g = vec3(1.164, -0.391, -0.813);
vec3 yuv2b = vec3(1.164, 2.018, 0.0);
yuv.x = texture(textureY, TexCoord).r - 0.0625;
yuv.y = texture(textureU, TexCoord).r - 0.5;
yuv.z = texture(textureV, TexCoord).r - 0.5;
rgb.x = dot(yuv, yuv2r);
rgb.y = dot(yuv, yuv2g);
rgb.z = dot(yuv, yuv2b);
FragColor = vec4(rgb, 1.0);
}

12
shaders/vertexShader.vert Normal file
View File

@@ -0,0 +1,12 @@
#version 330 core
layout (location = 0) in vec3 aPos;
layout (location = 1) in vec2 aTexCoord;
out vec2 TexCoord;
void main()
{
gl_Position = vec4(aPos, 1.0);
TexCoord = vec2(aTexCoord.x, aTexCoord.y);
}