fix shaders format
This commit is contained in:
@@ -1,20 +1,76 @@
|
||||
mediump vec3 blend_normal(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{ return mix(base.rgb, stroke.rgb, stroke.a/alpha_tot); }
|
||||
mediump vec3 blend_multiply(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{ return mix(stroke.rgb, mix(base.rgb, base.rgb*stroke.rgb, stroke.a/alpha_tot), base.a/alpha_tot); }
|
||||
mediump vec3 blend_screen(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{ return mix(stroke.rgb, mix(base.rgb, 1.0-(1.0-base.rgb)*(1.0-stroke.rgb), stroke.a/alpha_tot), base.a/alpha_tot); }
|
||||
mediump vec3 blend_colorDodge(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{ return mix(stroke.rgb, mix(base.rgb, base.rgb/(1.0-stroke.rgb), stroke.a/alpha_tot), base.a/alpha_tot); }
|
||||
mediump vec3 blend_overlay(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{ return mix(stroke.rgb, mix(base.rgb, mix(2.0*base.rgb*stroke.rgb, 1.0-2.0*(1.0-base.rgb)*(1.0-stroke.rgb), floor(base.rgb*2.0)), stroke.a/alpha_tot), base.a/alpha_tot); }
|
||||
mediump vec4 blend(mediump vec4 base, mediump vec4 stroke, int mode) {
|
||||
mediump float contribution = (1.0 - base.a) * stroke.a;
|
||||
mediump float alpha_tot = base.a + contribution;
|
||||
if (mode == 0) return vec4(blend_normal(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 1) return vec4(blend_multiply(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 2) return vec4(blend_screen(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 3) return vec4(blend_colorDodge(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 4) return vec4(blend_overlay(base, stroke, alpha_tot), alpha_tot);
|
||||
else return vec4(1.0, 0.0, 0.0, 1.0);
|
||||
{
|
||||
return mix(
|
||||
base.rgb,
|
||||
stroke.rgb,
|
||||
stroke.a/alpha_tot
|
||||
);
|
||||
}
|
||||
|
||||
mediump vec3 blend_multiply(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{
|
||||
return mix(
|
||||
stroke.rgb,
|
||||
mix(
|
||||
base.rgb,
|
||||
base.rgb*stroke.rgb,
|
||||
stroke.a/alpha_tot
|
||||
),
|
||||
base.a/alpha_tot
|
||||
);
|
||||
}
|
||||
|
||||
mediump vec3 blend_screen(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{
|
||||
return mix(
|
||||
stroke.rgb,
|
||||
mix(
|
||||
base.rgb,
|
||||
1.0-(1.0-base.rgb)*(1.0-stroke.rgb),
|
||||
stroke.a/alpha_tot
|
||||
),
|
||||
base.a/alpha_tot
|
||||
);
|
||||
}
|
||||
|
||||
mediump vec3 blend_colorDodge(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{
|
||||
return mix(
|
||||
stroke.rgb,
|
||||
mix(
|
||||
base.rgb,
|
||||
base.rgb/(1.0-stroke.rgb),
|
||||
stroke.a/alpha_tot
|
||||
),
|
||||
base.a/alpha_tot
|
||||
);
|
||||
}
|
||||
|
||||
mediump vec3 blend_overlay(mediump vec4 base, mediump vec4 stroke, mediump float alpha_tot)
|
||||
{
|
||||
return mix(
|
||||
stroke.rgb,
|
||||
mix(
|
||||
base.rgb,
|
||||
mix(
|
||||
2.0*base.rgb*stroke.rgb,
|
||||
1.0-2.0*(1.0-base.rgb)*(1.0-stroke.rgb),
|
||||
floor(base.rgb*2.0)
|
||||
),
|
||||
stroke.a/alpha_tot
|
||||
),
|
||||
base.a/alpha_tot
|
||||
);
|
||||
}
|
||||
|
||||
mediump vec4 blend(mediump vec4 base, mediump vec4 stroke, int mode)
|
||||
{
|
||||
mediump float contribution = (1.0 - base.a) * stroke.a;
|
||||
mediump float alpha_tot = base.a + contribution;
|
||||
if (mode == 0) return vec4(blend_normal(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 1) return vec4(blend_multiply(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 2) return vec4(blend_screen(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 3) return vec4(blend_colorDodge(base, stroke, alpha_tot), alpha_tot);
|
||||
else if (mode == 4) return vec4(blend_overlay(base, stroke, alpha_tot), alpha_tot);
|
||||
else return vec4(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
@@ -2,16 +2,19 @@ mediump vec3 brightness3(mediump vec3 c, mediump float val)
|
||||
{
|
||||
return clamp(c + vec3(val * 2.0 - 1.0), vec3(0), vec3(1));
|
||||
}
|
||||
|
||||
mediump vec3 contrast3(mediump vec3 c, mediump 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));
|
||||
return clamp(factor * (c - 0.5) + 0.5, vec3(0), vec3(1));
|
||||
}
|
||||
|
||||
mediump float brightness1(mediump float c, mediump float val)
|
||||
{
|
||||
return clamp(c + (val * 2.0 - 1.0), 0.0, 1.0);
|
||||
}
|
||||
|
||||
mediump float contrast1(mediump float c, mediump float val)
|
||||
{
|
||||
val = val * 2.0 - 1.0;
|
||||
|
||||
@@ -7,9 +7,10 @@ mediump vec3 rgb2hsv(mediump vec3 c)
|
||||
mediump 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)
|
||||
{
|
||||
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);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
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);
|
||||
return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user