Author Topic: [FF7PC-98] A few shaders I've found work over the years.  (Read 2342 times)

Mako

  • Freak
  • *
  • Posts: 660
  • Karma: 8
    • View Profile
First is the AA Color shader released by Guestr. There are a few options for customizing for performance and saturation, brightness, contrast. This has been tweaked for my specific needs.

Code: [Select]
const vec3 c_ch = vec3(1.0,1.0,1.0);  //  rgb color channel intensity
const float   a = 1.50 ;              //  saturation
const float   b = 1.00 ;              //  brightness
const float   c = 1.30 ;              //  contrast   

// you can use contrast1,contrast2...contrast4 (or contrast0 for speedup)

float contrast0(float x)
{ return x; }

float contrast1(float x)
{ x = x*1.1547-1.0;
  return sign(x)*pow(abs(x),1.0/c)*0.86 +  0.86;}

float contrast2(float x)
{ return normalize(vec2(pow(x,c),pow(0.86,c))).x*1.72;}

float contrast3(float x)
{ return 1.73*pow(0.57735*x,c); }

float contrast4(float x)
{ return clamp(0.866 + c*(x-0.866),0.05, 1.73); }

uniform sampler2D OGL2Texture;
void main()
{
vec3 c10 = texture2D(OGL2Texture, gl_TexCoord[1].xy).xyz;
vec3 c01 = texture2D(OGL2Texture, gl_TexCoord[4].xy).xyz;
vec3 c11 = texture2D(OGL2Texture, gl_TexCoord[0].xy).xyz;
vec3 c21 = texture2D(OGL2Texture, gl_TexCoord[5].xy).xyz;
vec3 c12 = texture2D(OGL2Texture, gl_TexCoord[2].xy).xyz;

vec3 dt = vec3(1.0,1.0,1.0);
float k1=dot(abs(c01-c21),dt);
float k2=dot(abs(c10-c12),dt);

vec3 color = (k1*(c10+c12)+k2*(c01+c21)+0.001*c11)/(2.0*(k1+k2)+0.001);

float x = sqrt(dot(color,color));

color.r = pow(color.r+0.001,a);
color.g = pow(color.g+0.001,a);
color.b = pow(color.b+0.001,a);

gl_FragColor.xyz = contrast4(x)*normalize(color*c_ch)*b;
}

The other is a shader created by Kauto. Adjust the line commented to increase/decrease the result, I don't prefer this one it makes everything look like an oil painting. But what the heck someone might use it...

Code: [Select]
uniform sampler2D tex00;
uniform float width;
uniform float height;

#define s2(a, b) temp = a; a = min(a, b); b = max(temp, b);
#define mn3(a, b, c) s2(a, b); s2(a, c);
#define mx3(a, b, c) s2(b, c); s2(a, c);

#define mnmx3(a, b, c) mx3(a, b, c); s2(a, b);                                   // 3 exchanges
#define mnmx4(a, b, c, d) s2(a, b); s2(c, d); s2(a, c); s2(b, d);                   // 4 exchanges
#define mnmx5(a, b, c, d, e) s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e);           // 6 exchanges
#define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f); // 7 exchanges

vec4 xlat_main( in vec2 tex ) {
   
    // Calculating texel coordinates
    float w = 540.0; //Set this value to a lower amount increase effect.
    float h = 540.0; //Set this value to a lower amount increase effect.

//    vec2 p0     = vec2(1.0/width,1.0/height);
    vec2 p1     = vec2(1.0/w,1.0/h);
vec2 p0     = p1*0.6;

vec4 v[9];

//MEDIAN-Filter to round edges

// Add the pixels which make up our window to the pixel array.
for(int dX = -1; dX <= 1; ++dX) {
for(int dY = -1; dY <= 1; ++dY) {
  vec2 offset = vec2(float(dX), float(dY));
   
  // If a pixel in the window is located at (x+dX, y+dY), put it at index (dX + R)(2R + 1) + (dY + R) of the
  // pixel array. This will fill the pixel array, with the top left pixel of the window at pixel[0] and the
  // bottom right pixel of the window at pixel[N-1].
  v[(dX + 1) * 3 + (dY + 1)] = texture2D(tex00, tex + offset * p0);
}
}

vec4 temp;

// Starting with a subset of size 6, remove the min and max each time
mnmx6(v[0], v[1], v[2], v[3], v[4], v[5]);
mnmx5(v[1], v[2], v[3], v[4], v[6]);
mnmx4(v[2], v[3], v[4], v[7]);
mnmx3(v[3], v[4], v[8]);
return v[4];
}

void main() {
    gl_FragData[0] = xlat_main(gl_TexCoord[0].xy).rgba;
}

Copy ether into a notepad and save them as a .post file. Then place them into your shader directory and tell your driver where to find them. Don't forget to enable. ;)
« Last Edit: 2016-02-25 11:43:23 by Mako »

ProtomanZxAdvent

  • Insane poster
  • *
  • Posts: 273
  • Karma: 7
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #1 on: 2016-02-25 23:28:37 »
been wanting filter like this http://forums.ppsspp.org/showthread.php?tid=6594&pid=109617#pid109617
his preset 2 would look great for my taste but don't know how to replicate it for [FF7-PC 98]

Kaldarasha

  • No life
  • *
  • Posts: 1992
  • Karma: 118
  • Prince of Model Editing
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #2 on: 2016-02-26 04:26:44 »
Can you convert these shaders for ff7? http://forums.qhimm.com/index.php?topic=16789.msg237730#msg237730
I had talked with the creator of the shaders but he was unable to port them to ff7 because he is limited to the rerelease which have no post shader support.

Mako

  • Freak
  • *
  • Posts: 660
  • Karma: 8
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #3 on: 2016-02-26 15:47:58 »
Can you convert these shaders for ff7? http://forums.qhimm.com/index.php?topic=16789.msg237730#msg237730
I had talked with the creator of the shaders but he was unable to port them to ff7 because he is limited to the rerelease which have no post shader support.

Can't he convert? It's a one time installer...

Sadly my knowledge of OpenGL shaders is rather limited, and what little I do know the driver doesn't seem to like or is depreciated in the spec of newer OpenGL releases. =/

ARB_framebuffer_object doesn't seem to be supported by the driver but is supported by the spec. Without the use of gl_TexCoord (depreciated) I have no way to tell the xBRZ filter to work on the backgrounds. It does run and seemingly works on the 3D (that doesn't need it) I suspect it's just a matter of telling the shader where to filter.

I'm a amateur at best with OpenGL spec.

Kaldarasha

  • No life
  • *
  • Posts: 1992
  • Karma: 118
  • Prince of Model Editing
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #4 on: 2016-02-26 16:04:24 »
Let's say that the converter will probably fail on his installment.

He has replaced the shader of the re-release but thanks to the tiled backgrounds it didn't work well. He has given me a link to the person who does the port of the psx shaders for reshade. This would be a good solution for ff8 as well, but I haven't the motivation to going in contact with another person trough a new forum where I have to register me first.

Mako

  • Freak
  • *
  • Posts: 660
  • Karma: 8
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #5 on: 2016-02-26 17:44:04 »
Can't seem to find the right mix... Ether I filter the text and videos to much to get the backgrounds not jaggy or not enough filter at all. Here's what I got so far

Code: [Select]
uniform sampler2D tex00;
uniform float width;
uniform float height;
uniform sampler2D bgl_DepthTexture;
uniform sampler2D bgl_RenderedTexture;
uniform sampler2D LuminanceTexture;

uniform float displayWidth;
uniform float displayHeight;
uniform float aspectRatio;
uniform float near;
uniform float far;

uniform sampler2D tex0;
uniform vec4 OGL2Size;
uniform vec4 OGL2InvSize;


#define XBR_RES     2.0                               
#define TEX_SIZEX (512.0*XBR_RES)
#define TEX_SIZEY   (512.0*XBR_RES)
#define SHA_LEVEL   3.0

const   float XBR_SCALE     = 2.0;
const   float coef          = 2.0;
const   vec3  rgbw          = vec3(14.352, 28.176, 5.472);
const   vec4  eq_threshold  = vec4(5.0, 5.0, 5.0, 5.0);
const   vec2 OGLSize    = vec2( TEX_SIZEX, TEX_SIZEY );
const   vec2 OGLInvSize = vec2( XBR_RES/TEX_SIZEX, XBR_RES/TEX_SIZEY);
const   vec2 dx         = vec2( XBR_RES/TEX_SIZEX, 0.0);
const   vec2 dy         = vec2( 0.0, XBR_RES/TEX_SIZEY );
const   vec2 x2         = 2.0*dx;
const   vec2 y2         = 2.0*dy;
const   vec2 hdx        = 0.5*dx;
const   vec2 hdy        = 0.5*dy;
const   vec4 xy         = vec4( XBR_RES/TEX_SIZEX, XBR_RES/TEX_SIZEY, -XBR_RES/TEX_SIZEX, -XBR_RES/TEX_SIZEY ); 
const   vec4 zw         = 2.0*xy; 
const   vec4 wz         = vec4( XBR_RES/TEX_SIZEX, 2.0*XBR_RES/TEX_SIZEY, -XBR_RES/TEX_SIZEX, -2.0*XBR_RES/TEX_SIZEY ); 


vec4 noteq(vec4 A, vec4 B)
{
return vec4(notEqual(A, B));
}

vec4 not(vec4 A)
{
return vec4(1.0)-A;
}

vec4 df(vec4 A, vec4 B)
{
    return abs(A-B);
}

vec4 eq(vec4 A, vec4 B)
{
return vec4(lessThan(df(A, B),eq_threshold));
}


vec4 weighted_distance(vec4 a, vec4 b, vec4 c, vec4 d, vec4 e, vec4 f, vec4 g, vec4 h)
{
    return (df(a,b) + df(a,c) + df(d,e) + df(d,f) + 4.0*df(g,h));
}


float c_df(vec3 c1, vec3 c2) {
                        vec3 df = abs(c1 - c2);
                        return df.r + df.g + df.b;
                }


uniform sampler2D OGL2Texture;

void main()
{
    vec4 edr, edr_left, edr_up;                     // px = pixel, edr = edge detection rule
    vec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
    vec4 nc30, nc60, nc45;                          // new_color
    vec4 fx, fx_left, fx_up, final_fx;              // inequations of straight lines.
    vec3 res1, res2, pix1, pix2;
    bvec4 nc, px;
    float blend1, blend2;

    vec4 delta  = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE);
    vec4 deltaL = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE);
    vec4 deltaU = deltaL.yxwz;


    vec2 fp  = fract(gl_TexCoord[0].xy*OGLSize);
    vec2 TexCoord_0 = gl_TexCoord[0].xy-fp*OGLInvSize + 0.5*OGLInvSize;

    vec3 A  = texture2D(OGL2Texture, TexCoord_0 + xy.zw ).xyz;
    vec3 B  = texture2D(OGL2Texture, TexCoord_0     -dy ).xyz;
    vec3 C  = texture2D(OGL2Texture, TexCoord_0 + xy.xw ).xyz;
    vec3 D  = texture2D(OGL2Texture, TexCoord_0 - dx    ).xyz;
    vec3 E  = texture2D(OGL2Texture, TexCoord_0         ).xyz;
    vec3 F  = texture2D(OGL2Texture, TexCoord_0 + dx    ).xyz;
    vec3 G  = texture2D(OGL2Texture, TexCoord_0 + xy.zy ).xyz;
    vec3 H  = texture2D(OGL2Texture, TexCoord_0     +dy ).xyz;
    vec3 I  = texture2D(OGL2Texture, TexCoord_0 + xy.xy ).xyz;
    vec3 A1 = texture2D(OGL2Texture, TexCoord_0 + wz.zw ).xyz;
    vec3 C1 = texture2D(OGL2Texture, TexCoord_0 + wz.xw ).xyz;
    vec3 A0 = texture2D(OGL2Texture, TexCoord_0 + zw.zw ).xyz;
    vec3 G0 = texture2D(OGL2Texture, TexCoord_0 + zw.zy ).xyz;
    vec3 C4 = texture2D(OGL2Texture, TexCoord_0 + zw.xw ).xyz;
    vec3 I4 = texture2D(OGL2Texture, TexCoord_0 + zw.xy ).xyz;
    vec3 G5 = texture2D(OGL2Texture, TexCoord_0 + wz.zy ).xyz;
    vec3 I5 = texture2D(OGL2Texture, TexCoord_0 + wz.xy ).xyz;
    vec3 B1 = texture2D(OGL2Texture, TexCoord_0 - y2    ).xyz;
    vec3 D0 = texture2D(OGL2Texture, TexCoord_0 - x2    ).xyz;
    vec3 H5 = texture2D(OGL2Texture, TexCoord_0 + y2    ).xyz;
    vec3 F4 = texture2D(OGL2Texture, TexCoord_0 + x2    ).xyz;

    vec4 b  = vec4(dot(B ,rgbw), dot(D ,rgbw), dot(H ,rgbw), dot(F ,rgbw));
    vec4 c  = vec4(dot(C ,rgbw), dot(A ,rgbw), dot(G ,rgbw), dot(I ,rgbw));
    vec4 d  = b.yzwx;
    vec4 e  = vec4(dot(E,rgbw));
    vec4 f  = b.wxyz;
    vec4 g  = c.zwxy;
    vec4 h  = b.zwxy;
    vec4 i  = c.wxyz;
    vec4 i4 = vec4(dot(I4,rgbw), dot(C1,rgbw), dot(A0,rgbw), dot(G5,rgbw));
    vec4 i5 = vec4(dot(I5,rgbw), dot(C4,rgbw), dot(A1,rgbw), dot(G0,rgbw));
    vec4 h5 = vec4(dot(H5,rgbw), dot(F4,rgbw), dot(B1,rgbw), dot(D0,rgbw));
    vec4 f4 = h5.yzwx;
    vec4 c1 = i4.yzwx;
    vec4 g0 = i5.wxyz;
   
    vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bo = vec4( 1.0,  1.0, -1.0,-1.0 );
    vec4 Co = vec4( 1.5,  0.5, -0.5, 0.5 );
    vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 Bx = vec4( 0.5,  2.0, -0.5,-2.0 );
    vec4 Cx = vec4( 1.0,  1.0, -0.5, 0.0 );
    vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
    vec4 By = vec4( 2.0,  0.5, -2.0,-0.5 );
    vec4 Cy = vec4( 2.0,  0.0, -1.0, 0.5 );
   
// These inequations define the line below which interpolation occurs.

    fx      = (Ao*fp.y+Bo*fp.x);

    fx_left = (Ax*fp.y+Bx*fp.x);

    fx_up   = (Ay*fp.y+By*fp.x);

    if (SHA_LEVEL == 0.0)
    {    interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h));}

    if (SHA_LEVEL == 1.0)
    {    interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c)));}

    if (SHA_LEVEL == 2.0)
    {    interp_restriction_lv1 = sign(noteq(e,f)*noteq(e,h)*(not(eq(f,b))* not(eq(h,d)) + eq(e,i) * not(eq(f,i4)) * not(eq(h,i5)) + eq(e,g) + eq(e,c) )  * (noteq(f,f4)* noteq(f,i) + noteq(h,h5) * noteq(h,i) + noteq(h,g) + noteq(f,c) + eq(b,c1) * eq(d,g0)));}

    if (SHA_LEVEL == 3.0)
    {    interp_restriction_lv1 = sign(noteq(e,f) * noteq(e,h) * ( not(eq(f,b)) * not(eq(f,c)) + not(eq(h,d)) * not(eq(h,g)) + eq(e,i) * (not(eq(f,f4)) * not(eq(f,i4)) + not(eq(h,h5)) * not(eq(h,i5))) + eq(e,g) + eq(e,c)) );}

    interp_restriction_lv2_left = vec4(notEqual(e,g))*vec4(notEqual(d,g));
    interp_restriction_lv2_up   = vec4(notEqual(e,c))*vec4(notEqual(b,c));

    vec4 fx45 = clamp((fx + delta -Co)/(2*delta ),0.0,1.0);
    vec4 fx30 = clamp((fx_left + deltaL -Cx)/(2*deltaL),0.0,1.0);
    vec4 fx60 = clamp((fx_up + deltaU -Cy)/(2*deltaU),0.0,1.0);

    edr      = vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*interp_restriction_lv1;
    edr_left = vec4(lessThanEqual(coef*df(f,g),df(h,c)))*interp_restriction_lv2_left*edr;
    edr_up   = vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*interp_restriction_lv2_up*edr;

    fx45 = edr*fx45;
    fx30 = edr_left*fx30;
    fx60 = edr_up*fx60;

    px = lessThanEqual(df(e,f),df(e,h));
    vec4 maximo = max(max(fx30, fx60), fx45);   

    mat4x3 pix = mat4x3(mix(E, mix(H, F, float(px.x)), maximo.x),
                        mix(E, mix(F, B, float(px.y)), maximo.y),
                        mix(E, mix(B, D, float(px.z)), maximo.z),
                        mix(E, mix(D, H, float(px.w)), maximo.w));

    vec4 pixel = vec4(dot(pix[0],rgbw),dot(pix[1],rgbw),dot(pix[2],rgbw),dot(pix[3],rgbw));

    vec4 diff = df(pixel,e);

    vec3 res = pix[0];
    float mx = diff.x;

    if (diff.y > mx) {res = pix[1]; mx = diff.y;}
    if (diff.z > mx) {res = pix[2]; mx = diff.z;}
    if (diff.w > mx) {res = pix[3];}

    gl_FragColor.xyz = res;
}

I'll keep working on it cause' I'm bored and gots nothing to do.

EDIT: Edited to actually work now.

Original:


5xBRZ
« Last Edit: 2016-02-26 19:55:00 by Mako »

Jahiliyyah

  • Fast newbie
  • *
  • Posts: 49
  • Karma: 7
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #6 on: 2016-03-01 22:49:35 »
Let's say that the converter will probably fail on his installment.

He has replaced the shader of the re-release but thanks to the tiled backgrounds it didn't work well. He has given me a link to the person who does the port of the psx shaders for reshade. This would be a good solution for ff8 as well, but I haven't the motivation to going in contact with another person trough a new forum where I have to register me first.

Oh, I didn't even consider Reshade.

http://reshade.me/compatibility
Final Fantasy VII    0.15.0    opengl32.dll    Good    No depth buffer access.
Final Fantasy VIII   0.15.0    opengl32.dll    Good    No depth buffer access.

So they haven't made much progress either it seems. Would it be easier to port a shader for the PSX version or one for the original OpenGL driver? Either way it sounds like you're close.

Jahiliyyah

  • Fast newbie
  • *
  • Posts: 49
  • Karma: 7
    • View Profile

DLPB

  • No life
  • *
  • Posts: 8229
  • Karma: 222
  • Shoot For Solar Value
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #8 on: 2016-06-07 20:09:41 »
To be honest, I think they look hideous.  Way too smoothed and turned it looking like plastic.  Lost all detail.

Sunwalker

  • Fast newbie
  • *
  • Posts: 26
  • Karma: 4
    • View Profile
Re: [FF7PC-98] A few shaders I've found work over the years.
« Reply #9 on: 2017-01-22 19:56:58 »
how to share my shader here?