author | František Kučera <franta-hg@frantovo.cz> |
Sat, 02 Dec 2023 23:11:56 +0100 | |
branch | v_0 |
changeset 11 | 0aeedc35ebed |
parent 4 | shaders/first.frag@9aba96f0b001 |
child 14 | ceeb36fad818 |
permissions | -rw-r--r-- |
0 | 1 |
#version 330 core |
2 |
||
2
3faef2f5128e
better GLSL variable names
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
3 |
uniform sampler2D uTexture; |
3faef2f5128e
better GLSL variable names
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
4 |
in vec2 vTextureXY; |
3faef2f5128e
better GLSL variable names
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
5 |
out vec3 fColor; |
0 | 6 |
|
4
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
7 |
vec3 grayscale(vec3 original) { |
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
8 |
const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721); |
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
9 |
float luminance = dot(original, luminanceWeighting); |
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
10 |
return vec3(luminance); |
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
11 |
} |
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
12 |
|
0 | 13 |
void main(){ |
2
3faef2f5128e
better GLSL variable names
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
14 |
fColor = texture(uTexture, vTextureXY).rgb; |
4
9aba96f0b001
fragment shader: add grayscale() function
František Kučera <franta-hg@frantovo.cz>
parents:
2
diff
changeset
|
15 |
// fColor = grayscale(fColor); |
2
3faef2f5128e
better GLSL variable names
František Kučera <franta-hg@frantovo.cz>
parents:
0
diff
changeset
|
16 |
// fColor *= vec3(0.8, 1., 0.2); |
0 | 17 |
} |