use high on painting shaders

This commit is contained in:
2019-03-05 10:21:49 +01:00
parent 317292318a
commit 9e26c67de6
13 changed files with 111 additions and 111 deletions

View File

@@ -1,9 +1,9 @@
mediump float blend_stroke_screen(mediump float base, mediump float stroke)
highp float blend_stroke_screen(highp float base, highp float stroke)
{
return base + stroke - (base * stroke);
}
mediump float blend_stroke_hard_light(mediump float base, mediump float stroke)
mediump float blend_stroke_hard_light(highp float base, highp float stroke)
{
if (stroke < 0.5)
return base * (stroke * 2.0); // multiply
@@ -11,12 +11,12 @@ mediump float blend_stroke_hard_light(mediump float base, mediump float stroke)
return blend_stroke_screen(base, 2.0 * stroke - 1.0);
}
mediump float blend_stroke_hard_mix(mediump float base, mediump float stroke)
highp float blend_stroke_hard_mix(highp float base, highp float stroke)
{
return base + stroke < 0.5 ? 0.0 : base + stroke;
}
mediump float blend_stroke_color_dodge(mediump float base, mediump float stroke)
highp float blend_stroke_color_dodge(highp float base, highp float stroke)
{
if (base == 0.0)
return 0.0;
@@ -26,7 +26,7 @@ mediump float blend_stroke_color_dodge(mediump float base, mediump float stroke)
return base / (1.0 - stroke);
}
mediump float blend_stroke_color_burn(mediump float base, mediump float stroke)
highp float blend_stroke_color_burn(highp float base, highp float stroke)
{
if (base == 1.0)
return 1.0;
@@ -36,20 +36,20 @@ mediump float blend_stroke_color_burn(mediump float base, mediump float stroke)
return 1.0 - min(1.0, (1.0 - base) / stroke);
}
mediump float blend_stroke_linear_height(mediump float base, mediump float stroke, mediump float depth)
highp float blend_stroke_linear_height(highp float base, highp float stroke, highp float depth)
{
mediump float partial = (1.0 - stroke) * pow(depth, 0.25) + (base * depth * 10.0);
highp float partial = (1.0 - stroke) * pow(depth, 0.25) + (base * depth * 10.0);
return base * partial;
}
mediump float blend_stroke_height(mediump float base, mediump float stroke, mediump float depth)
highp float blend_stroke_height(highp float base, highp float stroke, highp float depth)
{
mediump float A = pow((1.0 - stroke), max(1.0, (1.0 - depth) * 10.0)) * pow(depth, 0.25);
mediump float B = (base * depth * 5.0);
highp float A = pow((1.0 - stroke), max(1.0, (1.0 - depth) * 10.0)) * pow(depth, 0.25);
highp float B = (base * depth * 5.0);
return base * (A + B);
}
mediump float blend_stroke(mediump float base, mediump float stroke, mediump float depth, int mode)
highp float blend_stroke(highp float base, highp float stroke, highp float depth, int mode)
{
if (mode == 0) /* normal */ return mix(base, stroke, depth);
else if (mode == 1) /* multiply */ return mix(base, base * stroke, depth);

View File

@@ -1,4 +1,4 @@
mediump vec3 blend_normal(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
highp vec3 blend_normal(highp vec4 base, highp vec4 stroke, highp float alpha_tot)
{
return mix(
base.rgb,
@@ -7,7 +7,7 @@ mediump vec3 blend_normal(mediump vec4 base, mediump vec4 stroke, mediump float
);
}
mediump vec3 blend_multiply(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
highp vec3 blend_multiply(highp vec4 base, highp vec4 stroke, highp float alpha_tot)
{
return mix(
stroke.rgb,
@@ -20,7 +20,7 @@ mediump vec3 blend_multiply(mediump vec4 base, mediump vec4 stroke, mediump floa
);
}
mediump vec3 blend_screen(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
highp vec3 blend_screen(highp vec4 base, highp vec4 stroke, highp float alpha_tot)
{
return mix(
stroke.rgb,
@@ -33,7 +33,7 @@ mediump vec3 blend_screen(mediump vec4 base, mediump vec4 stroke, mediump float
);
}
mediump vec3 blend_colorDodge(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
highp vec3 blend_colorDodge(highp vec4 base, highp vec4 stroke, highp float alpha_tot)
{
return mix(
stroke.rgb,
@@ -46,7 +46,7 @@ mediump vec3 blend_colorDodge(mediump vec4 base, mediump vec4 stroke, mediump fl
);
}
mediump vec3 blend_overlay(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
highp vec3 blend_overlay(highp vec4 base, highp vec4 stroke, highp float alpha_tot)
{
return mix(
stroke.rgb,
@@ -63,7 +63,7 @@ mediump vec3 blend_overlay(mediump vec4 base, mediump vec4 stroke, mediump float
);
}
mediump vec4 blend(mediump vec4 base, mediump vec4 stroke, int mode)
highp vec4 blend(highp vec4 base, highp vec4 stroke, int mode)
{
mediump float contribution = (1.0 - base.a) * stroke.a;
mediump float alpha_tot = base.a + contribution;

View File

@@ -1,6 +1,6 @@
mediump vec4 blur(sampler2D t, mediump vec2 uv)
highp vec4 blur(sampler2D t, highp vec2 uv)
{
mediump vec4 sum = texture(t, uv);
highp vec4 sum = texture(t, uv);
sum += textureOffset(t, uv, ivec2(-1, -1));
sum += textureOffset(t, uv, ivec2(-1, 0));
sum += textureOffset(t, uv, ivec2(-1, 1));

View File

@@ -1,23 +1,23 @@
mediump vec3 brightness3(mediump vec3 c, mediump float val)
highp vec3 brightness3(highp vec3 c, highp float val)
{
return clamp(c + vec3(val * 2.0 - 1.0), vec3(0), vec3(1));
}
mediump vec3 contrast3(mediump vec3 c, mediump float val)
highp vec3 contrast3(highp vec3 c, highp float val)
{
val = val * 2.0 - 1.0;
mediump float factor = ((259.0 / 255.0) * (val + 1.0)) / (1.0 * ((259.0 / 255.0) - val));
highp float v = val * 2.0 - 1.0;
highp float factor = ((259.0 / 255.0) * (v + 1.0)) / (1.0 * ((259.0 / 255.0) - v));
return clamp(factor * (c - 0.5) + 0.5, vec3(0), vec3(1));
}
mediump float brightness1(mediump float c, mediump float val)
highp float brightness1(highp float c, highp float val)
{
return clamp(c + (val * 2.0 - 1.0), 0.0, 1.0);
}
mediump float contrast1(mediump float c, mediump float val)
highp float contrast1(highp float c, highp float val)
{
val = val * 2.0 - 1.0;
mediump float factor = ((259.0 / 255.0) * (val + 1.0)) / (1.0 * ((259.0 / 255.0) - val));
highp float v = val * 2.0 - 1.0;
highp float factor = ((259.0 / 255.0) * (v + 1.0)) / (1.0 * ((259.0 / 255.0) - v));
return clamp(factor * (c - 0.5) + 0.5, 0.0, 1.0);
}

View File

@@ -1,16 +1,16 @@
mediump vec3 rgb2hsv(mediump vec3 c)
highp vec3 rgb2hsv(highp vec3 c)
{
mediump vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
mediump vec4 p = mix(vec4(c.bg, k.wz), vec4(c.gb, k.xy), step(c.b, c.g));
mediump vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
mediump float d = q.x - min(q.w, q.y);
mediump float e = 1.0e-10;
highp vec4 k = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
highp vec4 p = mix(vec4(c.bg, k.wz), vec4(c.gb, k.xy), step(c.b, c.g));
highp vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
highp float d = q.x - min(q.w, q.y);
highp float e = 1.0e-10;
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
}
mediump vec3 hsv2rgb(mediump vec3 c)
highp vec3 hsv2rgb(highp vec3 c)
{
mediump vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
mediump vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
highp vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
highp vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
}