merge of long discussed new pipeline
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
/*a fast implementation of the chromakey program
|
||||
(c) 2008 Edward Cannon (adapted to GLSL by Olive Team)
|
||||
feel free to use or modify at will*/
|
||||
|
||||
/*the following three functions convert RGB into YCbCr in the same manner as in JPEG images*/
|
||||
|
||||
uniform vec3 key_color;
|
||||
uniform float tola;
|
||||
uniform float tolb;
|
||||
uniform bool opt;
|
||||
uniform int mode;
|
||||
|
||||
float rgb2y (vec3 c) {
|
||||
/*a utility function to convert colors from REC.709 RGB into YCbCr*/
|
||||
|
||||
// This isn’t colour managed and is a huge mess, but in the
|
||||
// short term, using correct weights will give significantly
|
||||
// more ideal results. The correct weights for REC.709 are
|
||||
// 0.2126 R, 0.7152 G, and 0.0722 B. Easy change.
|
||||
// The coefficients for YCbCr are calculated off of the
|
||||
// REC.709 values.
|
||||
return (0.2126*c.r + 0.7152*c.g + 0.0722*c.b);
|
||||
}
|
||||
|
||||
float rgb2cb (vec3 c) {
|
||||
/*a utility function to convert colors from REC.709 RGB into YCbCr*/
|
||||
return (0.5 + -0.1145721061*c.r - 0.3854278939*c.g + 0.5*c.b);
|
||||
}
|
||||
|
||||
float rgb2cr (vec3 c) {
|
||||
/*a utility function to convert colors from REC.709 RGB into YCbCr*/
|
||||
return (0.5 + 0.5*c.r - 0.4541529083*c.g - 0.0458470917*c.b);
|
||||
}
|
||||
|
||||
float colorclose(float Cb_p,float Cr_p,float Cb_key,float Cr_key,float tola,float tolb) {
|
||||
/*decides if a color is close to the specified hue*/
|
||||
float temp = sqrt(((Cb_key-Cb_p)*(Cb_key-Cb_p))+((Cr_key-Cr_p)*(Cr_key-Cr_p)));
|
||||
if (temp < tola) {return (0.0);}
|
||||
if (temp < tolb) {return ((temp-tola)/(tolb-tola));}
|
||||
return (1.0);
|
||||
}
|
||||
|
||||
vec4 process(vec4 texture_color) {
|
||||
float cb_key = rgb2cb(key_color);
|
||||
float cr_key = rgb2cr(key_color);
|
||||
|
||||
float cb = rgb2cb(texture_color.rgb);
|
||||
float cr = rgb2cr(texture_color.rgb);
|
||||
float mask = colorclose(cb, cr, cb_key, cr_key, (tola/100.0), (tolb/100.0));
|
||||
|
||||
if (mode == 0) { // composite
|
||||
//float submask = 1.0-mask;
|
||||
float submask = 0.0;
|
||||
texture_color.r = max(texture_color.r - submask*key_color.r, 0.0) + submask;
|
||||
texture_color.g = max(texture_color.g - submask*key_color.g, 0.0) + submask;
|
||||
texture_color.b = max(texture_color.b - submask*key_color.b, 0.0) + submask;
|
||||
texture_color.a *= mask;
|
||||
|
||||
// premultiply
|
||||
texture_color.rgb *= texture_color.a;
|
||||
} else if (mode == 1) { // alpha
|
||||
texture_color.rgb = vec3(mask);
|
||||
} else if (mode == 2) { // original
|
||||
}
|
||||
|
||||
return texture_color;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Chroma Key" category="Keying">
|
||||
<row name="Mode">
|
||||
<field type="combo" default="0" id="mode">
|
||||
<option>Composite</option>
|
||||
<option>Alpha</option>
|
||||
<option>Original</option>
|
||||
</field>
|
||||
</row>
|
||||
<row name="Key Color">
|
||||
<field type="color" r="0" g="255" b="0" id="key_color"/>
|
||||
</row>
|
||||
<row name="Lower Tolerance">
|
||||
<field type="double" min="0" default="5" max="100" id="tola"/>
|
||||
</row>
|
||||
<row name="Upper Tolerance">
|
||||
<field type="double" min="0" default="25" max="100" id="tolb"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="chromakey.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,74 @@
|
||||
#version 110
|
||||
|
||||
uniform float temperature;
|
||||
uniform float tint;
|
||||
uniform float exposure;
|
||||
uniform float contrast;
|
||||
uniform float highlights;
|
||||
uniform float shadows;
|
||||
uniform float whites;
|
||||
uniform float blacks;
|
||||
uniform float saturation;
|
||||
|
||||
uniform sampler2D myTexture;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(myTexture, vTexCoord);
|
||||
|
||||
vec3 rgb = textureColor.rgb;
|
||||
|
||||
// temperature
|
||||
float temp = temperature * 0.01;
|
||||
float redTemp = (temp <= 66.0) ? 1.0 : min(1.0, max(0.0,
|
||||
(1.2929361861 * pow(temp - 60.0, -0.1332047592))
|
||||
));
|
||||
float greenTemp = min(1.0, max(0.0,
|
||||
(temp <= 66.0) ? (0.3900815788 * log(temp) - 0.6318414438) : (1.1298908609 * pow(temp - 60.0, -0.0755148492))
|
||||
));
|
||||
float blueTemp = (temp >= 66.0) ? 1.0 : min(1.0, max(0.0,
|
||||
(0.5432067891 * log(temp - 10.0) - 1.1962540891)
|
||||
));
|
||||
rgb *= vec3(redTemp, greenTemp, blueTemp);
|
||||
|
||||
// tint
|
||||
rgb.g *= ((tint*0.01)+1.0);
|
||||
|
||||
// exposure
|
||||
rgb *= pow(2.0, exposure*0.01);
|
||||
|
||||
// contrast
|
||||
float contr_val = (contrast*0.01);
|
||||
rgb = (rgb*contr_val)-((contr_val-1.0)*0.5);
|
||||
|
||||
|
||||
// shadows/highlights
|
||||
//float luma = 0.33*rgb.r + 0.5*rgb.g + 0.16*rgb.b;
|
||||
if (rgb.r < 0.5 && rgb.g < 0.5 && rgb.b < 0.5) {
|
||||
float shadow_val = 1.0-(shadows*0.01);
|
||||
rgb = vec3(pow(rgb.r*2.0, shadow_val)*0.5, pow(rgb.g*2.0, shadow_val)*0.5, pow(rgb.b*2.0, shadow_val)*0.5);
|
||||
} else if (rgb.r > 0.5 && rgb.g > 0.5 && rgb.b > 0.5) {
|
||||
float highlight_val = 1.0-(highlights*0.01);
|
||||
rgb = vec3((pow((rgb.r-0.5)*2.0, highlight_val)*0.5)+0.5, (pow((rgb.g-0.5)*2.0, highlight_val)*0.5)+0.5, (pow((rgb.b-0.5)*2.0, highlight_val)*0.5)+0.5);
|
||||
}
|
||||
|
||||
|
||||
// whites
|
||||
rgb *= (whites*0.01);
|
||||
|
||||
// blacks
|
||||
float black_val = 2.0-(blacks*0.01);
|
||||
rgb = (rgb*black_val)-(black_val-1.0);
|
||||
|
||||
// saturation
|
||||
const vec3 W = vec3(0.2125, 0.7154, 0.0721);
|
||||
vec3 intensity = vec3(dot(rgb, W));
|
||||
rgb = mix(intensity, rgb, saturation*0.01);
|
||||
|
||||
gl_FragColor = vec4(
|
||||
rgb.r,
|
||||
rgb.g,
|
||||
rgb.b,
|
||||
textureColor.a
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Color Correction" category="Color">
|
||||
<row name="Temperature">
|
||||
<field type="double" min="2000" default="6600" max="40000" id="temperature"/>
|
||||
</row>
|
||||
<row name="Tint">
|
||||
<field type="double" min="-100" default="0" id="tint"/>
|
||||
</row>
|
||||
<row name="Exposure">
|
||||
<field type="double" default="0" id="exposure"/>
|
||||
</row>
|
||||
<row name="Contrast">
|
||||
<field type="double" min="0" default="100" id="contrast"/>
|
||||
</row>
|
||||
<row name="Highlights">
|
||||
<field type="double" default="0" max="100" id="highlights"/>
|
||||
</row>
|
||||
<row name="Shadows">
|
||||
<field type="double" default="0" max="100" id="shadows"/>
|
||||
</row>
|
||||
<row name="Whites (Brightness)">
|
||||
<field type="double" min="0" default="100" id="whites"/>
|
||||
</row>
|
||||
<row name="Blacks (Darkness)">
|
||||
<field type="double" min="0" default="100" max="200" id="blacks"/>
|
||||
</row>
|
||||
<row name="Saturation">
|
||||
<field type="double" min="0" default="100" id="saturation"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="colorcorrection.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,78 @@
|
||||
/* Filter by color characteristic simple program
|
||||
Based on Edward Cannon's Simple Chroma Key (adaptation by Olive Team)
|
||||
RGB to HSV based on MattKC's toonify source code
|
||||
Feel free to modify and use at will */
|
||||
|
||||
uniform float loc;
|
||||
uniform float hic;
|
||||
uniform int compo;
|
||||
uniform bool invert;
|
||||
|
||||
float rgb2luma(vec3 c) {
|
||||
return (max(max(c.r,c.g), c.b) + min(min(c.r,c.g), c.b))/2.0;
|
||||
}
|
||||
|
||||
vec3 rgb2hsv(vec3 c)
|
||||
{
|
||||
float r = c.r;
|
||||
float b = c.b;
|
||||
float g = c.g;
|
||||
float minv, maxv, delta;
|
||||
vec3 res;
|
||||
|
||||
minv = min(min(r, g), b);
|
||||
maxv = max(max(r, g), b);
|
||||
res.z = maxv; // v
|
||||
|
||||
delta = maxv - minv;
|
||||
|
||||
if( maxv != 0.0 )
|
||||
res.y = delta / maxv; // s
|
||||
else {
|
||||
// r = g = b = 0 // s = 0, v is undefined
|
||||
res.y = 0.0;
|
||||
res.x = -1.0;
|
||||
return res;
|
||||
}
|
||||
|
||||
if( r == maxv )
|
||||
res.x = ( g - b ) / delta; // between yellow & magenta
|
||||
else if( g == maxv )
|
||||
res.x = 2.0 + ( b - r ) / delta; // between cyan & yellow
|
||||
else
|
||||
res.x = 4.0 + ( r - g ) / delta; // between magenta & cyan
|
||||
|
||||
res.x = res.x * 60.0; // degrees
|
||||
if( res.x < 0.0 )
|
||||
res.x = res.x + 360.0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
bool isNotIncreasingSequence(float a, float b, float c) {
|
||||
return (c < b || a > b);
|
||||
}
|
||||
|
||||
vec4 process(vec4 texture_color) {
|
||||
vec3 color = texture_color.rgb;
|
||||
float toCheck = 0.0;
|
||||
|
||||
if (compo == 0) {
|
||||
toCheck = rgb2luma(color)*100.0;
|
||||
} else if (compo == 4) {
|
||||
toCheck = color.r*100.0;
|
||||
} else if (compo == 5) {
|
||||
toCheck = color.g*100.0;
|
||||
} else if (compo == 6) {
|
||||
toCheck = color.b*100.0;
|
||||
} else if (compo == 1) {
|
||||
toCheck = rgb2hsv(color).z*100.0;
|
||||
} else if (compo == 2) {
|
||||
toCheck = rgb2hsv(color).x/3.6;
|
||||
} else if (compo == 3) {
|
||||
toCheck = rgb2hsv(color).y*100.0;
|
||||
}
|
||||
texture_color.a = isNotIncreasingSequence(loc, toCheck, hic) ? (invert ? texture_color.a : 0.0) : (invert ? 0.0 : texture_color.a);
|
||||
texture_color.rgb *= texture_color.a;
|
||||
return texture_color;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Color Finder" category="Keying">
|
||||
<row name="Find by">
|
||||
<field type="combo" default="0" id="compo">
|
||||
<option>Luminance</option>
|
||||
<option>Value</option>
|
||||
<option>Hue</option>
|
||||
<option>Saturation</option>
|
||||
<option>Red</option>
|
||||
<option>Green</option>
|
||||
<option>Blue</option>
|
||||
</field>
|
||||
</row>
|
||||
<row name="Lower Limit">
|
||||
<field type="double" min="0" default="0" max="100" id="loc"/>
|
||||
</row>
|
||||
<row name="Upper Limit">
|
||||
<field type="double" min="0" default="100" max="100" id="hic"/>
|
||||
</row>
|
||||
<row name="Invert">
|
||||
<field type="bool" min="0" default="100" max="100" id="invert"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="colorsel.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,9 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D tex;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main(void) {
|
||||
vec4 textureColor = texture2D(tex, vTexCoord);
|
||||
gl_FragColor = textureColor;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#version 110
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
void main() {
|
||||
vTexCoord = gl_MultiTexCoord0.xy;
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
#version 110
|
||||
|
||||
uniform sampler2D tex0;
|
||||
uniform float time;
|
||||
uniform vec2 resolution;
|
||||
uniform float stitching_size;
|
||||
uniform bool invert;
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
vec4 PostFX(sampler2D tex, vec2 uv, float time) {
|
||||
vec4 c = vec4(0.0);
|
||||
float size = stitching_size;
|
||||
vec2 cPos = uv * resolution;
|
||||
vec2 tlPos = floor(cPos / vec2(size, size));
|
||||
tlPos *= size;
|
||||
int remX = int(mod(cPos.x, size));
|
||||
int remY = int(mod(cPos.y, size));
|
||||
if (remX == 0 && remY == 0)
|
||||
tlPos = cPos;
|
||||
vec2 blPos = tlPos;
|
||||
blPos.y += (size - 1.0);
|
||||
if ((remX == remY) ||
|
||||
(((int(cPos.x) - int(blPos.x)) == (int(blPos.y) - int(cPos.y)))))
|
||||
{
|
||||
if (!invert)
|
||||
c = vec4(0.2, 0.15, 0.05, 1.0);
|
||||
else
|
||||
c = texture2D(tex, tlPos * vec2(1.0/resolution.x, 1.0/resolution.y)) * 1.4;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!invert)
|
||||
c = texture2D(tex, tlPos * vec2(1.0/resolution.x, 1.0/resolution.y)) * 1.4;
|
||||
else
|
||||
c = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
vec2 uv = vTexCoord;
|
||||
gl_FragColor = PostFX(tex0, uv, time);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Cross Stitch" category="Stylize">
|
||||
<row name="Size">
|
||||
<field type="double" default="6" id="stitching_size"/>
|
||||
</row>
|
||||
<row name="Invert">
|
||||
<field type="bool" default="0" id="invert"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="crossstitch.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,38 @@
|
||||
/* Original source code: https://www.youtube.com/watch?v=I23zT7iu_Y4
|
||||
Adapted */
|
||||
|
||||
varying vec2 vTexCoord;
|
||||
uniform vec2 resolution;
|
||||
uniform sampler2D tex;
|
||||
|
||||
uniform float contrast100;
|
||||
uniform float level;
|
||||
uniform bool invert;
|
||||
uniform bool hslmode; // luminance is 2*V
|
||||
|
||||
void main() {
|
||||
|
||||
float contrast = contrast100 / 100.0;
|
||||
|
||||
vec2 onePixel = vec2(floor(level) / resolution.x, floor(level) / resolution.y); // calculating the size of one pixel on the screen for the current resolution
|
||||
|
||||
vec3 color = vec3(.5); // initialize color with half value on all channels
|
||||
if (invert) {
|
||||
color += texture2D(tex, vTexCoord - onePixel).rgb * contrast;
|
||||
color -= texture2D(tex, vTexCoord + onePixel).rgb * contrast;
|
||||
} else {
|
||||
color -= texture2D(tex, vTexCoord - onePixel).rgb * contrast;
|
||||
color += texture2D(tex, vTexCoord + onePixel).rgb * contrast;
|
||||
}
|
||||
|
||||
// original color
|
||||
vec4 color0 = texture2D(tex,vTexCoord);
|
||||
|
||||
// grayscale
|
||||
float gray = (color.r + color.g + color.b) / (hslmode ? 3.0 : 1.5);
|
||||
|
||||
//self-multiply
|
||||
color = color0.rgb * gray;
|
||||
|
||||
gl_FragColor = vec4(color * color0.a, color0.a);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Emboss" category="Stylize">
|
||||
<row name="Contrast">
|
||||
<field type="double" min="0" default="50" max="100" id="contrast100"/>
|
||||
</row>
|
||||
<row name="Resolution">
|
||||
<field type="double" min="0" default="1" max="100" id="level"/>
|
||||
</row>
|
||||
<row name="HSL mode">
|
||||
<field type="bool" min="0" default="100" max="100" id="hslmode"/>
|
||||
</row>
|
||||
<row name="Invert">
|
||||
<field type="bool" min="0" default="100" max="100" id="invert"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="emboss.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,53 @@
|
||||
#version 110
|
||||
|
||||
/*varying vec4 vertColor;
|
||||
varying vec4 vertTexCoord;
|
||||
uniform sampler2D texture;
|
||||
//uniform vec2 texOffset;
|
||||
|
||||
void main(void) {
|
||||
// Grouping texcoord variables in order to make it work in the GMA 950. See post #13
|
||||
// in this thread:
|
||||
// http://www.idevgames.com/forums/thread-3467.html
|
||||
vec2 texOffset = vec2(1.0);
|
||||
|
||||
vec2 tc0 = vertTexCoord.st + vec2(-texOffset.s, -texOffset.t);
|
||||
vec2 tc1 = vertTexCoord.st + vec2( 0.0, -texOffset.t);
|
||||
vec2 tc2 = vertTexCoord.st + vec2(+texOffset.s, -texOffset.t);
|
||||
vec2 tc3 = vertTexCoord.st + vec2(-texOffset.s, 0.0);
|
||||
vec2 tc4 = vertTexCoord.st + vec2( 0.0, 0.0);
|
||||
vec2 tc5 = vertTexCoord.st + vec2(+texOffset.s, 0.0);
|
||||
vec2 tc6 = vertTexCoord.st + vec2(-texOffset.s, +texOffset.t);
|
||||
vec2 tc7 = vertTexCoord.st + vec2( 0.0, +texOffset.t);
|
||||
vec2 tc8 = vertTexCoord.st + vec2(+texOffset.s, +texOffset.t);
|
||||
|
||||
vec4 col0 = texture2D(texture, tc0);
|
||||
vec4 col1 = texture2D(texture, tc1);
|
||||
vec4 col2 = texture2D(texture, tc2);
|
||||
vec4 col3 = texture2D(texture, tc3);
|
||||
vec4 col4 = texture2D(texture, tc4);
|
||||
vec4 col5 = texture2D(texture, tc5);
|
||||
vec4 col6 = texture2D(texture, tc6);
|
||||
vec4 col7 = texture2D(texture, tc7);
|
||||
vec4 col8 = texture2D(texture, tc8);
|
||||
|
||||
vec4 sum = 8.0 * col4 - (col0 + col1 + col2 + col3 + col5 + col6 + col7 + col8);
|
||||
gl_FragColor = vec4(sum.rgb, 1.0);// * vertColor;
|
||||
}*/
|
||||
|
||||
varying vec4 vertTexCoord;
|
||||
uniform sampler2D texture;
|
||||
//uniform vec2 pixels;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 pixels = vec2(16.0, 9.0);
|
||||
|
||||
vec2 p = vertTexCoord.st;
|
||||
|
||||
p.x -= mod(p.x, 1.0 / pixels.x);
|
||||
p.y -= mod(p.y, 1.0 / pixels.y);
|
||||
|
||||
vec3 col = texture2D(texture, p).rgb;
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Find Edges" category="Color">
|
||||
<row name="Bypass">
|
||||
<field type="bool" default="0" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="findedges.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,23 @@
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
|
||||
uniform float size;
|
||||
|
||||
vec4 process(vec4 col) {
|
||||
float maxFactor = 2.0 - (size * 0.01);
|
||||
|
||||
vec2 uv;
|
||||
vec2 xy = 2.0 * v_texcoord - 1.0;
|
||||
float d = length(xy);
|
||||
if (d < (2.0-maxFactor)) {
|
||||
d = length(xy * maxFactor);
|
||||
float z = sqrt(1.0 - d * d);
|
||||
float r = atan(d, z) / M_PI;
|
||||
float phi = atan(xy.y, xy.x);
|
||||
|
||||
uv.x = r * cos(phi) + 0.5;
|
||||
uv.y = r * sin(phi) + 0.5;
|
||||
} else {
|
||||
uv = v_texcoord;
|
||||
}
|
||||
return texture2D(texture, uv);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Fisheye" category="Distort">
|
||||
<row name="Size">
|
||||
<field type="double" min="0" default="100" id="size"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="fisheye.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,33 @@
|
||||
uniform float hue;
|
||||
uniform float saturation;
|
||||
uniform float brightness;
|
||||
|
||||
vec3 rgb2hsv(vec3 c) {
|
||||
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
|
||||
vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g));
|
||||
vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r));
|
||||
|
||||
float d = q.x - min(q.w, q.y);
|
||||
float e = 1.0e-10;
|
||||
return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x);
|
||||
}
|
||||
|
||||
vec3 hsv2rgb(vec3 c) {
|
||||
vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
||||
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);
|
||||
}
|
||||
|
||||
vec4 process(vec4 tex_color) {
|
||||
vec3 hsv = rgb2hsv(tex_color.rgb);
|
||||
hsv.r += (hue/360.0);
|
||||
hsv.g *= (saturation*0.01);
|
||||
hsv.b *= (brightness*0.01);
|
||||
|
||||
vec3 rgb = hsv2rgb(hsv);
|
||||
|
||||
return vec4(
|
||||
rgb.rgb,
|
||||
tex_color.a
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Hue/Saturation/Brightness" category="Color">
|
||||
<row name="Hue">
|
||||
<field type="double" default="0" id="hue"/>
|
||||
</row>
|
||||
<row name="Saturation">
|
||||
<field type="double" min="0" default="100" id="saturation"/>
|
||||
</row>
|
||||
<row name="Brightness">
|
||||
<field type="double" min="0" default="100" id="brightness"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="huesatbri.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,7 @@
|
||||
uniform float amount;
|
||||
|
||||
vec4 process(vec4 col) {
|
||||
float amount_val = amount * 0.01;
|
||||
vec3 color = col.rgb+((vec3(1.0)-col.rgb-col.rgb)*vec3(amount_val));
|
||||
return vec4(color, col.a);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Invert" category="Color">
|
||||
<row name="Amount">
|
||||
<field type="double" min="0" default="100" max="100" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="invert.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,29 @@
|
||||
/* Luma key simple program
|
||||
Based on Edward Cannon's Simple Chroma Key (adaptation by Olive Team)
|
||||
Feel free to modify and use at will */
|
||||
|
||||
uniform sampler2D tex;
|
||||
varying vec2 vTexCoord;
|
||||
|
||||
uniform float loc;
|
||||
uniform float hic;
|
||||
uniform bool invert;
|
||||
|
||||
void main(void) {
|
||||
vec4 texture_color = texture2D(tex,vTexCoord);
|
||||
|
||||
float luma = max(max(texture_color.r,texture_color.g), texture_color.b) + min(min(texture_color.r,texture_color.g), texture_color.b);
|
||||
|
||||
luma /= 2.0;
|
||||
|
||||
if (luma > hic/100.0) {
|
||||
texture_color.a = (invert ? 0.0 : 1.0);
|
||||
} else if (luma < loc/100.0) {
|
||||
texture_color.a = (invert ? 1.0 : 0.0);
|
||||
} else {
|
||||
texture_color.a = (invert ? 1.0-luma : luma);
|
||||
}
|
||||
|
||||
texture_color.rgb *= texture_color.a;
|
||||
gl_FragColor = texture_color;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Luma Key" category="Keying">
|
||||
<row name="Lower Limit">
|
||||
<field type="double" min="0" default="0" max="100" id="loc"/>
|
||||
</row>
|
||||
<row name="Upper Limit">
|
||||
<field type="double" min="0" default="100" max="100" id="hic"/>
|
||||
</row>
|
||||
<row name="Invert">
|
||||
<field type="bool" min="0" default="100" max="100" id="invert"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="lumakey.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,13 @@
|
||||
uniform float gamma_cent; // 0.6
|
||||
uniform float numColors; // 8.0
|
||||
|
||||
vec4 process(vec4 color) {
|
||||
float gamma = gamma_cent*0.01;
|
||||
vec3 c = color.rgb;
|
||||
c = pow(c, vec3(gamma, gamma, gamma));
|
||||
c = c * numColors;
|
||||
c = floor(c);
|
||||
c = c / numColors;
|
||||
c = pow(c, vec3(1.0/gamma));
|
||||
return vec4(c, color.a);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Posterize" category="Stylize">
|
||||
<row name="Colors">
|
||||
<field type="double" min="0" default="8" id="numColors"/>
|
||||
</row>
|
||||
<row name="Gamma">
|
||||
<field type="double" min="0" default="60" id="gamma_cent"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="posterize.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,168 @@
|
||||
#version 150
|
||||
uniform sampler2D tex0;
|
||||
in vec2 vTexCoord;
|
||||
out vec4 FragColor;
|
||||
|
||||
uniform float colors; // 12.0
|
||||
uniform float sat_levels; // 4.0
|
||||
uniform float bri_levels; // 4.0
|
||||
uniform float edge_thres; // 0.2;
|
||||
uniform float edge_thres2; // 5.0;
|
||||
|
||||
vec3 RGBtoHSV( float r, float g, float b)
|
||||
{
|
||||
float minv, maxv, delta;
|
||||
vec3 res;
|
||||
|
||||
minv = min(min(r, g), b);
|
||||
maxv = max(max(r, g), b);
|
||||
res.z = maxv; // v
|
||||
|
||||
delta = maxv - minv;
|
||||
|
||||
if( maxv != 0.0 )
|
||||
res.y = delta / maxv; // s
|
||||
else {
|
||||
// r = g = b = 0 // s = 0, v is undefined
|
||||
res.y = 0.0;
|
||||
res.x = -1.0;
|
||||
return res;
|
||||
}
|
||||
|
||||
if( r == maxv )
|
||||
res.x = ( g - b ) / delta; // between yellow & magenta
|
||||
else if( g == maxv )
|
||||
res.x = 2.0 + ( b - r ) / delta; // between cyan & yellow
|
||||
else
|
||||
res.x = 4.0 + ( r - g ) / delta; // between magenta & cyan
|
||||
|
||||
res.x = res.x * 60.0; // degrees
|
||||
if( res.x < 0.0 )
|
||||
res.x = res.x + 360.0;
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
vec3 HSVtoRGB(float h, float s, float v )
|
||||
{
|
||||
int i;
|
||||
float f, p, q, t;
|
||||
vec3 res;
|
||||
|
||||
if( s == 0.0 )
|
||||
{
|
||||
// achromatic (grey)
|
||||
res.x = v;
|
||||
res.y = v;
|
||||
res.z = v;
|
||||
return res;
|
||||
}
|
||||
|
||||
h /= 60.0; // sector 0 to 5
|
||||
i = int(floor( h ));
|
||||
f = h - float(i); // factorial part of h
|
||||
p = v * ( 1.0 - s );
|
||||
q = v * ( 1.0 - s * f );
|
||||
t = v * ( 1.0 - s * ( 1.0 - f ) );
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0:
|
||||
res.x = v;
|
||||
res.y = t;
|
||||
res.z = p;
|
||||
break;
|
||||
case 1:
|
||||
res.x = q;
|
||||
res.y = v;
|
||||
res.z = p;
|
||||
break;
|
||||
case 2:
|
||||
res.x = p;
|
||||
res.y = v;
|
||||
res.z = t;
|
||||
break;
|
||||
case 3:
|
||||
res.x = p;
|
||||
res.y = q;
|
||||
res.z = v;
|
||||
break;
|
||||
case 4:
|
||||
res.x = t;
|
||||
res.y = p;
|
||||
res.z = v;
|
||||
break;
|
||||
default: // case 5:
|
||||
res.x = v;
|
||||
res.y = p;
|
||||
res.z = q;
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// averaged pixel intensity from 3 color channels
|
||||
float avg_intensity(vec4 pix)
|
||||
{
|
||||
return (pix.r + pix.g + pix.b)/3.;
|
||||
}
|
||||
|
||||
vec4 get_pixel(vec2 coords, float dx, float dy)
|
||||
{
|
||||
return texture(tex0,coords + vec2(dx, dy));
|
||||
}
|
||||
|
||||
// returns pixel color
|
||||
float IsEdge(in vec2 coords)
|
||||
{
|
||||
float dxtex = 1.0 /float(textureSize(tex0,0)) ;
|
||||
float dytex = 1.0 /float(textureSize(tex0,0));
|
||||
float pix[9];
|
||||
int k = -1;
|
||||
float delta;
|
||||
|
||||
// read neighboring pixel intensities
|
||||
for (int i=-1; i<2; i++) {
|
||||
for(int j=-1; j<2; j++) {
|
||||
k++;
|
||||
pix[k] = avg_intensity(get_pixel(coords,float(i)*dxtex,
|
||||
float(j)*dytex));
|
||||
}
|
||||
}
|
||||
|
||||
// average color differences around neighboring pixels
|
||||
delta = (abs(pix[1]-pix[7])+
|
||||
abs(pix[5]-pix[3]) +
|
||||
abs(pix[0]-pix[8])+
|
||||
abs(pix[2]-pix[6])
|
||||
)/4.;
|
||||
|
||||
//return clamp(5.5*delta,0.0,1.0);
|
||||
return clamp(edge_thres2*delta,0.0,1.0);
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vTexCoord.xy;
|
||||
vec4 tc = vec4(1.0, 0.0, 0.0, 1.0);
|
||||
vec3 colorOrg = texture(tex0, uv).rgb;
|
||||
vec3 vHSV = RGBtoHSV(colorOrg.r,colorOrg.g,colorOrg.b);
|
||||
|
||||
// hue limiting
|
||||
if (colors == 0.0) {
|
||||
vHSV.y = 0.0;
|
||||
} else {
|
||||
float hue_divider = (360.0/colors);
|
||||
vHSV.x = round(vHSV.x/hue_divider)*hue_divider;
|
||||
|
||||
float sat_divider = 100.0/sat_levels;
|
||||
vHSV.y = round((vHSV.y*100.0)/sat_divider)*sat_divider/100.0;
|
||||
}
|
||||
|
||||
float bri_divider = 100.0/bri_levels;
|
||||
vHSV.z = round((vHSV.z*100.0)/bri_divider)*bri_divider/100.0;
|
||||
|
||||
float edg = IsEdge(uv);
|
||||
vec3 vRGB = (edg >= (1.0-((edge_thres-1.0)*0.01)))? vec3(0.0,0.0,0.0):HSVtoRGB(vHSV.x,vHSV.y,vHSV.z);
|
||||
tc = vec4(vRGB.x,vRGB.y,vRGB.z, 1);
|
||||
FragColor = tc;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Toonify" category="Stylize">
|
||||
<row name="Colors">
|
||||
<field type="double" min="0" default="12" max="360" id="colors"/>
|
||||
</row>
|
||||
<row name="Saturation Levels">
|
||||
<field type="double" min="0" default="4" id="sat_levels"/>
|
||||
</row>
|
||||
<row name="Brightness Levels">
|
||||
<field type="double" min="0" default="4" id="bri_levels"/>
|
||||
</row>
|
||||
<row name="Edge Tolerance">
|
||||
<field type="double" default="20" id="edge_thres"/>
|
||||
</row>
|
||||
<row name="Edge Strength">
|
||||
<field type="double" default="5" id="edge_thres2"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="toonify.frag"/>
|
||||
</effect>
|
||||
@@ -0,0 +1,15 @@
|
||||
uniform float amount;
|
||||
|
||||
uniform vec2 resolution; // screen resolution
|
||||
|
||||
vec4 process(vec4 col) {
|
||||
float alpha = texture2D(texture, v_texcoord)[3];
|
||||
|
||||
vec3 p = gl_FragCoord.xyz/vec3(resolution, 1.0)-.5;
|
||||
vec4 color = texture2D(texture,.5+(p.xy*=.992));
|
||||
vec3 o = color.rgb;
|
||||
for (float i=0.;i<amount;i++) {
|
||||
p.z += pow(max(0.,.5-length(color.rg)),2.)*exp(-i*.08);
|
||||
}
|
||||
return vec4(o*o+p.z, alpha);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<effect name="Volumetric Light" category="Stylize">
|
||||
<row name="Amount">
|
||||
<field type="double" min="0" default="100" id="amount"/>
|
||||
</row>
|
||||
<shader vert="common.vert" frag="volumetriclight.frag"/>
|
||||
</effect>
|
||||
Reference in New Issue
Block a user