/* * WiVRn VR streaming * Copyright (C) 2022 Guillaume Meunier * Copyright (C) 2022 Patrick Nicolas * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #version 450 layout (binding = 0) uniform sampler2D image; layout (location = 0) in vec2 pos; layout (location = 0) out float y; float gamma(float x) { if (x <= 0.0031308) return 12.92 * x; else return 1.055 * pow(x, 1/2.4) - 0.055; } vec4 gamma4(vec4 x) { return vec4(gamma(x.r), gamma(x.g), gamma(x.b), gamma(x.a)); } void main() { vec4 rgba = gamma4(texture(image, pos)); y = rgba.r * 0.2126 + rgba.g * 0.7152 + rgba.b * 0.0722; }