summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/evas/engines/gl_common/shader/evas_gl_shaders.x31
-rw-r--r--src/modules/evas/engines/gl_common/shader/fragment.glsl32
2 files changed, 41 insertions, 22 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 b534f66c41..411a680e78 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
@@ -99,26 +99,35 @@ static const char fragment_glsl[] =
"#endif\n"
"// ----------------------------------------------------------------------------\n"
"#ifdef SHD_DITHER\n"
- "const mat4 dm = mat4(vec4( 0, 8, 2, 10),\n"
- " vec4(12, 4, 14, 6),\n"
- " vec4( 3, 11, 1, 9),\n"
- " vec4(15, 7, 13, 5));\n"
- "float dither_closest(vec2 pos, float val)\n"
+ "#ifdef DM_HIQ\n"
+ "#define DMMOD 4.0\n"
+ "#define DMDIV (16.0*256.0)\n"
+ "const mat4 dm = mat4(vec4( 0.0/DMDIV, 8.0/DMDIV, 2.0/DMDIV, 10.0/DMDIV),\n"
+ " vec4(12.0/DMDIV, 4.0/DMDIV, 14.0/DMDIV, 6.0/DMDIV),\n"
+ " vec4( 3.0/DMDIV, 11.0/DMDIV, 1.0/DMDIV, 9.0/DMDIV),\n"
+ " vec4(15.0/DMDIV, 7.0/DMDIV, 13.0/DMDIV, 5.0/DMDIV));\n"
+ "#else\n"
+ "#define DMMOD 2.0\n"
+ "#define DMDIV (4.0*256.0)\n"
+ "const mat2 dm = mat2(vec2( 0.0/DMDIV, 2.0/DMDIV),\n"
+ " vec2( 3.0/DMDIV, 1.0/DMDIV));\n"
+ "#endif\n"
+ "float dither_closest(ivec2 pos, float val)\n"
"{\n"
- " float limit = dm[int(pos.x)][int(pos.y)] / 16.0;\n"
+ " float limit = dm[pos.x][pos.y];\n"
" if (val <= limit) return 0.0;\n"
- " return 1.0;\n"
+ " return (1.0 / 256.0);\n"
"}\n"
- "float dither_8bit(vec2 modpos, float val)\n"
+ "float dither_8bit(ivec2 modpos, float val)\n"
"{\n"
" float val_quant = float(floor(val * 255.0)) / 255.0;\n"
- " float val_delta = (val - val_quant) / (1.0 / 256.0);\n"
+ " float val_delta = val - val_quant;\n"
" float val_roundup = dither_closest(modpos, val_delta);\n"
- " return val_quant + (val_roundup * (1.0 / 256.0));\n"
+ " return val_quant + val_roundup;\n"
"}\n"
"vec4 dither(vec4 col, vec2 pos)\n"
"{\n"
- " vec2 modpos = vec2(mod(float(pos.x), 4.0), mod(float(pos.y), 4.0));\n"
+ " ivec2 modpos = ivec2(int(mod(pos.x, DMMOD)), int(mod(pos.y, DMMOD)));\n"
" return vec4(dither_8bit(modpos, col.r),\n"
" dither_8bit(modpos, col.g),\n"
" dither_8bit(modpos, col.b),\n"
diff --git a/src/modules/evas/engines/gl_common/shader/fragment.glsl b/src/modules/evas/engines/gl_common/shader/fragment.glsl
index b715c8de99..5b1f8c24bc 100644
--- a/src/modules/evas/engines/gl_common/shader/fragment.glsl
+++ b/src/modules/evas/engines/gl_common/shader/fragment.glsl
@@ -98,29 +98,39 @@ uniform float blur_div;
// ----------------------------------------------------------------------------
#ifdef SHD_DITHER
-const mat4 dm = mat4(vec4( 0, 8, 2, 10),
- vec4(12, 4, 14, 6),
- vec4( 3, 11, 1, 9),
- vec4(15, 7, 13, 5));
-float dither_closest(vec2 pos, float val)
+#ifdef DM_HIQ
+#define DMMOD 4.0
+#define DMDIV (16.0*256.0)
+const mat4 dm = mat4(vec4( 0.0/DMDIV, 8.0/DMDIV, 2.0/DMDIV, 10.0/DMDIV),
+ vec4(12.0/DMDIV, 4.0/DMDIV, 14.0/DMDIV, 6.0/DMDIV),
+ vec4( 3.0/DMDIV, 11.0/DMDIV, 1.0/DMDIV, 9.0/DMDIV),
+ vec4(15.0/DMDIV, 7.0/DMDIV, 13.0/DMDIV, 5.0/DMDIV));
+#else
+#define DMMOD 2.0
+#define DMDIV (4.0*256.0)
+const mat2 dm = mat2(vec2( 0.0/DMDIV, 2.0/DMDIV),
+ vec2( 3.0/DMDIV, 1.0/DMDIV));
+#endif
+
+float dither_closest(ivec2 pos, float val)
{
- float limit = dm[int(pos.x)][int(pos.y)] / 16.0;
+ float limit = dm[pos.x][pos.y];
if (val <= limit) return 0.0;
- return 1.0;
+ return (1.0 / 256.0);
}
-float dither_8bit(vec2 modpos, float val)
+float dither_8bit(ivec2 modpos, float val)
{
float val_quant = float(floor(val * 255.0)) / 255.0;
- float val_delta = (val - val_quant) / (1.0 / 256.0);
+ float val_delta = val - val_quant;
float val_roundup = dither_closest(modpos, val_delta);
- return val_quant + (val_roundup * (1.0 / 256.0));
+ return val_quant + val_roundup;
}
vec4 dither(vec4 col, vec2 pos)
{
- vec2 modpos = vec2(mod(float(pos.x), 4.0), mod(float(pos.y), 4.0));
+ ivec2 modpos = ivec2(int(mod(pos.x, DMMOD)), int(mod(pos.y, DMMOD)));
return vec4(dither_8bit(modpos, col.r),
dither_8bit(modpos, col.g),
dither_8bit(modpos, col.b),