First commit desu

This commit is contained in:
Marisa the Magician 2019-01-03 18:27:49 +01:00
commit 6834797f09
20 changed files with 1618 additions and 0 deletions

View file

@ -0,0 +1,15 @@
void main()
{
float gauss4[4] = { 0.270682, 0.216745, 0.111281, 0.036633 };
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec2 bresl = textureSize(InputTexture,0);
vec2 uv = ((coord-0.5)*vec2(1.0,bresl.y/bresl.x))*2.0;
float bfact = clamp(pow(dot(uv,uv),bblurpow)*bblurmul+bblurbump,0.0,1.0);
vec2 bof = (1.0/bresl)*bblurradius*bfact;
res.rgb *= 0;
int i,j;
for ( i=-3; i<4; i++ ) for ( j=-3; j<4; j++ )
res.rgb += gauss4[abs(i)]*gauss4[abs(j)]*texture(InputTexture,coord+vec2(i,j)*bof).rgb;
FragColor = res;
}

View file

@ -0,0 +1,24 @@
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec2 ofs[16] =
{
vec2(1.0,1.0), vec2(-1.0,-1.0),
vec2(-1.0,1.0), vec2(1.0,-1.0),
vec2(1.0,0.0), vec2(-1.0,0.0),
vec2(0.0,1.0), vec2(0.0,-1.0),
vec2(1.41,0.0), vec2(-1.41,0.0),
vec2(0.0,1.41), vec2(0.0,-1.41),
vec2(1.41,1.41), vec2(-1.41,-1.41),
vec2(-1.41,1.41), vec2(1.41,-1.41)
};
vec2 bresl = textureSize(InputTexture,0);
vec2 bof = (1.0/bresl)*bssblurradius;
for ( int i=0; i<16; i++ ) res.rgb += texture(InputTexture,coord+ofs[i]*bof).rgb;
res.rgb /= 17.0;
FragColor = res;
}

View file

@ -0,0 +1,24 @@
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec2 ofs[8] =
{
vec2(1.0,1.0), vec2(-1.0,-1.0),
vec2(-1.0,1.0), vec2(1.0,-1.0),
vec2(1.41,1.41), vec2(-1.41,-1.41),
vec2(-1.41,1.41), vec2(1.41,-1.41)
};
vec2 bresl = textureSize(InputTexture,0);
vec2 bof = (1.0/bresl)*bsssharpradius;
vec4 tcol = res;
int i;
for ( i=0; i<8; i++ ) tcol += texture(InputTexture,coord+ofs[i]*bof);
tcol /= 9.0;
vec4 orig = res;
res = orig*(1.0+dot(orig.rgb-tcol.rgb,vec3(0.333333))*bsssharpamount);
float rg = clamp(pow(orig.b,3.0),0.0,1.0);
res = mix(res,orig,rg);
FragColor = res;
}

View file

@ -0,0 +1,11 @@
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec2 bresl = textureSize(InputTexture,0);
vec2 bof = (1.0/bresl)*bssshiftradius;
res.g = texture(InputTexture,coord).g;
res.r = texture(InputTexture,coord+vec2(0,-bof.y)).r;
res.b = texture(InputTexture,coord+vec2(0,bof.y)).b;
FragColor = res;
}

View file

@ -0,0 +1,10 @@
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
mat3 cmat = mat3(redrow,greenrow,bluerow);
float cmatscale = (redrow.r+redrow.g+redrow.b+greenrow.r+greenrow.g+greenrow.b+bluerow.r+bluerow.g+bluerow.b)/3.0;
res.rgb *= cmat;
res.rgb /= cmatscale;
FragColor = res;
}

16
shaders/glsl/mfx_dirt.fp Normal file
View file

@ -0,0 +1,16 @@
vec3 lensdirt( in vec3 res, in vec2 coord )
{
vec2 nr = textureSize(InputTexture,0)/textureSize(NoiseTexture,0);
vec3 ncolc = texture(NoiseTexture,coord*dirtmc*nr).rgb;
vec2 ds = vec2(res.r+res.g,res.g+res.b)/2.0;
res = mix(res,(ncolc.r+1.0)*res,dirtcfactor*clamp(1.0-(ds.x+ds.y)*0.25,0.0,1.0));
return res;
}
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
res.rgb = lensdirt(res.rgb,coord);
FragColor = res;
}

View file

@ -0,0 +1,32 @@
/* math color grading from MariFX */
#define luminance(x) dot(x,vec3(0.2126,0.7152,0.0722))
vec3 rgb2hsv( vec3 c )
{
vec4 K = vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);
vec4 p = (c.g<c.b)?vec4(c.bg,K.wz):vec4(c.gb,K.xy);
vec4 q = (c.r<p.x)?vec4(p.xyw,c.r):vec4(c.r,p.yzx);
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);
}
void main()
{
vec4 res = texture(InputTexture,TexCoord);
res.rgb = pow(max(res.rgb,0.0),gradepow)*grademul;
float tonev = luminance(res.rgb);
vec3 tonecolor = gradecol*tonev;
res.rgb = res.rgb*(1.0-gradecolfact)+tonecolor*gradecolfact;
vec3 hsv = rgb2hsv(res.rgb);
hsv.y = clamp(pow(max(hsv.y,0.0),gradesatpow)*gradesatmul,0.0,1.0);
hsv.z = pow(max(hsv.z,0.0),gradevalpow)*gradevalmul;
res.rgb = hsv2rgb(hsv);
FragColor = res;
}

51
shaders/glsl/mfx_grain.fp Normal file
View file

@ -0,0 +1,51 @@
/*
Complex grain shader ported over from MariENB
(C)2012-2018 Marisa Kirisame
*/
const float nf = 0.000005;
const vec3 nm1 = vec3(2.05,3.11,2.22);
const float nk = 0.04;
const vec3 nm2 = vec3(4.25,9.42,6.29);
const float ns = -0.08;
const float np = 3.95;
const float bnp = 1.7;
#define darkmask(a,b) (a>0.5)?(2.0*a*(0.5+b)):(1.0-2.0*(1.0-a)*(1.0-((0.5+b))))
vec3 grain( in vec3 res, in vec2 coord )
{
float ts = Timer*nf;
vec2 s1 = coord+vec2(0.0,ts);
vec2 s2 = coord+vec2(ts,0.0);
vec2 s3 = coord+vec2(ts,ts);
float n1, n2, n3;
vec2 nr = textureSize(NoiseTexture,0);
n1 = texture(NoiseTexture,s1*nm1.x*nr).r;
n2 = texture(NoiseTexture,s2*nm1.y*nr).g;
n3 = texture(NoiseTexture,s3*nm1.z*nr).b;
s1 = coord+vec2(ts+n1*nk,n2*nk);
s2 = coord+vec2(n2,ts+n3*nk);
s3 = coord+vec2(ts+n3*nk,ts+n1*nk);
n1 = texture(NoiseTexture,s1*nm2.x*nr).r;
n2 = texture(NoiseTexture,s2*nm2.y*nr).g;
n3 = texture(NoiseTexture,s3*nm2.z*nr).b;
float n4 = (n1+n2+n3)/3.0;
vec3 ng = vec3(n4);
vec3 nc = vec3(n1,n2,n3);
vec3 nt = pow(clamp(mix(ng,nc,ns),0.0,1.0),vec3(np));
float bn = 1.0-clamp((res.r+res.g+res.b)/3.0,0.0,1.0);
bn = pow(bn,bnp);
vec3 nn = clamp(nt*bn,vec3(0.0),vec3(1.0));
res.r = darkmask(res.r,(nn.r*ni));
res.g = darkmask(res.g,(nn.g*ni));
res.b = darkmask(res.b,(nn.b*ni));
return res;
}
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
res.rgb = grain(res.rgb,coord);
FragColor = res;
}

View file

@ -0,0 +1,90 @@
vec3 rgb2hsv( vec3 c )
{
vec4 K = vec4(0.0,-1.0/3.0,2.0/3.0,-1.0);
vec4 p = (c.g<c.b)?vec4(c.bg,K.wz):vec4(c.gb,K.xy);
vec4 q = (c.r<p.x)?vec4(p.xyw,c.r):vec4(c.r,p.yzx);
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);
}
float hs_hue_overlap( float hue_p, float hue_s, float res )
{
float v = hue_p+hue_s;
res += (hshue_a+v)/2.0;
return mod(res,1.0);
}
float hs_hue( float hue, float res )
{
res += (hshue_a+hue)/2.0;
return mod(res,1.0);
}
float hs_sat( float sat, float res )
{
float v = hssat_a+sat;
res *= v+1.0;
return clamp(res,0.0,1.0);
}
float hs_val( float val, float res )
{
float v = (hsval_a+val)/2.0;
if ( v < 0.0 ) return res*(v+1.0);
return res+(v*(1.0-res));
}
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec3 hsv = rgb2hsv(res.rgb);
float ch = hsv.x*6.0;
int ph = 0, sh = 0;
float pv = 0.0, sv = 0.0;
bool usesh = false;
float hues[6] = {hshue_r,hshue_y,hshue_g,hshue_c,hshue_b,hshue_m};
float sats[6] = {hssat_r,hssat_y,hssat_g,hssat_c,hssat_b,hssat_m};
float vals[6] = {hsval_r,hsval_y,hsval_g,hsval_c,hsval_b,hsval_m};
float v;
for ( float h=0.0; h<7.0; h+=1.0 )
{
float ht = h+0.5;
if ( ch < ht+hsover )
{
ph = int(floor(h));
if ( (hsover > 0.0) && (ch > ht-hsover) )
{
usesh = true;
sh = ph+1;
sv = (ch-ht+hsover)/(2.0*hsover);
pv = 1.0-sv;
}
else usesh = false;
break;
}
}
if ( ph >= 6 )
{
ph = 0;
usesh = false;
}
if ( sh >= 6 ) sh = 0;
if ( usesh )
{
hsv.x = hs_hue_overlap(hues[ph]*pv,hues[sh]*sv,hsv.x);
hsv.y = hs_sat(sats[ph],hsv.y)*pv+hs_sat(sats[sh],hsv.y)*sv;
hsv.z = hs_val(vals[ph],hsv.z)*pv+hs_val(vals[sh],hsv.z)*sv;
}
else
{
hsv.x = hs_hue(hues[ph],hsv.x);
hsv.y = hs_sat(sats[ph],hsv.y);
hsv.z = hs_val(vals[ph],hsv.z);
}
res.rgb = hsv2rgb(hsv);
FragColor = res;
}

View file

@ -0,0 +1,11 @@
void main()
{
vec2 coord = TexCoord;
vec4 res = texture(InputTexture,coord);
vec2 bresl = textureSize(InputTexture,0);
vec2 uv = ((coord-0.5)*vec2(1.0,bresl.y/bresl.x))*2.0;
vec4 vigdata = vec4(vigcolor,clamp(pow(dot(uv,uv),vigpow)*vigmul+vigbump,0.0,1.0));
vec3 outcol = clamp(res.rgb+vigdata.rgb,0.0,1.0);
res.rgb = mix(res.rgb,outcol,vigdata.a);
FragColor = res;
}