summaryrefslogtreecommitdiff
path: root/shaders/gtk4/146.shader_test
blob: 6d7a62303beb43fba2f5d1cd58f54a85106541f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
[require]
GLSL >= 3.30

[vertex shader]
#version 330 core
in vec4 a_position;   
in vec2 a_texcoord;   
out vec2 v_texcoord;     
void main()                  
{                            
  gl_Position = a_position; 
  v_texcoord = a_texcoord;  
}                            

[fragment shader]
#version 330 core
uniform vec2 tex_scale0;
uniform vec2 tex_scale1;
uniform vec2 tex_scale2;
uniform float width;
uniform float height;
uniform float poffset_x;
uniform float poffset_y;
uniform vec3 offset;
uniform vec3 coeff1;
uniform vec3 coeff2;
uniform vec3 coeff3;
uniform sampler2D Ytex, Utex, Vtex;

layout (location = 0) out vec4 fragColor;

vec3 yuv_to_rgb (vec3 val, vec3 offset, vec3 ycoeff, vec3 ucoeff, vec3 vcoeff) {
  vec3 rgb;
  val += offset;
  rgb.r = dot(val, ycoeff);
  rgb.g = dot(val, ucoeff);
  rgb.b = dot(val, vcoeff);
  return rgb;
}


in vec2 v_texcoord;
void main (void) {
vec2 texcoord;
texcoord = v_texcoord;
vec4 texel, rgba;
texel.x = texture(Ytex, texcoord * tex_scale0).r;
texel.y = texture(Utex, texcoord * tex_scale1).r;
texel.z = texture(Vtex, texcoord * tex_scale2).r;
rgba.rgb = yuv_to_rgb (texel.xyz, offset, coeff1, coeff2, coeff3);
rgba.a = 1.0;
fragColor=vec4(rgba.r,rgba.g,rgba.b,rgba.a);

}