aboutsummaryrefslogtreecommitdiffstats
path: root/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x')
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
index 558531a50b..dec8aa93bc 100644
--- a/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
+++ b/src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x
@@ -26,9 +26,11 @@ static const char fragment_glsl[] =
"#ifdef SHD_EXTERNAL\n"
"uniform SAMPLER_EXTERNAL_OES tex;\n"
"varying vec2 tex_c;\n"
+ "#define ADD_NOISE 1\n"
"#elif defined(SHD_TEX)\n"
"uniform sampler2D tex;\n"
"varying vec2 tex_c;\n"
+ "#define ADD_NOISE 1\n"
"#endif\n"
"#if defined(SHD_NV12) || defined(SHD_YUY2)\n"
"uniform sampler2D texuv;\n"
@@ -80,6 +82,14 @@ static const char fragment_glsl[] =
"# endif\n"
"# endif\n"
"#endif\n"
+ "#ifdef ADD_NOISE\n"
+ "float rand(vec2 co)\n"
+ "{\n"
+ " /* Magic 'random' number in range [0..1]. 'co' should be random coordinate.\n"
+ " * Distribution is not great. Falls apart with lowp float. */\n"
+ " return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453) - 0.5;\n"
+ "}\n"
+ "#endif\n"
"void main()\n"
"{\n"
" vec4 c;\n"
@@ -130,6 +140,11 @@ static const char fragment_glsl[] =
"#else\n"
" c = vec4(1, 1, 1, 1);\n"
"#endif\n"
+ "#ifdef ADD_NOISE\n"
+ " vec4 noise = vec4(rand(tex_c) / 256.0, rand(tex_c + vec2(1, 1)) / 256.0, rand(tex_c + vec2(2, 2)) / 256.0, 0);\n"
+ " noise.a = max(noise.r, noise.g);\n"
+ " noise.a = max(noise.a, noise.b);\n"
+ "#endif\n"
"#ifdef SHD_MASK\n"
" float ma;\n"
"# if defined(SHD_MASKSAM12) || defined(SHD_MASKSAM21)\n"
@@ -160,6 +175,9 @@ static const char fragment_glsl[] =
"#ifdef SHD_TEXA\n"
" * texture2D(texa, tex_a).r\n"
"#endif\n"
+ "#ifdef ADD_NOISE\n"
+ " + noise\n"
+ "#endif\n"
" ;\n"
"}\n";