[mutter/lamefun/dithering] compositor: improve vignette on background actor
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/lamefun/dithering] compositor: improve vignette on background actor
- Date: Wed, 12 Dec 2018 11:37:44 +0000 (UTC)
commit bdf8d0f1c31cb87eefdfd3cd956c9f2c309201d8
Author: Nikita Churaev <lamefun x0r gmail com>
Date: Wed Mar 7 00:14:44 2018 +0300
compositor: improve vignette on background actor
The shader used for computing a vignette currently has two
problems:
* The math is wrong such that the vignette isn't stretched
across the whole actor and so ends abruptly
* There is noticeable banding in its gradient
This commit corrects both problems by fixing the computing
and introducing noise dithering.
src/compositor/meta-background-actor.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/src/compositor/meta-background-actor.c b/src/compositor/meta-background-actor.c
index 2b619eb27..756b29e72 100644
--- a/src/compositor/meta-background-actor.c
+++ b/src/compositor/meta-background-actor.c
@@ -131,15 +131,19 @@ typedef enum {
#define VIGNETTE_VERTEX_SHADER_CODE \
"position = cogl_tex_coord0_in.xy * scale + offset;\n" \
-#define VIGNETTE_FRAGMENT_SHADER_DECLARATIONS \
-"uniform float vignette_sharpness;\n" \
-"varying vec2 position;\n" \
+#define VIGNETTE_SQRT_2 "1.4142"
+
+#define VIGNETTE_FRAGMENT_SHADER_DECLARATIONS \
+"uniform float vignette_sharpness;\n" \
+"varying vec2 position;\n" \
+"float rand(vec2 p) { return fract(sin(dot(p, vec2(12.9898, 78.233))) * 43758.5453123); }\n" \
#define VIGNETTE_FRAGMENT_SHADER_CODE \
-"float t = 2.0 * length(position);\n" \
+"float t = " VIGNETTE_SQRT_2 " * length(position);\n" \
"t = min(t, 1.0);\n" \
"float pixel_brightness = 1.0 - t * vignette_sharpness;\n" \
"cogl_color_out.rgb = cogl_color_out.rgb * pixel_brightness;\n" \
+"cogl_color_out.rgb += (rand(position) - 0.5) / 255.0;\n" \
typedef struct _MetaBackgroundLayer MetaBackgroundLayer;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]