# HG changeset patch # User František Kučera # Date 1701217625 -3600 # Node ID 9aba96f0b001380173e029f04e2d3c1b3d567961 # Parent 48dc4ae894b04d4e0f8ccc220c2d2489c9ac17a1 fragment shader: add grayscale() function diff -r 48dc4ae894b0 -r 9aba96f0b001 shaders/first.frag --- a/shaders/first.frag Wed Nov 29 01:21:17 2023 +0100 +++ b/shaders/first.frag Wed Nov 29 01:27:05 2023 +0100 @@ -4,7 +4,14 @@ in vec2 vTextureXY; out vec3 fColor; +vec3 grayscale(vec3 original) { + const vec3 luminanceWeighting = vec3(0.2125, 0.7154, 0.0721); + float luminance = dot(original, luminanceWeighting); + return vec3(luminance); +} + void main(){ fColor = texture(uTexture, vTextureXY).rgb; + // fColor = grayscale(fColor); // fColor *= vec3(0.8, 1., 0.2); }