Add server source, originally in monado

This commit is contained in:
Guillaume Meunier
2022-11-12 23:59:28 +01:00
parent 07c0c09c80
commit 294c4f81ba
53 changed files with 10808 additions and 12 deletions
@@ -0,0 +1,36 @@
// Copyright 2022, Guillaume Meunier
// Copyright 2022, Patrick Nicolas
// SPDX-License-Identifier: BSL-1.0
#version 450
layout (binding = 0) uniform sampler2D image;
layout (location = 0) in vec2 pos;
layout (location = 0) out vec2 uv;
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));
}
float reduce_range(float x)
{
return (128 + x * 224) / 256;
}
void main() {
vec4 rgba = gamma4(texture(image, pos));
uv.x = reduce_range(rgba.r * -0.1146 + rgba.g * -0.3854 + rgba.b * 0.5);
uv.y = reduce_range(rgba.r * 0.5 + rgba.g * -0.4542 + rgba.b * -0.0458);
}
@@ -0,0 +1,12 @@
// Copyright 2022, Guillaume Meunier
// Copyright 2022, Patrick Nicolas
// SPDX-License-Identifier: BSL-1.0
#version 450
layout (location = 0) out vec2 outUV;
void main() {
outUV = vec2((gl_VertexIndex << 1) & 2, gl_VertexIndex & 2); // [(0, 0), (2, 0), (0, 2)]
gl_Position = vec4(outUV * 2.0f + -1.0f, 0.0f, 1.0f); // [(-1, -1), (3, -1), (-1, 3)]
}
@@ -0,0 +1,34 @@
// Copyright 2022, Guillaume Meunier
// Copyright 2022, Patrick Nicolas
// SPDX-License-Identifier: BSL-1.0
#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));
}
float reduce_range(float x)
{
return (16 + x * 219) / 256;
}
void main() {
vec4 rgba = gamma4(texture(image, pos));
y = reduce_range(rgba.r * 0.2126 + rgba.g * 0.7152 + rgba.b * 0.0722);
}