Update : PSP
This commit is contained in:
@@ -1,77 +1,77 @@
|
||||
// 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// License: GNU-GPL
|
||||
|
||||
// Shader notes: looks better with sprite games
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
const float mx = 0.325; // start smoothing factor
|
||||
const float k = -0.250; // smoothing decrease factor
|
||||
const float max_w = 0.25; // max. smoothing weigth
|
||||
const float min_w =-0.05; // min smoothing/sharpening weigth
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 i1 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 i2 = texture2D(sampler0, v_texcoord2.xy).xyz;
|
||||
vec3 i3 = texture2D(sampler0, v_texcoord3.xy).xyz;
|
||||
vec3 i4 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 o1 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 o3 = texture2D(sampler0, v_texcoord6.xy).xyz;
|
||||
vec3 o2 = texture2D(sampler0, v_texcoord5.zw).xyz;
|
||||
vec3 o4 = texture2D(sampler0, v_texcoord6.zw).xyz;
|
||||
|
||||
vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
float ko1=dot(abs(o1-c),dt);
|
||||
float ko2=dot(abs(o2-c),dt);
|
||||
float ko3=dot(abs(o3-c),dt);
|
||||
float ko4=dot(abs(o4-c),dt);
|
||||
|
||||
float sd1 = dot(abs(i1-i3),dt);
|
||||
float sd2 = dot(abs(i2-i4),dt);
|
||||
|
||||
float w1 = step(ko1,ko3)*sd2;
|
||||
float w2 = step(ko2,ko4)*sd1;
|
||||
float w3 = step(ko3,ko1)*sd2;
|
||||
float w4 = step(ko4,ko2)*sd1;
|
||||
|
||||
c = (w1*o1+w2*o2+w3*o3+w4*o4+0.1*c)/(w1+w2+w3+w4+0.1);
|
||||
|
||||
float lc = c.r+c.g+c.b+0.2;
|
||||
|
||||
w1 = (i1.r+i1.g+i1.b+lc)*0.2;
|
||||
w1 = clamp(k*dot(abs(c-i1),dt)/w1+mx,min_w,max_w);
|
||||
|
||||
w2 = (i2.r+i2.g+i2.b+lc)*0.2;
|
||||
w2 = clamp(k*dot(abs(c-i2),dt)/w2+mx,min_w,max_w);
|
||||
|
||||
w3 = (i3.r+i3.g+i3.b+lc)*0.2;
|
||||
w3 = clamp(k*dot(abs(c-i3),dt)/w3+mx,min_w,max_w);
|
||||
|
||||
w4 = (i4.r+i4.g+i4.b+lc)*0.2;
|
||||
w4 = clamp(k*dot(abs(c-i4),dt)/w4+mx,min_w,max_w);
|
||||
|
||||
gl_FragColor.rgb = w1*i1 + w2*i2 + w3*i3 + w4*i4 + (1.0-w1-w2-w3-w4)*c;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 4xGLSL HqFilter shader, Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// License: GNU-GPL
|
||||
|
||||
// Shader notes: looks better with sprite games
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
const float mx = 0.325; // start smoothing factor
|
||||
const float k = -0.250; // smoothing decrease factor
|
||||
const float max_w = 0.25; // max. smoothing weigth
|
||||
const float min_w =-0.05; // min smoothing/sharpening weigth
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 i1 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 i2 = texture2D(sampler0, v_texcoord2.xy).xyz;
|
||||
vec3 i3 = texture2D(sampler0, v_texcoord3.xy).xyz;
|
||||
vec3 i4 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 o1 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 o3 = texture2D(sampler0, v_texcoord6.xy).xyz;
|
||||
vec3 o2 = texture2D(sampler0, v_texcoord5.zw).xyz;
|
||||
vec3 o4 = texture2D(sampler0, v_texcoord6.zw).xyz;
|
||||
|
||||
vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
float ko1=dot(abs(o1-c),dt);
|
||||
float ko2=dot(abs(o2-c),dt);
|
||||
float ko3=dot(abs(o3-c),dt);
|
||||
float ko4=dot(abs(o4-c),dt);
|
||||
|
||||
float sd1 = dot(abs(i1-i3),dt);
|
||||
float sd2 = dot(abs(i2-i4),dt);
|
||||
|
||||
float w1 = step(ko1,ko3)*sd2;
|
||||
float w2 = step(ko2,ko4)*sd1;
|
||||
float w3 = step(ko3,ko1)*sd2;
|
||||
float w4 = step(ko4,ko2)*sd1;
|
||||
|
||||
c = (w1*o1+w2*o2+w3*o3+w4*o4+0.1*c)/(w1+w2+w3+w4+0.1);
|
||||
|
||||
float lc = c.r+c.g+c.b+0.2;
|
||||
|
||||
w1 = (i1.r+i1.g+i1.b+lc)*0.2;
|
||||
w1 = clamp(k*dot(abs(c-i1),dt)/w1+mx,min_w,max_w);
|
||||
|
||||
w2 = (i2.r+i2.g+i2.b+lc)*0.2;
|
||||
w2 = clamp(k*dot(abs(c-i2),dt)/w2+mx,min_w,max_w);
|
||||
|
||||
w3 = (i3.r+i3.g+i3.b+lc)*0.2;
|
||||
w3 = clamp(k*dot(abs(c-i3),dt)/w3+mx,min_w,max_w);
|
||||
|
||||
w4 = (i4.r+i4.g+i4.b+lc)*0.2;
|
||||
w4 = clamp(k*dot(abs(c-i4),dt)/w4+mx,min_w,max_w);
|
||||
|
||||
gl_FragColor.rgb = w1*i1 + w2*i2 + w3*i3 + w4*i4 + (1.0-w1-w2-w3-w4)*c;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +1,37 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = u_pixelDelta.x*((u_texelDelta.x/u_pixelDelta.x)/2.0);
|
||||
float y = u_pixelDelta.y*((u_texelDelta.y/u_pixelDelta.y)/2.0);
|
||||
vec2 dg1 = vec2( x,y);
|
||||
vec2 dg2 = vec2(-x,y);
|
||||
vec2 sd1 = dg1*0.5;
|
||||
vec2 sd2 = dg2*0.5;
|
||||
gl_Position = a_position;
|
||||
v_texcoord0=a_texcoord0.xyxy;
|
||||
v_texcoord1.xy = v_texcoord0.xy - sd1;
|
||||
v_texcoord2.xy = v_texcoord0.xy - sd2;
|
||||
v_texcoord3.xy = v_texcoord0.xy + sd1;
|
||||
v_texcoord4.xy = v_texcoord0.xy + sd2;
|
||||
v_texcoord5.xy = v_texcoord0.xy - dg1;
|
||||
v_texcoord6.xy = v_texcoord0.xy + dg1;
|
||||
v_texcoord5.zw = v_texcoord0.xy - dg2;
|
||||
v_texcoord6.zw = v_texcoord0.xy + dg2;
|
||||
}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = u_pixelDelta.x*((u_texelDelta.x/u_pixelDelta.x)/2.0);
|
||||
float y = u_pixelDelta.y*((u_texelDelta.y/u_pixelDelta.y)/2.0);
|
||||
vec2 dg1 = vec2( x,y);
|
||||
vec2 dg2 = vec2(-x,y);
|
||||
vec2 sd1 = dg1*0.5;
|
||||
vec2 sd2 = dg2*0.5;
|
||||
gl_Position = a_position;
|
||||
v_texcoord0=a_texcoord0.xyxy;
|
||||
v_texcoord1.xy = v_texcoord0.xy - sd1;
|
||||
v_texcoord2.xy = v_texcoord0.xy - sd2;
|
||||
v_texcoord3.xy = v_texcoord0.xy + sd1;
|
||||
v_texcoord4.xy = v_texcoord0.xy + sd2;
|
||||
v_texcoord5.xy = v_texcoord0.xy - dg1;
|
||||
v_texcoord6.xy = v_texcoord0.xy + dg1;
|
||||
v_texcoord5.zw = v_texcoord0.xy - dg2;
|
||||
v_texcoord6.zw = v_texcoord0.xy + dg2;
|
||||
}
|
||||
|
||||
@@ -1,218 +1,218 @@
|
||||
/*
|
||||
Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r)
|
||||
|
||||
Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
|
||||
*/
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding
|
||||
#define CornerB 0 //ON:1/OFF:0 / activate only one
|
||||
#define CornerD 0 //ON:1/OFF:0
|
||||
// CornerC //used as default if none of the above is defined
|
||||
|
||||
const float XBR_SCALE = 3.0;
|
||||
const float lv2_cf = 2.0;
|
||||
|
||||
const float coef = 2.0;
|
||||
const vec3 rgbw = vec3(14.352, 28.176, 5.472);
|
||||
const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
|
||||
|
||||
const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
|
||||
const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
|
||||
const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
|
||||
const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
|
||||
const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
|
||||
const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
|
||||
const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
// Difference between vector components.
|
||||
vec4 df(vec4 A, vec4 B) {
|
||||
return vec4(abs(A-B));
|
||||
}
|
||||
|
||||
// Compare two vectors and return their components are different.
|
||||
vec4 diff(vec4 A, vec4 B) {
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
// Determine if two vector components are equal based on a threshold.
|
||||
vec4 eq(vec4 A, vec4 B) {
|
||||
return (step(df(A, B), eq_threshold));
|
||||
}
|
||||
|
||||
// Determine if two vector components are NOT equal based on a threshold.
|
||||
vec4 neq(vec4 A, vec4 B) {
|
||||
return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B));
|
||||
}
|
||||
|
||||
float c_df(vec3 c1, vec3 c2) {
|
||||
vec3 df = abs(c1 - c2);
|
||||
return df.r + df.g + df.b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
vec4 edri, edr, edr_l, edr_u, px; // px = pixel, edr = edge detection rule
|
||||
vec4 irlv0, irlv1, irlv2l, irlv2u;
|
||||
vec4 fx, fx_l, fx_u; // inequations of straight lines.
|
||||
|
||||
vec2 pS = 1.0 / u_texelDelta.xy;
|
||||
vec2 fp = fract(v_texcoord0.xy*pS.xy);
|
||||
vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy;
|
||||
vec2 dx = vec2(u_texelDelta.x,0.0);
|
||||
vec2 dy = vec2(0.0,u_texelDelta.y);
|
||||
vec2 y2 = dy + dy; vec2 x2 = dx + dx;
|
||||
|
||||
vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE);
|
||||
vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE);
|
||||
vec4 delta_u = delta_l.yxwz;
|
||||
|
||||
vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy ).xyz;
|
||||
vec3 B = texture2D(sampler0, TexCoord_0 -dy ).xyz;
|
||||
vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy ).xyz;
|
||||
vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz;
|
||||
vec3 E = texture2D(sampler0, TexCoord_0 ).xyz;
|
||||
vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz;
|
||||
vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy ).xyz;
|
||||
vec3 H = texture2D(sampler0, TexCoord_0 +dy ).xyz;
|
||||
vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy ).xyz;
|
||||
vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz;
|
||||
vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz;
|
||||
vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz;
|
||||
vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz;
|
||||
vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz;
|
||||
vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz;
|
||||
vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz;
|
||||
vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz;
|
||||
vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz;
|
||||
vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz;
|
||||
vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz;
|
||||
vec3 F4 = texture2D(sampler0, 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;
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
fx = (Ao*fp.y+Bo*fp.x);
|
||||
fx_l = (Ax*fp.y+Bx*fp.x);
|
||||
fx_u = (Ay*fp.y+By*fp.x);
|
||||
irlv1 = irlv0 = diff(e,f) * diff(e,h);
|
||||
#if(CornerA==0) // A takes priority skipping other corners
|
||||
#define SMOOTH_TIPS
|
||||
// Corner C also default if no other ones used
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) );
|
||||
int select1 = 0;
|
||||
#if(CornerB==1) // Corner B
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) );
|
||||
select1 = 1;
|
||||
#endif
|
||||
#if(CornerD==1) // Corner D
|
||||
if (select1==0) {
|
||||
vec4 c1 = i4.yzwx;
|
||||
vec4 g0 = i5.wxyz;
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0)));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
irlv2l = diff(e,g) * diff(d,g);
|
||||
irlv2u = diff(e,c) * diff(b,c);
|
||||
|
||||
vec4 fx45i = clamp((fx + delta -Co - Ci) / (2.0*delta ), 0.0, 1.0);
|
||||
vec4 fx45 = clamp((fx + delta -Co ) / (2.0*delta ), 0.0, 1.0);
|
||||
vec4 fx30 = clamp((fx_l + delta_l -Cx ) / (2.0*delta_l), 0.0, 1.0);
|
||||
vec4 fx60 = clamp((fx_u + delta_u -Cy ) / (2.0*delta_u), 0.0, 1.0);
|
||||
vec4 w1, w2;
|
||||
|
||||
w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw);
|
||||
w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw);
|
||||
w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw);
|
||||
w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw);
|
||||
w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw);
|
||||
w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw);
|
||||
w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw);
|
||||
w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw);
|
||||
|
||||
edri = step(w1, w2) * irlv0;
|
||||
edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1);
|
||||
|
||||
w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw);
|
||||
w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw);
|
||||
|
||||
edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr;
|
||||
edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr;
|
||||
|
||||
fx45 = edr * fx45;
|
||||
fx30 = edr_l * fx30;
|
||||
fx60 = edr_u * fx60;
|
||||
fx45i = edri * fx45i;
|
||||
|
||||
w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw);
|
||||
w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw);
|
||||
|
||||
px = step(w1, w2);
|
||||
#ifdef SMOOTH_TIPS
|
||||
vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
|
||||
#else
|
||||
vec4 maximos = max(max(fx30, fx60), fx45);
|
||||
#endif
|
||||
vec3 res1 = E;
|
||||
res1 = mix(res1, mix(H, F, px.x), maximos.x);
|
||||
res1 = mix(res1, mix(B, D, px.z), maximos.z);
|
||||
|
||||
vec3 res2 = E;
|
||||
res2 = mix(res2, mix(F, B, px.y), maximos.y);
|
||||
res2 = mix(res2, mix(D, H, px.w), maximos.w);
|
||||
|
||||
res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
|
||||
}
|
||||
gl_FragColor.xyz = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
/*
|
||||
Hyllian's xBR-lv2 Shader Accuracy (tweak by guest.r)
|
||||
|
||||
Copyright (C) 2011-2015 Hyllian - sergiogdb@gmail.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Incorporates some of the ideas from SABR shader. Thanks to Joshua Street.
|
||||
*/
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
#define CornerA 0 //ON:1/OFF:0 / A, B, C, D are just different variants of corner rounding
|
||||
#define CornerB 0 //ON:1/OFF:0 / activate only one
|
||||
#define CornerD 0 //ON:1/OFF:0
|
||||
// CornerC //used as default if none of the above is defined
|
||||
|
||||
const float XBR_SCALE = 3.0;
|
||||
const float lv2_cf = 2.0;
|
||||
|
||||
const float coef = 2.0;
|
||||
const vec3 rgbw = vec3(14.352, 28.176, 5.472);
|
||||
const vec4 eq_threshold = vec4(15.0, 15.0, 15.0, 15.0);
|
||||
|
||||
const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
|
||||
const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
|
||||
const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
|
||||
const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
|
||||
const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
|
||||
const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
|
||||
const vec4 Ci = vec4(0.25, 0.25, 0.25, 0.25);
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
// Difference between vector components.
|
||||
vec4 df(vec4 A, vec4 B) {
|
||||
return vec4(abs(A-B));
|
||||
}
|
||||
|
||||
// Compare two vectors and return their components are different.
|
||||
vec4 diff(vec4 A, vec4 B) {
|
||||
return vec4(notEqual(A, B));
|
||||
}
|
||||
|
||||
// Determine if two vector components are equal based on a threshold.
|
||||
vec4 eq(vec4 A, vec4 B) {
|
||||
return (step(df(A, B), eq_threshold));
|
||||
}
|
||||
|
||||
// Determine if two vector components are NOT equal based on a threshold.
|
||||
vec4 neq(vec4 A, vec4 B) {
|
||||
return (vec4(1.0, 1.0, 1.0, 1.0) - eq(A, B));
|
||||
}
|
||||
|
||||
float c_df(vec3 c1, vec3 c2) {
|
||||
vec3 df = abs(c1 - c2);
|
||||
return df.r + df.g + df.b;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
vec4 edri, edr, edr_l, edr_u, px; // px = pixel, edr = edge detection rule
|
||||
vec4 irlv0, irlv1, irlv2l, irlv2u;
|
||||
vec4 fx, fx_l, fx_u; // inequations of straight lines.
|
||||
|
||||
vec2 pS = 1.0 / u_texelDelta.xy;
|
||||
vec2 fp = fract(v_texcoord0.xy*pS.xy);
|
||||
vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy;
|
||||
vec2 dx = vec2(u_texelDelta.x,0.0);
|
||||
vec2 dy = vec2(0.0,u_texelDelta.y);
|
||||
vec2 y2 = dy + dy; vec2 x2 = dx + dx;
|
||||
|
||||
vec4 delta = vec4(1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE, 1.0/XBR_SCALE);
|
||||
vec4 delta_l = vec4(0.5/XBR_SCALE, 1.0/XBR_SCALE, 0.5/XBR_SCALE, 1.0/XBR_SCALE);
|
||||
vec4 delta_u = delta_l.yxwz;
|
||||
|
||||
vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy ).xyz;
|
||||
vec3 B = texture2D(sampler0, TexCoord_0 -dy ).xyz;
|
||||
vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy ).xyz;
|
||||
vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz;
|
||||
vec3 E = texture2D(sampler0, TexCoord_0 ).xyz;
|
||||
vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz;
|
||||
vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy ).xyz;
|
||||
vec3 H = texture2D(sampler0, TexCoord_0 +dy ).xyz;
|
||||
vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy ).xyz;
|
||||
vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz;
|
||||
vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz;
|
||||
vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz;
|
||||
vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz;
|
||||
vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz;
|
||||
vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz;
|
||||
vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz;
|
||||
vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz;
|
||||
vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz;
|
||||
vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz;
|
||||
vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz;
|
||||
vec3 F4 = texture2D(sampler0, 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;
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
fx = (Ao*fp.y+Bo*fp.x);
|
||||
fx_l = (Ax*fp.y+Bx*fp.x);
|
||||
fx_u = (Ay*fp.y+By*fp.x);
|
||||
irlv1 = irlv0 = diff(e,f) * diff(e,h);
|
||||
#if(CornerA==0) // A takes priority skipping other corners
|
||||
#define SMOOTH_TIPS
|
||||
// Corner C also default if no other ones used
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(f,c) + neq(h,d) * neq(h,g) + eq(e,i) * (neq(f,f4) * neq(f,i4) + neq(h,h5) * neq(h,i5)) + eq(e,g) + eq(e,c)) );
|
||||
int select1 = 0;
|
||||
#if(CornerB==1) // Corner B
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) );
|
||||
select1 = 1;
|
||||
#endif
|
||||
#if(CornerD==1) // Corner D
|
||||
if (select1==0) {
|
||||
vec4 c1 = i4.yzwx;
|
||||
vec4 g0 = i5.wxyz;
|
||||
irlv1 = (irlv0 * ( neq(f,b) * neq(h,d) + eq(e,i) * neq(f,i4) * neq(h,i5) + eq(e,g) + eq(e,c) ) * (diff(f,f4) * diff(f,i) + diff(h,h5) * diff(h,i) + diff(h,g) + diff(f,c) + eq(b,c1) * eq(d,g0)));
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
irlv2l = diff(e,g) * diff(d,g);
|
||||
irlv2u = diff(e,c) * diff(b,c);
|
||||
|
||||
vec4 fx45i = clamp((fx + delta -Co - Ci) / (2.0*delta ), 0.0, 1.0);
|
||||
vec4 fx45 = clamp((fx + delta -Co ) / (2.0*delta ), 0.0, 1.0);
|
||||
vec4 fx30 = clamp((fx_l + delta_l -Cx ) / (2.0*delta_l), 0.0, 1.0);
|
||||
vec4 fx60 = clamp((fx_u + delta_u -Cy ) / (2.0*delta_u), 0.0, 1.0);
|
||||
vec4 w1, w2;
|
||||
|
||||
w1.x = dot(abs(E-C),rgbw) + dot(abs(E-G),rgbw) + dot(abs(I-H5),rgbw) + dot(abs(I-F4),rgbw) + 4.0*dot(abs(H-F),rgbw);
|
||||
w1.y = dot(abs(E-A),rgbw) + dot(abs(E-I),rgbw) + dot(abs(C-F4),rgbw) + dot(abs(C-B1),rgbw) + 4.0*dot(abs(F-B),rgbw);
|
||||
w1.z = dot(abs(E-G),rgbw) + dot(abs(E-C),rgbw) + dot(abs(A-B1),rgbw) + dot(abs(A-D0),rgbw) + 4.0*dot(abs(B-D),rgbw);
|
||||
w1.w = dot(abs(E-I),rgbw) + dot(abs(E-A),rgbw) + dot(abs(G-D0),rgbw) + dot(abs(G-H5),rgbw) + 4.0*dot(abs(D-H),rgbw);
|
||||
w2.x = dot(abs(H-D),rgbw) + dot(abs(H-I5),rgbw) + dot(abs(F-I4),rgbw) + dot(abs(F-B),rgbw) + 4.0*dot(abs(E-I),rgbw);
|
||||
w2.y = dot(abs(F-H),rgbw) + dot(abs(F-C4),rgbw) + dot(abs(B-C1),rgbw) + dot(abs(B-D),rgbw) + 4.0*dot(abs(E-C),rgbw);
|
||||
w2.z = dot(abs(B-F),rgbw) + dot(abs(B-A1),rgbw) + dot(abs(D-A0),rgbw) + dot(abs(D-H),rgbw) + 4.0*dot(abs(E-A),rgbw);
|
||||
w2.w = dot(abs(D-B),rgbw) + dot(abs(D-G0),rgbw) + dot(abs(H-G5),rgbw) + dot(abs(H-F),rgbw) + 4.0*dot(abs(E-G),rgbw);
|
||||
|
||||
edri = step(w1, w2) * irlv0;
|
||||
edr = step(w1 + vec4(0.1, 0.1, 0.1, 0.1), w2) * step(vec4(0.5, 0.5, 0.5, 0.5), irlv1);
|
||||
|
||||
w1.x = dot(abs(F-G),rgbw); w1.y = dot(abs(B-I),rgbw); w1.z = dot(abs(D-C),rgbw); w1.w = dot(abs(H-A),rgbw);
|
||||
w2.x = dot(abs(H-C),rgbw); w2.y = dot(abs(F-A),rgbw); w2.z = dot(abs(B-G),rgbw); w2.w = dot(abs(D-I),rgbw);
|
||||
|
||||
edr_l = step( lv2_cf*w1, w2 ) * irlv2l * edr;
|
||||
edr_u = step( lv2_cf*w2, w1 ) * irlv2u * edr;
|
||||
|
||||
fx45 = edr * fx45;
|
||||
fx30 = edr_l * fx30;
|
||||
fx60 = edr_u * fx60;
|
||||
fx45i = edri * fx45i;
|
||||
|
||||
w1.x = dot(abs(E-F),rgbw); w1.y = dot(abs(E-B),rgbw); w1.z = dot(abs(E-D),rgbw); w1.w = dot(abs(E-H),rgbw);
|
||||
w2.x = dot(abs(E-H),rgbw); w2.y = dot(abs(E-F),rgbw); w2.z = dot(abs(E-B),rgbw); w2.w = dot(abs(E-D),rgbw);
|
||||
|
||||
px = step(w1, w2);
|
||||
#ifdef SMOOTH_TIPS
|
||||
vec4 maximos = max(max(fx30, fx60), max(fx45, fx45i));
|
||||
#else
|
||||
vec4 maximos = max(max(fx30, fx60), fx45);
|
||||
#endif
|
||||
vec3 res1 = E;
|
||||
res1 = mix(res1, mix(H, F, px.x), maximos.x);
|
||||
res1 = mix(res1, mix(B, D, px.z), maximos.z);
|
||||
|
||||
vec3 res2 = E;
|
||||
res2 = mix(res2, mix(F, B, px.y), maximos.y);
|
||||
res2 = mix(res2, mix(D, H, px.w), maximos.w);
|
||||
|
||||
res = mix(res1, res2, step(c_df(E, res1), c_df(E, res2)));
|
||||
}
|
||||
gl_FragColor.xyz = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,133 +1,133 @@
|
||||
/*
|
||||
Hyllian's 5xBR v3.5a Shader
|
||||
|
||||
Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
const float coef = 2.0;
|
||||
const vec3 rgbw = vec3(16.163, 23.351, 8.4772);
|
||||
|
||||
const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
|
||||
const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
|
||||
const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
|
||||
const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
|
||||
const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
|
||||
const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
|
||||
|
||||
|
||||
vec4 df(vec4 A, vec4 B) {
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
void main(){
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule
|
||||
bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
|
||||
bvec4 nc; // new_color
|
||||
bvec4 fx, fx_left, fx_up; // inequations of straight lines.
|
||||
|
||||
vec2 pS = 1.0 / u_texelDelta.xy;
|
||||
vec2 fp = fract(v_texcoord0.xy*pS.xy);
|
||||
vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy;
|
||||
vec2 dx = vec2(u_texelDelta.x,0.0);
|
||||
vec2 dy = vec2(0.0,u_texelDelta.y);
|
||||
vec2 y2 = dy + dy; vec2 x2 = dx + dx;
|
||||
|
||||
vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy ).xyz;
|
||||
vec3 B = texture2D(sampler0, TexCoord_0 -dy ).xyz;
|
||||
vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy ).xyz;
|
||||
vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz;
|
||||
vec3 E = texture2D(sampler0, TexCoord_0 ).xyz;
|
||||
vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz;
|
||||
vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy ).xyz;
|
||||
vec3 H = texture2D(sampler0, TexCoord_0 +dy ).xyz;
|
||||
vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy ).xyz;
|
||||
vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz;
|
||||
vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz;
|
||||
vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz;
|
||||
vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz;
|
||||
vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz;
|
||||
vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz;
|
||||
vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz;
|
||||
vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz;
|
||||
vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz;
|
||||
vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz;
|
||||
vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz;
|
||||
vec3 F4 = texture2D(sampler0, 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 = vec4(b.y, b.z, b.w, b.x);
|
||||
vec4 e = vec4(dot(E,rgbw));
|
||||
vec4 f = vec4(b.w, b.x, b.y, b.z);
|
||||
vec4 g = vec4(c.z, c.w, c.x, c.y);
|
||||
vec4 h = vec4(b.z, b.w, b.x, b.y);
|
||||
vec4 i = vec4(c.w, c.x, c.y, c.z);
|
||||
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 = vec4(h5.y, h5.z, h5.w, h5.x);
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
fx = greaterThan(Ao*fp.y+Bo*fp.x,Co);
|
||||
fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx);
|
||||
fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy);
|
||||
|
||||
interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h)));
|
||||
interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g)));
|
||||
interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c)));
|
||||
|
||||
edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1));
|
||||
edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left));
|
||||
edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up));
|
||||
|
||||
nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) );
|
||||
nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) );
|
||||
nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) );
|
||||
nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) );
|
||||
|
||||
px = lessThanEqual(df(e,f),df(e,h));
|
||||
|
||||
res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;
|
||||
}
|
||||
gl_FragColor.rgb = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
/*
|
||||
Hyllian's 5xBR v3.5a Shader
|
||||
|
||||
Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
const float coef = 2.0;
|
||||
const vec3 rgbw = vec3(16.163, 23.351, 8.4772);
|
||||
|
||||
const vec4 Ao = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bo = vec4( 1.0, 1.0, -1.0,-1.0 );
|
||||
const vec4 Co = vec4( 1.5, 0.5, -0.5, 0.5 );
|
||||
const vec4 Ax = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 Bx = vec4( 0.5, 2.0, -0.5,-2.0 );
|
||||
const vec4 Cx = vec4( 1.0, 1.0, -0.5, 0.0 );
|
||||
const vec4 Ay = vec4( 1.0, -1.0, -1.0, 1.0 );
|
||||
const vec4 By = vec4( 2.0, 0.5, -2.0,-0.5 );
|
||||
const vec4 Cy = vec4( 2.0, 0.0, -1.0, 0.5 );
|
||||
|
||||
|
||||
vec4 df(vec4 A, vec4 B) {
|
||||
return abs(A-B);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
void main(){
|
||||
|
||||
bool upscale = u_texelDelta.x > (1.6 * u_pixelDelta.x);
|
||||
vec3 res = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
// Let's skip the whole scaling if output size smaller than 1.6x of input size
|
||||
if (upscale) {
|
||||
|
||||
bvec4 edr, edr_left, edr_up, px; // px = pixel, edr = edge detection rule
|
||||
bvec4 interp_restriction_lv1, interp_restriction_lv2_left, interp_restriction_lv2_up;
|
||||
bvec4 nc; // new_color
|
||||
bvec4 fx, fx_left, fx_up; // inequations of straight lines.
|
||||
|
||||
vec2 pS = 1.0 / u_texelDelta.xy;
|
||||
vec2 fp = fract(v_texcoord0.xy*pS.xy);
|
||||
vec2 TexCoord_0 = v_texcoord0.xy-fp*u_pixelDelta.xy;
|
||||
vec2 dx = vec2(u_texelDelta.x,0.0);
|
||||
vec2 dy = vec2(0.0,u_texelDelta.y);
|
||||
vec2 y2 = dy + dy; vec2 x2 = dx + dx;
|
||||
|
||||
vec3 A = texture2D(sampler0, TexCoord_0 -dx -dy ).xyz;
|
||||
vec3 B = texture2D(sampler0, TexCoord_0 -dy ).xyz;
|
||||
vec3 C = texture2D(sampler0, TexCoord_0 +dx -dy ).xyz;
|
||||
vec3 D = texture2D(sampler0, TexCoord_0 -dx ).xyz;
|
||||
vec3 E = texture2D(sampler0, TexCoord_0 ).xyz;
|
||||
vec3 F = texture2D(sampler0, TexCoord_0 +dx ).xyz;
|
||||
vec3 G = texture2D(sampler0, TexCoord_0 -dx +dy ).xyz;
|
||||
vec3 H = texture2D(sampler0, TexCoord_0 +dy ).xyz;
|
||||
vec3 I = texture2D(sampler0, TexCoord_0 +dx +dy ).xyz;
|
||||
vec3 A1 = texture2D(sampler0, TexCoord_0 -dx -y2).xyz;
|
||||
vec3 C1 = texture2D(sampler0, TexCoord_0 +dx -y2).xyz;
|
||||
vec3 A0 = texture2D(sampler0, TexCoord_0 -x2 -dy).xyz;
|
||||
vec3 G0 = texture2D(sampler0, TexCoord_0 -x2 +dy).xyz;
|
||||
vec3 C4 = texture2D(sampler0, TexCoord_0 +x2 -dy).xyz;
|
||||
vec3 I4 = texture2D(sampler0, TexCoord_0 +x2 +dy).xyz;
|
||||
vec3 G5 = texture2D(sampler0, TexCoord_0 -dx +y2).xyz;
|
||||
vec3 I5 = texture2D(sampler0, TexCoord_0 +dx +y2).xyz;
|
||||
vec3 B1 = texture2D(sampler0, TexCoord_0 -y2).xyz;
|
||||
vec3 D0 = texture2D(sampler0, TexCoord_0 -x2 ).xyz;
|
||||
vec3 H5 = texture2D(sampler0, TexCoord_0 +y2).xyz;
|
||||
vec3 F4 = texture2D(sampler0, 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 = vec4(b.y, b.z, b.w, b.x);
|
||||
vec4 e = vec4(dot(E,rgbw));
|
||||
vec4 f = vec4(b.w, b.x, b.y, b.z);
|
||||
vec4 g = vec4(c.z, c.w, c.x, c.y);
|
||||
vec4 h = vec4(b.z, b.w, b.x, b.y);
|
||||
vec4 i = vec4(c.w, c.x, c.y, c.z);
|
||||
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 = vec4(h5.y, h5.z, h5.w, h5.x);
|
||||
|
||||
// These inequations define the line below which interpolation occurs.
|
||||
fx = greaterThan(Ao*fp.y+Bo*fp.x,Co);
|
||||
fx_left = greaterThan(Ax*fp.y+Bx*fp.x,Cx);
|
||||
fx_up = greaterThan(Ay*fp.y+By*fp.x,Cy);
|
||||
|
||||
interp_restriction_lv1 = bvec4(vec4(notEqual(e,f))*vec4(notEqual(e,h)));
|
||||
interp_restriction_lv2_left = bvec4(vec4(notEqual(e,g))*vec4(notEqual(d,g)));
|
||||
interp_restriction_lv2_up = bvec4(vec4(notEqual(e,c))*vec4(notEqual(b,c)));
|
||||
|
||||
edr = bvec4(vec4(lessThan(weighted_distance( e, c, g, i, h5, f4, h, f), weighted_distance( h, d, i5, f, i4, b, e, i)))*vec4(interp_restriction_lv1));
|
||||
edr_left = bvec4(vec4(lessThanEqual(coef*df(f,g),df(h,c)))*vec4(interp_restriction_lv2_left));
|
||||
edr_up = bvec4(vec4(greaterThanEqual(df(f,g),coef*df(h,c)))*vec4(interp_restriction_lv2_up));
|
||||
|
||||
nc.x = ( edr.x && (fx.x || edr_left.x && fx_left.x || edr_up.x && fx_up.x) );
|
||||
nc.y = ( edr.y && (fx.y || edr_left.y && fx_left.y || edr_up.y && fx_up.y) );
|
||||
nc.z = ( edr.z && (fx.z || edr_left.z && fx_left.z || edr_up.z && fx_up.z) );
|
||||
nc.w = ( edr.w && (fx.w || edr_left.w && fx_left.w || edr_up.w && fx_up.w) );
|
||||
|
||||
px = lessThanEqual(df(e,f),df(e,h));
|
||||
|
||||
res = nc.x ? px.x ? F : H : nc.y ? px.y ? B : F : nc.z ? px.z ? D : B : nc.w ? px.w ? H : D : E;
|
||||
}
|
||||
gl_FragColor.rgb = res;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
/*
|
||||
Hyllian's 5xBR v3.5a Shader
|
||||
|
||||
Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
v_texcoord0 = a_texcoord0;
|
||||
gl_Position = a_position;
|
||||
/*
|
||||
Hyllian's 5xBR v3.5a Shader
|
||||
|
||||
Copyright (C) 2011 Hyllian/Jararaca - sergiogdb@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
v_texcoord0 = a_texcoord0;
|
||||
gl_Position = a_position;
|
||||
}
|
||||
@@ -1,73 +1,73 @@
|
||||
// PPSSPP: Simple Gauss filter
|
||||
// Made by Bigpet
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
// The parameters are hardcoded for now, but could be
|
||||
// made into uniforms to control fromt he program.
|
||||
float GAUSS_SPAN_MAX = 1.5;
|
||||
|
||||
//just a variable to describe the maximu
|
||||
float GAUSS_KERNEL_SIZE = 5.0;
|
||||
//indices
|
||||
// XX XX 00 XX XX
|
||||
// XX 01 02 03 XX
|
||||
// 04 05 06 07 08
|
||||
// XX 09 10 11 XX
|
||||
// XX XX 12 XX XX
|
||||
|
||||
//filter strength, rather smooth
|
||||
// XX XX 01 XX XX
|
||||
// XX 03 08 03 XX
|
||||
// 01 08 10 08 01
|
||||
// XX 03 08 03 XX
|
||||
// XX XX 01 XX XX
|
||||
|
||||
vec2 offset = u_pixelDelta*GAUSS_SPAN_MAX/GAUSS_KERNEL_SIZE;
|
||||
|
||||
vec3 rgbSimple0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz;
|
||||
vec3 rgbSimple1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz;
|
||||
vec3 rgbSimple2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz;
|
||||
vec3 rgbSimple3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz;
|
||||
vec3 rgbSimple4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz;
|
||||
vec3 rgbSimple5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz;
|
||||
vec3 rgbSimple6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz;
|
||||
vec3 rgbSimple7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz;
|
||||
vec3 rgbSimple8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz;
|
||||
vec3 rgbSimple9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz;
|
||||
vec3 rgbSimple10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz;
|
||||
vec3 rgbSimple11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz;
|
||||
vec3 rgbSimple12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz;
|
||||
//vec3 rgbSimple10= vec3(1.0,0.0,0.0);
|
||||
//vec3 rgbSimple11= vec3(1.0,0.0,0.0);
|
||||
//vec3 rgbSimple12= vec3(1.0,0.0,0.0);
|
||||
|
||||
vec3 rgb = rgbSimple0 +
|
||||
rgbSimple1 +
|
||||
rgbSimple2 +
|
||||
rgbSimple3 +
|
||||
rgbSimple4 +
|
||||
rgbSimple5 +
|
||||
rgbSimple6 +
|
||||
rgbSimple7 +
|
||||
rgbSimple8 +
|
||||
rgbSimple9 +
|
||||
rgbSimple10 +
|
||||
rgbSimple11 +
|
||||
rgbSimple12;
|
||||
rgb = rgb / 58.0;
|
||||
gl_FragColor.xyz=rgb;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
// PPSSPP: Simple Gauss filter
|
||||
// Made by Bigpet
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
// The parameters are hardcoded for now, but could be
|
||||
// made into uniforms to control fromt he program.
|
||||
float GAUSS_SPAN_MAX = 1.5;
|
||||
|
||||
//just a variable to describe the maximu
|
||||
float GAUSS_KERNEL_SIZE = 5.0;
|
||||
//indices
|
||||
// XX XX 00 XX XX
|
||||
// XX 01 02 03 XX
|
||||
// 04 05 06 07 08
|
||||
// XX 09 10 11 XX
|
||||
// XX XX 12 XX XX
|
||||
|
||||
//filter strength, rather smooth
|
||||
// XX XX 01 XX XX
|
||||
// XX 03 08 03 XX
|
||||
// 01 08 10 08 01
|
||||
// XX 03 08 03 XX
|
||||
// XX XX 01 XX XX
|
||||
|
||||
vec2 offset = u_pixelDelta*GAUSS_SPAN_MAX/GAUSS_KERNEL_SIZE;
|
||||
|
||||
vec3 rgbSimple0 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-2.0)).xyz;
|
||||
vec3 rgbSimple1 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0,-1.0)).xyz;
|
||||
vec3 rgbSimple2 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0,-1.0)).xyz;
|
||||
vec3 rgbSimple3 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0,-1.0)).xyz;
|
||||
vec3 rgbSimple4 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-2.0, 0.0)).xyz;
|
||||
vec3 rgbSimple5 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 0.0)).xyz;
|
||||
vec3 rgbSimple6 = 10.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 0.0)).xyz;
|
||||
vec3 rgbSimple7 = 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 0.0)).xyz;
|
||||
vec3 rgbSimple8 = 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 2.0, 0.0)).xyz;
|
||||
vec3 rgbSimple9 = 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2(-1.0, 1.0)).xyz;
|
||||
vec3 rgbSimple10= 8.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 1.0)).xyz;
|
||||
vec3 rgbSimple11= 3.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 1.0, 1.0)).xyz;
|
||||
vec3 rgbSimple12= 1.0 * texture2D(sampler0, v_texcoord0.xy + offset * vec2( 0.0, 2.0)).xyz;
|
||||
//vec3 rgbSimple10= vec3(1.0,0.0,0.0);
|
||||
//vec3 rgbSimple11= vec3(1.0,0.0,0.0);
|
||||
//vec3 rgbSimple12= vec3(1.0,0.0,0.0);
|
||||
|
||||
vec3 rgb = rgbSimple0 +
|
||||
rgbSimple1 +
|
||||
rgbSimple2 +
|
||||
rgbSimple3 +
|
||||
rgbSimple4 +
|
||||
rgbSimple5 +
|
||||
rgbSimple6 +
|
||||
rgbSimple7 +
|
||||
rgbSimple8 +
|
||||
rgbSimple9 +
|
||||
rgbSimple10 +
|
||||
rgbSimple11 +
|
||||
rgbSimple12;
|
||||
rgb = rgb / 58.0;
|
||||
gl_FragColor.xyz=rgb;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,69 +1,69 @@
|
||||
// AA-Color shader, Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// license: GNU-GPL
|
||||
|
||||
// Color variables
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
const vec3 c_ch = vec3(1.0,1.0,1.0); // rgb color channel intensity
|
||||
const float a = 1.20 ; // saturation
|
||||
const float b = 1.00 ; // brightness
|
||||
const float c = 1.25 ; // 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 sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c10 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 c01 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 c11 = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 c21 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 c12 = texture2D(sampler0, v_texcoord2.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.rgb = contrast4(x)*normalize(color*c_ch)*b;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// AA-Color shader, Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// license: GNU-GPL
|
||||
|
||||
// Color variables
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
const vec3 c_ch = vec3(1.0,1.0,1.0); // rgb color channel intensity
|
||||
const float a = 1.20 ; // saturation
|
||||
const float b = 1.00 ; // brightness
|
||||
const float c = 1.25 ; // 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 sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c10 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 c01 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 c11 = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 c21 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 c12 = texture2D(sampler0, v_texcoord2.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.rgb = contrast4(x)*normalize(color*c_ch)*b;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,33 +1,38 @@
|
||||
// by guest(r) - guest.r@gmail.com
|
||||
// license: GNU-GPL
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
float scaleoffset = 0.8;
|
||||
|
||||
void main()
|
||||
|
||||
{
|
||||
float x = u_texelDelta.x*scaleoffset;
|
||||
float y = u_texelDelta.y*scaleoffset;
|
||||
gl_Position = a_position;
|
||||
v_texcoord0 = a_texcoord0.xyxy;
|
||||
v_texcoord1 = v_texcoord0;
|
||||
v_texcoord2 = v_texcoord0;
|
||||
v_texcoord4 = v_texcoord0;
|
||||
v_texcoord5 = v_texcoord0;
|
||||
v_texcoord1.y-=y;
|
||||
v_texcoord2.y+=y;
|
||||
v_texcoord4.x-=x;
|
||||
v_texcoord5.x+=x;
|
||||
}
|
||||
// by guest(r) - guest.r@gmail.com
|
||||
// license: GNU-GPL
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
float scaleoffset = 0.8;
|
||||
|
||||
void main()
|
||||
|
||||
{
|
||||
float x = u_texelDelta.x*scaleoffset;
|
||||
float y = u_texelDelta.y*scaleoffset;
|
||||
gl_Position = a_position;
|
||||
v_texcoord0 = a_texcoord0.xyxy;
|
||||
v_texcoord1 = v_texcoord0;
|
||||
v_texcoord2 = v_texcoord0;
|
||||
v_texcoord4 = v_texcoord0;
|
||||
v_texcoord5 = v_texcoord0;
|
||||
v_texcoord1.y-=y;
|
||||
v_texcoord2.y+=y;
|
||||
v_texcoord4.x-=x;
|
||||
v_texcoord5.x+=x;
|
||||
}
|
||||
|
||||
@@ -1,48 +1,47 @@
|
||||
// Simple Bloom shader; created to use in PPSSPP.
|
||||
// Without excessive samples and complex nested loops
|
||||
// (to make it compatible with low-end GPUs and to ensure ps_2_0 compatibility).
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
float amount = 0.60; // suitable range = 0.00 - 1.00
|
||||
float power = 0.5; // suitable range = 0.0 - 1.0
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec4 sum = vec4(0);
|
||||
vec3 bloom;
|
||||
|
||||
for(int i= -3 ;i < 3; i++)
|
||||
{
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(-1, i)*0.004) * amount;
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(0, i)*0.004) * amount;
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(1, i)*0.004) * amount;
|
||||
}
|
||||
|
||||
if (color.r < 0.3 && color.g < 0.3 && color.b < 0.3)
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.012 + color;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (color.r < 0.5 && color.g < 0.5 && color.b < 0.5)
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.009 + color;
|
||||
}
|
||||
else
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.0075 + color;
|
||||
}
|
||||
}
|
||||
|
||||
bloom = mix(color, bloom, power);
|
||||
gl_FragColor.rgb = bloom;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Simple Bloom shader; created to use in PPSSPP.
|
||||
// Without excessive samples and complex nested loops
|
||||
// (to make it compatible with low-end GPUs and to ensure ps_2_0 compatibility).
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
uniform vec4 u_setting;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec4 sum = vec4(0);
|
||||
vec3 bloom;
|
||||
|
||||
for(int i= -3 ;i < 3; i++)
|
||||
{
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(-1, i)*0.004) * u_setting.x;
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(0, i)*0.004) * u_setting.x;
|
||||
sum += texture2D(sampler0, v_texcoord0 + vec2(1, i)*0.004) * u_setting.x;
|
||||
}
|
||||
|
||||
if (color.r < 0.3 && color.g < 0.3 && color.b < 0.3)
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.012 + color;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (color.r < 0.5 && color.g < 0.5 && color.b < 0.5)
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.009 + color;
|
||||
}
|
||||
else
|
||||
{
|
||||
bloom = sum.xyz*sum.xyz*0.0075 + color;
|
||||
}
|
||||
}
|
||||
|
||||
bloom = mix(color, bloom, u_setting.y);
|
||||
gl_FragColor.rgb = bloom;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,52 +1,52 @@
|
||||
// Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// Advanced Cartoon shader I
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// license: GNU-GPL
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
const float bb = 0.5; // effects black border sensitivity; from 0.0 to 1.0
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c00 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 c10 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 c20 = texture2D(sampler0, v_texcoord2.zw).xyz;
|
||||
vec3 c01 = texture2D(sampler0, v_texcoord3.xy).xyz;
|
||||
vec3 c11 = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 c21 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 c02 = texture2D(sampler0, v_texcoord1.zw).xyz;
|
||||
vec3 c12 = texture2D(sampler0, v_texcoord2.xy).xyz;
|
||||
vec3 c22 = texture2D(sampler0, v_texcoord6.xy).xyz;
|
||||
vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
float d1=dot(abs(c00-c22),dt);
|
||||
float d2=dot(abs(c20-c02),dt);
|
||||
float hl=dot(abs(c01-c21),dt);
|
||||
float vl=dot(abs(c10-c12),dt);
|
||||
float d = bb*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);
|
||||
|
||||
float lc = 4.0*length(c11);
|
||||
float f = fract(lc); f*=f;
|
||||
lc = 0.25*(floor(lc) + f*f)+0.05;
|
||||
c11 = 4.0*normalize(c11);
|
||||
vec3 frct = fract(c11); frct*=frct;
|
||||
c11 = floor(c11)+ 0.05*dt + frct*frct;
|
||||
gl_FragColor.rgb = 0.25*lc*(1.1-d*sqrt(d))*c11;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Modified to use in PPSSPP. Grabbed from:
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
// Advanced Cartoon shader I
|
||||
// by guest(r) (guest.r@gmail.com)
|
||||
// license: GNU-GPL
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform vec4 u_setting;
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c00 = texture2D(sampler0, v_texcoord5.xy).xyz;
|
||||
vec3 c10 = texture2D(sampler0, v_texcoord1.xy).xyz;
|
||||
vec3 c20 = texture2D(sampler0, v_texcoord2.zw).xyz;
|
||||
vec3 c01 = texture2D(sampler0, v_texcoord3.xy).xyz;
|
||||
vec3 c11 = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
vec3 c21 = texture2D(sampler0, v_texcoord4.xy).xyz;
|
||||
vec3 c02 = texture2D(sampler0, v_texcoord1.zw).xyz;
|
||||
vec3 c12 = texture2D(sampler0, v_texcoord2.xy).xyz;
|
||||
vec3 c22 = texture2D(sampler0, v_texcoord6.xy).xyz;
|
||||
vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
float d1=dot(abs(c00-c22),dt);
|
||||
float d2=dot(abs(c20-c02),dt);
|
||||
float hl=dot(abs(c01-c21),dt);
|
||||
float vl=dot(abs(c10-c12),dt);
|
||||
float d = u_setting.x*(d1+d2+hl+vl)/(dot(c11,dt)+0.15);
|
||||
|
||||
float lc = 4.0*length(c11);
|
||||
float f = fract(lc); f*=f;
|
||||
lc = 0.25*(floor(lc) + f*f)+0.05;
|
||||
c11 = 4.0*normalize(c11);
|
||||
vec3 frct = fract(c11); frct*=frct;
|
||||
c11 = floor(c11)+ 0.05*dt + frct*frct;
|
||||
gl_FragColor.rgb = 0.25*lc*(1.1-d*sqrt(d))*c11;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,34 +1,39 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
float scaleoffset = 0.8; //edge detection offset
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = u_texelDelta.x*scaleoffset;
|
||||
float y = u_texelDelta.y*scaleoffset;
|
||||
vec2 dg1 = vec2( x,y);
|
||||
vec2 dg2 = vec2(-x,y);
|
||||
vec2 dx = vec2(x,0.0);
|
||||
vec2 dy = vec2(0.0,y);
|
||||
gl_Position = a_position;
|
||||
v_texcoord0=a_texcoord0.xyxy;
|
||||
v_texcoord1.xy = v_texcoord0.xy - dy;
|
||||
v_texcoord2.xy = v_texcoord0.xy + dy;
|
||||
v_texcoord3.xy = v_texcoord0.xy - dx;
|
||||
v_texcoord4.xy = v_texcoord0.xy + dx;
|
||||
v_texcoord5.xy = v_texcoord0.xy - dg1;
|
||||
v_texcoord6.xy = v_texcoord0.xy + dg1;
|
||||
v_texcoord1.zw = v_texcoord0.xy - dg2;
|
||||
v_texcoord2.zw = v_texcoord0.xy + dg2;
|
||||
|
||||
}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
varying vec4 v_texcoord4;
|
||||
varying vec4 v_texcoord5;
|
||||
varying vec4 v_texcoord6;
|
||||
|
||||
float scaleoffset = 0.8; //edge detection offset
|
||||
|
||||
void main()
|
||||
{
|
||||
float x = u_texelDelta.x*scaleoffset;
|
||||
float y = u_texelDelta.y*scaleoffset;
|
||||
vec2 dg1 = vec2( x,y);
|
||||
vec2 dg2 = vec2(-x,y);
|
||||
vec2 dx = vec2(x,0.0);
|
||||
vec2 dy = vec2(0.0,y);
|
||||
gl_Position = a_position;
|
||||
v_texcoord0=a_texcoord0.xyxy;
|
||||
v_texcoord1.xy = v_texcoord0.xy - dy;
|
||||
v_texcoord2.xy = v_texcoord0.xy + dy;
|
||||
v_texcoord3.xy = v_texcoord0.xy - dx;
|
||||
v_texcoord4.xy = v_texcoord0.xy + dx;
|
||||
v_texcoord5.xy = v_texcoord0.xy - dg1;
|
||||
v_texcoord6.xy = v_texcoord0.xy + dg1;
|
||||
v_texcoord1.zw = v_texcoord0.xy - dg2;
|
||||
v_texcoord2.zw = v_texcoord0.xy + dg2;
|
||||
|
||||
}
|
||||
|
||||
20
system/PPSSPP/shaders/colorcorrection.fsh
Normal file
20
system/PPSSPP/shaders/colorcorrection.fsh
Normal file
@@ -0,0 +1,20 @@
|
||||
// Color correction
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
uniform vec4 u_setting;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 rgb = texture2D( sampler0, v_texcoord0 ).xyz;
|
||||
rgb = vec3(mix(vec3(dot(rgb, vec3(0.299, 0.587, 0.114))), rgb, u_setting.y));
|
||||
rgb = (rgb-0.5)*u_setting.z+0.5+u_setting.x-1.0;
|
||||
gl_FragColor.rgb = pow(rgb, vec3(1.0/u_setting.w));
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
@@ -1,33 +1,33 @@
|
||||
// Retro (CRT) shader, created to use in PPSSPP.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
uniform vec4 u_time;
|
||||
|
||||
void main()
|
||||
{
|
||||
// scanlines
|
||||
int vPos = int( ( v_texcoord0.y + u_time.x * 0.5 ) * 272.0 );
|
||||
float line_intensity = mod( float(vPos), 2.0 );
|
||||
|
||||
// color shift
|
||||
float off = line_intensity * 0.0005;
|
||||
vec2 shift = vec2( off, 0 );
|
||||
|
||||
// shift R and G channels to simulate NTSC color bleed
|
||||
vec2 colorShift = vec2( 0.001, 0 );
|
||||
float r = texture2D( sampler0, v_texcoord0 + colorShift + shift ).x;
|
||||
float g = texture2D( sampler0, v_texcoord0 - colorShift + shift ).y;
|
||||
float b = texture2D( sampler0, v_texcoord0 ).z;
|
||||
|
||||
vec4 c = vec4( r, g * 0.99, b, 1.0 ) * clamp( line_intensity, 0.85, 1.0 );
|
||||
|
||||
float rollbar = sin( ( v_texcoord0.y + u_time.x ) * 4.0 );
|
||||
|
||||
gl_FragColor.rgba = c + (rollbar * 0.02);
|
||||
}
|
||||
// Retro (CRT) shader, created to use in PPSSPP.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
uniform vec4 u_time;
|
||||
|
||||
void main()
|
||||
{
|
||||
// scanlines
|
||||
int vPos = int( ( v_texcoord0.y + u_time.x * 0.5 ) * 272.0 );
|
||||
float line_intensity = mod( float(vPos), 2.0 );
|
||||
|
||||
// color shift
|
||||
float off = line_intensity * 0.0005;
|
||||
vec2 shift = vec2( off, 0 );
|
||||
|
||||
// shift R and G channels to simulate NTSC color bleed
|
||||
vec2 colorShift = vec2( 0.001, 0 );
|
||||
float r = texture2D( sampler0, v_texcoord0 + colorShift + shift ).x;
|
||||
float g = texture2D( sampler0, v_texcoord0 - colorShift + shift ).y;
|
||||
float b = texture2D( sampler0, v_texcoord0 ).z;
|
||||
|
||||
vec4 c = vec4( r, g * 0.99, b, 1.0 ) * clamp( line_intensity, 0.85, 1.0 );
|
||||
|
||||
float rollbar = sin( ( v_texcoord0.y + u_time.x ) * 4.0 );
|
||||
|
||||
gl_FragColor.rgba = c + (rollbar * 0.02);
|
||||
}
|
||||
|
||||
@@ -1,95 +1,162 @@
|
||||
# You can have multiple ini files if you want, it doesn't matter.
|
||||
[FXAA]
|
||||
Name=FXAA Antialiasing
|
||||
Author=nVidia
|
||||
Fragment=fxaa.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[CRT]
|
||||
Name=CRT Scanlines
|
||||
Author=KillaMaaki
|
||||
Fragment=crt.fsh
|
||||
Vertex=fxaa.vsh
|
||||
60fps=True
|
||||
[Natural]
|
||||
Name=Natural Colors
|
||||
Fragment=natural.fsh
|
||||
Vertex=natural.vsh
|
||||
[NaturalA]
|
||||
Name=Natural Colors (No Blur)
|
||||
Fragment=naturalA.fsh
|
||||
Vertex=natural.vsh
|
||||
[Vignette]
|
||||
Name=Vignette
|
||||
Author=Henrik
|
||||
Fragment=vignette.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Grayscale]
|
||||
Name=Grayscale
|
||||
Author=Henrik
|
||||
Fragment=grayscale.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Bloom]
|
||||
Name=Bloom
|
||||
Fragment=bloom.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Sharpen]
|
||||
Name=Sharpen
|
||||
Fragment=sharpen.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[InverseColors]
|
||||
Name=Inverse Colors
|
||||
Author=Henrik
|
||||
Fragment=inversecolors.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Scanlines]
|
||||
Name=Scanlines (CRT)
|
||||
Fragment=scanlines.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
[Cartoon]
|
||||
Name=Cartoon
|
||||
Fragment=cartoon.fsh
|
||||
Vertex=cartoon.vsh
|
||||
[4xHqGLSL]
|
||||
Name=4xHqGLSL Upscaler
|
||||
Fragment=4xhqglsl.fsh
|
||||
Vertex=4xhqglsl.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[AAColor]
|
||||
Name=AA-Color
|
||||
Fragment=aacolor.fsh
|
||||
Vertex=aacolor.vsh
|
||||
[UpscaleSpline36]
|
||||
Name=Spline36 Upscaler
|
||||
Fragment=upscale_spline36.fsh
|
||||
Vertex=upscale_spline36.vsh
|
||||
OutputResolution=True
|
||||
RequiresIntSupport=True
|
||||
Upscaling=True
|
||||
[5xBR]
|
||||
Name=5xBR Upscaler
|
||||
Author=Hyllian
|
||||
Fragment=5xBR.fsh
|
||||
Vertex=5xBR.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[5xBR-lv2]
|
||||
Name=5xBR lv2 Upscaler
|
||||
Author=Hyllian (tweak by guest.r)
|
||||
Fragment=5xBR-lv2.fsh
|
||||
Vertex=5xBR.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[VideoSmoothingAA]
|
||||
Name=Video aware guest.r AA 4.o
|
||||
Author=guest.r(tweak by LunaMoo)
|
||||
Fragment=videoAA.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
[SSAA(Gauss)]
|
||||
Name=Super Sampling AA(Gauss)
|
||||
Fragment=GaussianDownscale.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
SSAA=2
|
||||
# You can have multiple ini files if you want, it doesn't matter.
|
||||
[FXAA]
|
||||
Name=FXAA Antialiasing
|
||||
Author=nVidia
|
||||
Fragment=fxaa.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[CRT]
|
||||
Name=CRT Scanlines
|
||||
Author=KillaMaaki
|
||||
Fragment=crt.fsh
|
||||
Vertex=fxaa.vsh
|
||||
60fps=True
|
||||
[Natural]
|
||||
Name=Natural Colors
|
||||
Fragment=natural.fsh
|
||||
Vertex=natural.vsh
|
||||
[NaturalA]
|
||||
Name=Natural Colors (No Blur)
|
||||
Fragment=naturalA.fsh
|
||||
Vertex=naturalA.vsh
|
||||
[Vignette]
|
||||
Name=Vignette
|
||||
Author=Henrik
|
||||
Fragment=vignette.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Grayscale]
|
||||
Name=Grayscale
|
||||
Author=Henrik
|
||||
Fragment=grayscale.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Bloom]
|
||||
Name=Bloom
|
||||
Fragment=bloom.fsh
|
||||
Vertex=fxaa.vsh
|
||||
SettingName1=Amount
|
||||
SettingDefaultValue1=0.6
|
||||
SettingMaxValue1=1.0
|
||||
SettingMinValue1=0.0
|
||||
SettingName2=Power
|
||||
SettingDefaultValue2=0.5
|
||||
SettingMaxValue2=1.0
|
||||
SettingMinValue2=0.0
|
||||
[Sharpen]
|
||||
Name=Sharpen
|
||||
Fragment=sharpen.fsh
|
||||
Vertex=fxaa.vsh
|
||||
SettingName1=Amount
|
||||
SettingDefaultValue1=1.5
|
||||
SettingMaxValue1=3.0
|
||||
SettingMinValue1=1.0
|
||||
SettingStep1=0.1
|
||||
[InverseColors]
|
||||
Name=Inverse Colors
|
||||
Author=Henrik
|
||||
Fragment=inversecolors.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Scanlines]
|
||||
Name=Scanlines (CRT)
|
||||
Fragment=scanlines.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
SettingName1=Amount
|
||||
SettingDefaultValue1=1.0
|
||||
SettingMaxValue1=1.0
|
||||
SettingMinValue1=0.0
|
||||
SettingStep1=0.1
|
||||
SettingName2=Intensity
|
||||
SettingDefaultValue2=0.5
|
||||
SettingMaxValue2=1.0
|
||||
SettingMinValue2=0.0
|
||||
SettingStep2=0.05
|
||||
[Cartoon]
|
||||
Name=Cartoon
|
||||
Fragment=cartoon.fsh
|
||||
Vertex=cartoon.vsh
|
||||
SettingName1=Black border
|
||||
SettingDefaultValue1=0.5
|
||||
SettingMaxValue1=1.0
|
||||
SettingMinValue1=0.0
|
||||
[4xHqGLSL]
|
||||
Name=4xHqGLSL Upscaler
|
||||
Fragment=4xhqglsl.fsh
|
||||
Vertex=4xhqglsl.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[AAColor]
|
||||
Name=AA-Color
|
||||
Fragment=aacolor.fsh
|
||||
Vertex=aacolor.vsh
|
||||
[UpscaleSpline36]
|
||||
Name=Spline36 Upscaler
|
||||
Fragment=upscale_spline36.fsh
|
||||
Vertex=upscale_spline36.vsh
|
||||
OutputResolution=True
|
||||
RequiresIntSupport=True
|
||||
Upscaling=True
|
||||
[5xBR]
|
||||
Name=5xBR Upscaler
|
||||
Author=Hyllian
|
||||
Fragment=5xBR.fsh
|
||||
Vertex=5xBR.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[5xBR-lv2]
|
||||
Name=5xBR lv2 Upscaler
|
||||
Author=Hyllian (tweak by guest.r)
|
||||
Fragment=5xBR-lv2.fsh
|
||||
Vertex=5xBR.vsh
|
||||
OutputResolution=True
|
||||
Upscaling=True
|
||||
[VideoSmoothingAA]
|
||||
Name=Video aware guest.r AA 4.o
|
||||
Author=guest.r(tweak by LunaMoo)
|
||||
Fragment=videoAA.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
[SSAA(Gauss)]
|
||||
Name=Super Sampling AA(Gauss)
|
||||
Fragment=GaussianDownscale.fsh
|
||||
Vertex=fxaa.vsh
|
||||
OutputResolution=True
|
||||
SSAA=2
|
||||
[ColorCorrection]
|
||||
Name=Color correction
|
||||
Fragment=colorcorrection.fsh
|
||||
Vertex=fxaa.vsh
|
||||
SettingName1=Brightness
|
||||
SettingDefaultValue1=1.0
|
||||
SettingMaxValue1=2.0
|
||||
SettingMinValue1=0.1
|
||||
SettingStep1=0.05
|
||||
SettingName2=Saturation
|
||||
SettingDefaultValue2=1.0
|
||||
SettingMaxValue2=2.0
|
||||
SettingMinValue2=0.0
|
||||
SettingStep2=0.1
|
||||
SettingName3=Contrast
|
||||
SettingDefaultValue3=1.0
|
||||
SettingMaxValue3=3.0
|
||||
SettingMinValue3=0.1
|
||||
SettingStep3=0.1
|
||||
SettingName4=Gamma
|
||||
SettingDefaultValue4=1.0
|
||||
SettingMaxValue4=2.0
|
||||
SettingMinValue4=0.1
|
||||
SettingStep4=0.05
|
||||
[PSPColor]
|
||||
Name=PSP Color
|
||||
Author=hunterk, Pokefan531 (ported by jdgleaver)
|
||||
Fragment=psp_color.fsh
|
||||
Vertex=fxaa.vsh
|
||||
[Tex4xBRZ]
|
||||
Type=Texture
|
||||
Name=4xBRZ
|
||||
Author=Hyllian
|
||||
Compute=tex_4xbrz.csh
|
||||
[TexMMPX]
|
||||
Type=Texture
|
||||
Name=MMPX
|
||||
Author=Morgan McGuire and Mara Gagiu
|
||||
Compute=tex_mmpx.csh
|
||||
MaxScale=2
|
||||
|
||||
@@ -1,68 +1,68 @@
|
||||
// PPSSPP: Grabbed from Processing and slightly modified.
|
||||
|
||||
// FXAA shader, GLSL code adapted from:
|
||||
// http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA
|
||||
// Whitepaper describing the technique:
|
||||
// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 u_texelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
// The parameters are hardcoded for now, but could be
|
||||
// made into uniforms to control fromt he program.
|
||||
float FXAA_SPAN_MAX = 8.0;
|
||||
float FXAA_REDUCE_MUL = 1.0/8.0;
|
||||
float FXAA_REDUCE_MIN = (1.0/128.0);
|
||||
|
||||
vec3 rgbNW = texture2D(sampler0, v_texcoord0.xy + (vec2(-1.0, -1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbNE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, -1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbSW = texture2D(sampler0, v_texcoord0.xy + (vec2(-1.0, +1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbSE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, +1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbM = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma);
|
||||
float lumaNE = dot(rgbNE, luma);
|
||||
float lumaSW = dot(rgbSW, luma);
|
||||
float lumaSE = dot(rgbSE, luma);
|
||||
float lumaM = dot( rgbM, luma);
|
||||
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
|
||||
float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
|
||||
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||||
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta;
|
||||
|
||||
vec3 rgbA = (1.0/2.0) * (
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (1.0/3.0 - 0.5)).xyz +
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (2.0/3.0 - 0.5)).xyz);
|
||||
vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (0.0/3.0 - 0.5)).xyz +
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (3.0/3.0 - 0.5)).xyz);
|
||||
float lumaB = dot(rgbB, luma);
|
||||
|
||||
if((lumaB < lumaMin) || (lumaB > lumaMax)){
|
||||
gl_FragColor.xyz=rgbA;
|
||||
} else {
|
||||
gl_FragColor.xyz=rgbB;
|
||||
}
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
// PPSSPP: Grabbed from Processing and slightly modified.
|
||||
|
||||
// FXAA shader, GLSL code adapted from:
|
||||
// http://horde3d.org/wiki/index.php5?title=Shading_Technique_-_FXAA
|
||||
// Whitepaper describing the technique:
|
||||
// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
|
||||
// The inverse of the texture dimensions along X and Y
|
||||
uniform vec2 u_texelDelta;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
// The parameters are hardcoded for now, but could be
|
||||
// made into uniforms to control fromt he program.
|
||||
float FXAA_SPAN_MAX = 8.0;
|
||||
float FXAA_REDUCE_MUL = 1.0/8.0;
|
||||
float FXAA_REDUCE_MIN = (1.0/128.0);
|
||||
|
||||
vec3 rgbNW = texture2D(sampler0, v_texcoord0.xy + (vec2(-1.0, -1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbNE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, -1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbSW = texture2D(sampler0, v_texcoord0.xy + (vec2(-1.0, +1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbSE = texture2D(sampler0, v_texcoord0.xy + (vec2(+1.0, +1.0) * u_texelDelta)).xyz;
|
||||
vec3 rgbM = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
|
||||
vec3 luma = vec3(0.299, 0.587, 0.114);
|
||||
float lumaNW = dot(rgbNW, luma);
|
||||
float lumaNE = dot(rgbNE, luma);
|
||||
float lumaSW = dot(rgbSW, luma);
|
||||
float lumaSE = dot(rgbSE, luma);
|
||||
float lumaM = dot( rgbM, luma);
|
||||
|
||||
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
|
||||
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
|
||||
|
||||
vec2 dir;
|
||||
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
|
||||
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
|
||||
|
||||
float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN);
|
||||
|
||||
float rcpDirMin = 1.0/(min(abs(dir.x), abs(dir.y)) + dirReduce);
|
||||
|
||||
dir = min(vec2(FXAA_SPAN_MAX, FXAA_SPAN_MAX),
|
||||
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), dir * rcpDirMin)) * u_texelDelta;
|
||||
|
||||
vec3 rgbA = (1.0/2.0) * (
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (1.0/3.0 - 0.5)).xyz +
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (2.0/3.0 - 0.5)).xyz);
|
||||
vec3 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (0.0/3.0 - 0.5)).xyz +
|
||||
texture2D(sampler0, v_texcoord0.xy + dir * (3.0/3.0 - 0.5)).xyz);
|
||||
float lumaB = dot(rgbB, luma);
|
||||
|
||||
if((lumaB < lumaMin) || (lumaB > lumaMax)){
|
||||
gl_FragColor.xyz=rgbA;
|
||||
} else {
|
||||
gl_FragColor.xyz=rgbB;
|
||||
}
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
varying vec2 v_texcoord0;
|
||||
void main() {
|
||||
v_texcoord0 = a_texcoord0;
|
||||
gl_Position = a_position;
|
||||
}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
varying vec2 v_texcoord0;
|
||||
void main() {
|
||||
v_texcoord0 = a_texcoord0;
|
||||
gl_Position = a_position;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Simple grayscale shader
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
float luma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
||||
gl_FragColor.rgb = vec3(luma, luma, luma);
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Simple grayscale shader
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
float luma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
||||
gl_FragColor.rgb = vec3(luma, luma, luma);
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// Simple false color shader
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
float luma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
||||
vec3 gray = vec3(luma, luma, luma) - 0.5;
|
||||
rgb -= vec3(0.5, 0.5, 0.5);
|
||||
|
||||
gl_FragColor.rgb = mix(rgb, gray, 2.0) + 0.5;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Simple false color shader
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
float luma = dot(rgb, vec3(0.299, 0.587, 0.114));
|
||||
vec3 gray = vec3(luma, luma, luma) - 0.5;
|
||||
rgb -= vec3(0.5, 0.5, 0.5);
|
||||
|
||||
gl_FragColor.rgb = mix(rgb, gray, 2.0) + 0.5;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,58 +1,58 @@
|
||||
// Natural Vision Shader, modified to use in PPSSPP.
|
||||
|
||||
// by ShadX (Modded by SimoneT)
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
|
||||
const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212,
|
||||
0.587,-0.275,-0.523,
|
||||
0.114,-0.321, 0.311);
|
||||
|
||||
const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0,
|
||||
0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523,
|
||||
0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149);
|
||||
|
||||
const vec3 val00 = vec3( 1.2, 1.2, 1.2);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c0,c1;
|
||||
|
||||
c0 = texture2D(sampler0,v_texcoord0.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord1.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord2.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord3.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125;
|
||||
c0*=0.153846153846;
|
||||
|
||||
c1=RGBtoYIQ*c0;
|
||||
|
||||
c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz);
|
||||
|
||||
gl_FragColor.rgb=YIQtoRGB*c1;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Natural Vision Shader, modified to use in PPSSPP.
|
||||
|
||||
// by ShadX (Modded by SimoneT)
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
|
||||
const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212,
|
||||
0.587,-0.275,-0.523,
|
||||
0.114,-0.321, 0.311);
|
||||
|
||||
const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0,
|
||||
0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523,
|
||||
0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149);
|
||||
|
||||
const vec3 val00 = vec3( 1.2, 1.2, 1.2);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c0,c1;
|
||||
|
||||
c0 = texture2D(sampler0,v_texcoord0.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord0.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord1.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord1.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord2.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord2.zw).xyz)*0.125;
|
||||
|
||||
c0+= texture2D(sampler0,v_texcoord3.xy).xyz;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.zy).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.xw).xyz)*0.25;
|
||||
c0+=(texture2D(sampler0,v_texcoord3.zw).xyz)*0.125;
|
||||
c0*=0.153846153846;
|
||||
|
||||
c1=RGBtoYIQ*c0;
|
||||
|
||||
c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz);
|
||||
|
||||
gl_FragColor.rgb=YIQtoRGB*c1;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position=a_position;
|
||||
|
||||
v_texcoord0=a_texcoord0.xyxy+vec4(-0.5,-0.5,-1.5,-1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord1=a_texcoord0.xyxy+vec4( 0.5,-0.5, 1.5,-1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord2=a_texcoord0.xyxy+vec4(-0.5, 0.5,-1.5, 1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord3=a_texcoord0.xyxy+vec4( 0.5, 0.5, 1.5, 1.5)*u_texelDelta.xyxy;
|
||||
}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform vec2 u_texelDelta;
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position=a_position;
|
||||
|
||||
v_texcoord0=a_texcoord0.xyxy+vec4(-0.5,-0.5,-1.5,-1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord1=a_texcoord0.xyxy+vec4( 0.5,-0.5, 1.5,-1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord2=a_texcoord0.xyxy+vec4(-0.5, 0.5,-1.5, 1.5)*u_texelDelta.xyxy;
|
||||
v_texcoord3=a_texcoord0.xyxy+vec4( 0.5, 0.5, 1.5, 1.5)*u_texelDelta.xyxy;
|
||||
}
|
||||
|
||||
@@ -1,39 +1,36 @@
|
||||
// Natural Vision Shader with removed blur.
|
||||
|
||||
// by ShadX (Modded by SimoneT and Leopard20)
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec4 v_texcoord0;
|
||||
varying vec4 v_texcoord1;
|
||||
varying vec4 v_texcoord2;
|
||||
varying vec4 v_texcoord3;
|
||||
|
||||
const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212,
|
||||
0.587,-0.275,-0.523,
|
||||
0.114,-0.321, 0.311);
|
||||
|
||||
const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0,
|
||||
0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523,
|
||||
0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149);
|
||||
|
||||
const vec3 val00 = vec3( 1.2, 1.2, 1.2);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c0,c1;
|
||||
|
||||
c0 = texture2D(sampler0,v_texcoord0.xy).xyz;
|
||||
|
||||
c1=RGBtoYIQ*c0;
|
||||
|
||||
c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz);
|
||||
|
||||
gl_FragColor.rgb=YIQtoRGB*c1;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Natural Vision Shader, modified to use in PPSSPP.
|
||||
|
||||
// by ShadX (Modded by SimoneT)
|
||||
// http://forums.ngemu.com/showthread.php?t=76098
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
const mat3 RGBtoYIQ = mat3(0.299, 0.596, 0.212,
|
||||
0.587,-0.275,-0.523,
|
||||
0.114,-0.321, 0.311);
|
||||
|
||||
const mat3 YIQtoRGB = mat3(1.0, 1.0, 1.0,
|
||||
0.95568806036115671171,-0.27158179694405859326,-1.1081773266826619523,
|
||||
0.61985809445637075388,-0.64687381613840131330, 1.7050645599191817149);
|
||||
|
||||
const vec3 val00 = vec3( 1.2, 1.2, 1.2);
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 c0,c1;
|
||||
|
||||
c0 = texture2D(sampler0,v_texcoord0).xyz;
|
||||
|
||||
c1=RGBtoYIQ*c0;
|
||||
|
||||
c1=vec3(pow(c1.x,val00.x),c1.yz*val00.yz);
|
||||
|
||||
gl_FragColor.rgb=YIQtoRGB*c1;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
15
system/PPSSPP/shaders/naturalA.vsh
Normal file
15
system/PPSSPP/shaders/naturalA.vsh
Normal file
@@ -0,0 +1,15 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position=a_position;
|
||||
v_texcoord0=a_texcoord0;
|
||||
}
|
||||
58
system/PPSSPP/shaders/psp_color.fsh
Normal file
58
system/PPSSPP/shaders/psp_color.fsh
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
psp_color vertex shader
|
||||
|
||||
Original code written by hunterk, modified by Pokefan531 and
|
||||
released into the public domain
|
||||
|
||||
'Ported' (i.e. copy/paste) to PPSSPP format by jdgleaver
|
||||
|
||||
This program is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the Free
|
||||
Software Foundation; either version 2 of the License, or (at your option)
|
||||
any later version.
|
||||
|
||||
Notes: This shader replicates the LCD dynamics of the PSP 1000 and PSP 2000
|
||||
*/
|
||||
|
||||
//================
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
// For android, use this instead...
|
||||
//precision highp float;
|
||||
//precision highp int;
|
||||
//
|
||||
#endif
|
||||
|
||||
//================
|
||||
#define target_gamma 2.21
|
||||
#define display_gamma 2.2
|
||||
#define r 0.98
|
||||
#define g 0.795
|
||||
#define b 0.98
|
||||
#define rg 0.04
|
||||
#define rb 0.01
|
||||
#define gr 0.20
|
||||
#define gb 0.01
|
||||
#define br -0.18
|
||||
#define bg 0.165
|
||||
|
||||
//================
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
//================
|
||||
void main()
|
||||
{
|
||||
// Apply colour correction
|
||||
vec3 screen = pow(texture2D(sampler0, v_texcoord0.xy).rgb, vec3(target_gamma));
|
||||
// screen = clamp(screen, 0.0, 1.0);
|
||||
screen = pow(
|
||||
mat3(r, rg, rb,
|
||||
gr, g, gb,
|
||||
br, bg, b) * screen,
|
||||
vec3(1.0 / display_gamma)
|
||||
);
|
||||
|
||||
gl_FragColor = vec4(screen, 1.0);
|
||||
}
|
||||
@@ -1,30 +1,29 @@
|
||||
// Advanced Scanlines (CRT) shader, created to use in PPSSPP.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
float amount = 1.0; // suitable range = 0.0 - 1.0
|
||||
float intensity = 0.5; // suitable range = 0.0 - 1.0
|
||||
|
||||
void main()
|
||||
{
|
||||
float pos0 = ((v_texcoord0.y + 1.0) * 170.0*amount);
|
||||
float pos1 = cos((fract( pos0 ) - 0.5)*3.1415926*intensity)*1.5;
|
||||
vec4 rgb = texture2D( sampler0, v_texcoord0 );
|
||||
|
||||
// slight contrast curve
|
||||
vec4 color = rgb*0.5+0.5*rgb*rgb*1.2;
|
||||
|
||||
// color tint
|
||||
color *= vec4(0.9,1.0,0.7, 0.0);
|
||||
|
||||
// vignette
|
||||
color *= 1.1 - 0.6 * (dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5) * 2.0);
|
||||
|
||||
gl_FragColor.rgba = mix(vec4(0,0,0,0), color, pos1);
|
||||
}
|
||||
// Advanced Scanlines (CRT) shader, created to use in PPSSPP.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
uniform vec4 u_setting;
|
||||
|
||||
void main()
|
||||
{
|
||||
float pos0 = ((v_texcoord0.y + 1.0) * 170.0*u_setting.x);
|
||||
float pos1 = cos((fract( pos0 ) - 0.5)*3.1415926*u_setting.y)*1.5;
|
||||
vec4 rgb = texture2D( sampler0, v_texcoord0 );
|
||||
|
||||
// slight contrast curve
|
||||
vec4 color = rgb*0.5+0.5*rgb*rgb*1.2;
|
||||
|
||||
// color tint
|
||||
color *= vec4(0.9,1.0,0.7, 0.0);
|
||||
|
||||
// vignette
|
||||
color *= 1.1 - 0.6 * (dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5) * 2.0);
|
||||
|
||||
gl_FragColor.rgba = mix(vec4(0,0,0,0), color, pos1);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
// Simple sharpen shader; created to use in PPSSPP
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
float amount = 1.5;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*7.0*amount;
|
||||
color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*7.0*amount;
|
||||
gl_FragColor.rgb = color;
|
||||
}
|
||||
// Simple sharpen shader; created to use in PPSSPP
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
uniform vec4 u_setting;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*7.0*u_setting.x;
|
||||
color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*7.0*u_setting.x;
|
||||
gl_FragColor.rgb = color;
|
||||
}
|
||||
|
||||
279
system/PPSSPP/shaders/tex_4xbrz.csh
Normal file
279
system/PPSSPP/shaders/tex_4xbrz.csh
Normal file
@@ -0,0 +1,279 @@
|
||||
// 4xBRZ shader - Copyright (C) 2014-2016 DeSmuME team (GPL2+)
|
||||
// Hyllian's xBR-vertex code and texel mapping
|
||||
// Copyright (C) 2011/2016 Hyllian - sergiogdb@gmail.com
|
||||
#define BLEND_ALPHA 1
|
||||
#define BLEND_NONE 0
|
||||
#define BLEND_NORMAL 1
|
||||
#define BLEND_DOMINANT 2
|
||||
#define LUMINANCE_WEIGHT 1.0
|
||||
#define EQUAL_COLOR_TOLERANCE 30.0/255.0
|
||||
#define STEEP_DIRECTION_THRESHOLD 2.2
|
||||
#define DOMINANT_DIRECTION_THRESHOLD 3.6
|
||||
|
||||
float reduce(vec4 color) {
|
||||
return dot(color.rgb, vec3(65536.0, 256.0, 1.0));
|
||||
}
|
||||
|
||||
float DistYCbCr(vec4 pixA, vec4 pixB) {
|
||||
// https://en.wikipedia.org/wiki/YCbCr#ITU-R_BT.2020_conversion
|
||||
const vec3 K = vec3(0.2627, 0.6780, 0.0593);
|
||||
const mat3 MATRIX = mat3(K,
|
||||
-.5 * K.r / (1.0 - K.b), -.5 * K.g / (1.0 - K.b), .5,
|
||||
.5, -.5 * K.g / (1.0 - K.r), -.5 * K.b / (1.0 - K.r));
|
||||
vec4 diff = pixA - pixB;
|
||||
vec3 YCbCr = diff.rgb * MATRIX;
|
||||
YCbCr.x *= LUMINANCE_WEIGHT;
|
||||
float d = length(YCbCr);
|
||||
return sqrt(pixA.a * pixB.a * d * d + diff.a * diff.a);
|
||||
}
|
||||
|
||||
bool IsPixEqual(const vec4 pixA, const vec4 pixB) {
|
||||
return (DistYCbCr(pixA, pixB) < EQUAL_COLOR_TOLERANCE);
|
||||
}
|
||||
|
||||
bool IsBlendingNeeded(const ivec4 blend) {
|
||||
ivec4 diff = blend - ivec4(BLEND_NONE);
|
||||
return diff.x != 0 || diff.y != 0 || diff.z != 0 || diff.w != 0;
|
||||
}
|
||||
|
||||
vec4 applyScalingf(uvec2 origxy, uvec2 xy) {
|
||||
float dx = 1.0 / params.width;
|
||||
float dy = 1.0 / params.height;
|
||||
|
||||
// A1 B1 C1
|
||||
// A0 A B C C4
|
||||
// D0 D E F F4
|
||||
// G0 G H I I4
|
||||
// G5 H5 I5
|
||||
|
||||
uvec4 t1 = uvec4(origxy.x - 1, origxy.x, origxy.x + 1, origxy.y - 2); // A1 B1 C1
|
||||
uvec4 t2 = uvec4(origxy.x - 1, origxy.x, origxy.x + 1, origxy.y - 1); // A B C
|
||||
uvec4 t3 = uvec4(origxy.x - 1, origxy.x, origxy.x + 1, origxy.y + 0); // D E F
|
||||
uvec4 t4 = uvec4(origxy.x - 1, origxy.x, origxy.x + 1, origxy.y + 1); // G H I
|
||||
uvec4 t5 = uvec4(origxy.x - 1, origxy.x, origxy.x + 1, origxy.y + 2); // G5 H5 I5
|
||||
uvec4 t6 = uvec4(origxy.x - 2, origxy.y - 1, origxy.y, origxy.y + 1); // A0 D0 G0
|
||||
uvec4 t7 = uvec4(origxy.x + 2, origxy.y - 1, origxy.y, origxy.y + 1); // C4 F4 I4
|
||||
|
||||
vec2 f = fract(vec2(float(xy.x) / float(params.scale), float(xy.y) / float(params.scale)));
|
||||
|
||||
//---------------------------------------
|
||||
// Input Pixel Mapping: |21|22|23|
|
||||
// 19|06|07|08|09
|
||||
// 18|05|00|01|10
|
||||
// 17|04|03|02|11
|
||||
// |15|14|13|
|
||||
|
||||
vec4 src[25];
|
||||
|
||||
src[21] = readColorf(t1.xw);
|
||||
src[22] = readColorf(t1.yw);
|
||||
src[23] = readColorf(t1.zw);
|
||||
src[ 6] = readColorf(t2.xw);
|
||||
src[ 7] = readColorf(t2.yw);
|
||||
src[ 8] = readColorf(t2.zw);
|
||||
src[ 5] = readColorf(t3.xw);
|
||||
src[ 0] = readColorf(t3.yw);
|
||||
src[ 1] = readColorf(t3.zw);
|
||||
src[ 4] = readColorf(t4.xw);
|
||||
src[ 3] = readColorf(t4.yw);
|
||||
src[ 2] = readColorf(t4.zw);
|
||||
src[15] = readColorf(t5.xw);
|
||||
src[14] = readColorf(t5.yw);
|
||||
src[13] = readColorf(t5.zw);
|
||||
src[19] = readColorf(t6.xy);
|
||||
src[18] = readColorf(t6.xz);
|
||||
src[17] = readColorf(t6.xw);
|
||||
src[ 9] = readColorf(t7.xy);
|
||||
src[10] = readColorf(t7.xz);
|
||||
src[11] = readColorf(t7.xw);
|
||||
|
||||
float v[9];
|
||||
v[0] = reduce(src[0]);
|
||||
v[1] = reduce(src[1]);
|
||||
v[2] = reduce(src[2]);
|
||||
v[3] = reduce(src[3]);
|
||||
v[4] = reduce(src[4]);
|
||||
v[5] = reduce(src[5]);
|
||||
v[6] = reduce(src[6]);
|
||||
v[7] = reduce(src[7]);
|
||||
v[8] = reduce(src[8]);
|
||||
|
||||
ivec4 blendResult = ivec4(BLEND_NONE);
|
||||
|
||||
// Preprocess corners
|
||||
// Pixel Tap Mapping: --|--|--|--|--
|
||||
// --|--|07|08|--
|
||||
// --|05|00|01|10
|
||||
// --|04|03|02|11
|
||||
// --|--|14|13|--
|
||||
// Corner (1, 1)
|
||||
if ( ((v[0] == v[1] && v[3] == v[2]) || (v[0] == v[3] && v[1] == v[2])) == false) {
|
||||
float dist_03_01 = DistYCbCr(src[ 4], src[ 0]) + DistYCbCr(src[ 0], src[ 8]) + DistYCbCr(src[14], src[ 2]) + DistYCbCr(src[ 2], src[10]) + (4.0 * DistYCbCr(src[ 3], src[ 1]));
|
||||
float dist_00_02 = DistYCbCr(src[ 5], src[ 3]) + DistYCbCr(src[ 3], src[13]) + DistYCbCr(src[ 7], src[ 1]) + DistYCbCr(src[ 1], src[11]) + (4.0 * DistYCbCr(src[ 0], src[ 2]));
|
||||
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_03_01) < dist_00_02;
|
||||
blendResult[2] = ((dist_03_01 < dist_00_02) && (v[0] != v[1]) && (v[0] != v[3])) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
|
||||
}
|
||||
|
||||
// Pixel Tap Mapping: --|--|--|--|--
|
||||
// --|06|07|--|--
|
||||
// 18|05|00|01|--
|
||||
// 17|04|03|02|--
|
||||
// --|15|14|--|--
|
||||
// Corner (0, 1)
|
||||
if ( ((v[5] == v[0] && v[4] == v[3]) || (v[5] == v[4] && v[0] == v[3])) == false) {
|
||||
float dist_04_00 = DistYCbCr(src[17], src[ 5]) + DistYCbCr(src[ 5], src[ 7]) + DistYCbCr(src[15], src[ 3]) + DistYCbCr(src[ 3], src[ 1]) + (4.0 * DistYCbCr(src[ 4], src[ 0]));
|
||||
float dist_05_03 = DistYCbCr(src[18], src[ 4]) + DistYCbCr(src[ 4], src[14]) + DistYCbCr(src[ 6], src[ 0]) + DistYCbCr(src[ 0], src[ 2]) + (4.0 * DistYCbCr(src[ 5], src[ 3]));
|
||||
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_05_03) < dist_04_00;
|
||||
blendResult[3] = ((dist_04_00 > dist_05_03) && (v[0] != v[5]) && (v[0] != v[3])) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
|
||||
}
|
||||
|
||||
// Pixel Tap Mapping: --|--|22|23|--
|
||||
// --|06|07|08|09
|
||||
// --|05|00|01|10
|
||||
// --|--|03|02|--
|
||||
// --|--|--|--|--
|
||||
// Corner (1, 0)
|
||||
if ( ((v[7] == v[8] && v[0] == v[1]) || (v[7] == v[0] && v[8] == v[1])) == false) {
|
||||
float dist_00_08 = DistYCbCr(src[ 5], src[ 7]) + DistYCbCr(src[ 7], src[23]) + DistYCbCr(src[ 3], src[ 1]) + DistYCbCr(src[ 1], src[ 9]) + (4.0 * DistYCbCr(src[ 0], src[ 8]));
|
||||
float dist_07_01 = DistYCbCr(src[ 6], src[ 0]) + DistYCbCr(src[ 0], src[ 2]) + DistYCbCr(src[22], src[ 8]) + DistYCbCr(src[ 8], src[10]) + (4.0 * DistYCbCr(src[ 7], src[ 1]));
|
||||
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_07_01) < dist_00_08;
|
||||
blendResult[1] = ((dist_00_08 > dist_07_01) && (v[0] != v[7]) && (v[0] != v[1])) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
|
||||
}
|
||||
|
||||
// Pixel Tap Mapping: --|21|22|--|--
|
||||
// 19|06|07|08|--
|
||||
// 18|05|00|01|--
|
||||
// --|04|03|--|--
|
||||
// --|--|--|--|--
|
||||
// Corner (0, 0)
|
||||
if ( ((v[6] == v[7] && v[5] == v[0]) || (v[6] == v[5] && v[7] == v[0])) == false) {
|
||||
float dist_05_07 = DistYCbCr(src[18], src[ 6]) + DistYCbCr(src[ 6], src[22]) + DistYCbCr(src[ 4], src[ 0]) + DistYCbCr(src[ 0], src[ 8]) + (4.0 * DistYCbCr(src[ 5], src[ 7]));
|
||||
float dist_06_00 = DistYCbCr(src[19], src[ 5]) + DistYCbCr(src[ 5], src[ 3]) + DistYCbCr(src[21], src[ 7]) + DistYCbCr(src[ 7], src[ 1]) + (4.0 * DistYCbCr(src[ 6], src[ 0]));
|
||||
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_05_07) < dist_06_00;
|
||||
blendResult[0] = ((dist_05_07 < dist_06_00) && (v[0] != v[5]) && (v[0] != v[7])) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
|
||||
}
|
||||
|
||||
vec4 dst[16];
|
||||
dst[ 0] = src[0];
|
||||
dst[ 1] = src[0];
|
||||
dst[ 2] = src[0];
|
||||
dst[ 3] = src[0];
|
||||
dst[ 4] = src[0];
|
||||
dst[ 5] = src[0];
|
||||
dst[ 6] = src[0];
|
||||
dst[ 7] = src[0];
|
||||
dst[ 8] = src[0];
|
||||
dst[ 9] = src[0];
|
||||
dst[10] = src[0];
|
||||
dst[11] = src[0];
|
||||
dst[12] = src[0];
|
||||
dst[13] = src[0];
|
||||
dst[14] = src[0];
|
||||
dst[15] = src[0];
|
||||
|
||||
// Scale pixel
|
||||
if (IsBlendingNeeded(blendResult) == true) {
|
||||
float dist_01_04 = DistYCbCr(src[1], src[4]);
|
||||
float dist_03_08 = DistYCbCr(src[3], src[8]);
|
||||
bool haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_01_04 <= dist_03_08) && (v[0] != v[4]) && (v[5] != v[4]);
|
||||
bool haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_03_08 <= dist_01_04) && (v[0] != v[8]) && (v[7] != v[8]);
|
||||
bool needBlend = (blendResult[2] != BLEND_NONE);
|
||||
bool doLineBlend = ( blendResult[2] >= BLEND_DOMINANT ||
|
||||
((blendResult[1] != BLEND_NONE && !IsPixEqual(src[0], src[4])) ||
|
||||
(blendResult[3] != BLEND_NONE && !IsPixEqual(src[0], src[8])) ||
|
||||
(IsPixEqual(src[4], src[3]) && IsPixEqual(src[3], src[2]) && IsPixEqual(src[2], src[1]) && IsPixEqual(src[1], src[8]) && IsPixEqual(src[0], src[2]) == false) ) == false );
|
||||
|
||||
vec4 blendPix = ( DistYCbCr(src[0], src[1]) <= DistYCbCr(src[0], src[3]) ) ? src[1] : src[3];
|
||||
dst[ 2] = mix(dst[ 2], blendPix, (needBlend && doLineBlend) ? ((haveShallowLine) ? ((haveSteepLine) ? 1.0/3.0 : 0.25) : ((haveSteepLine) ? 0.25 : 0.00)) : 0.00);
|
||||
dst[ 9] = mix(dst[ 9], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.25 : 0.00);
|
||||
dst[10] = mix(dst[10], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.75 : 0.00);
|
||||
dst[11] = mix(dst[11], blendPix, (needBlend) ? ((doLineBlend) ? ((haveSteepLine) ? 1.00 : ((haveShallowLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[12] = mix(dst[12], blendPix, (needBlend) ? ((doLineBlend) ? 1.00 : 0.6848532563) : 0.00);
|
||||
dst[13] = mix(dst[13], blendPix, (needBlend) ? ((doLineBlend) ? ((haveShallowLine) ? 1.00 : ((haveSteepLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[14] = mix(dst[14], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.75 : 0.00);
|
||||
dst[15] = mix(dst[15], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.25 : 0.00);
|
||||
|
||||
dist_01_04 = DistYCbCr(src[7], src[2]);
|
||||
dist_03_08 = DistYCbCr(src[1], src[6]);
|
||||
haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_01_04 <= dist_03_08) && (v[0] != v[2]) && (v[3] != v[2]);
|
||||
haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_03_08 <= dist_01_04) && (v[0] != v[6]) && (v[5] != v[6]);
|
||||
needBlend = (blendResult[1] != BLEND_NONE);
|
||||
doLineBlend = ( blendResult[1] >= BLEND_DOMINANT ||
|
||||
!((blendResult[0] != BLEND_NONE && !IsPixEqual(src[0], src[2])) ||
|
||||
(blendResult[2] != BLEND_NONE && !IsPixEqual(src[0], src[6])) ||
|
||||
(IsPixEqual(src[2], src[1]) && IsPixEqual(src[1], src[8]) && IsPixEqual(src[8], src[7]) && IsPixEqual(src[7], src[6]) && !IsPixEqual(src[0], src[8])) ) );
|
||||
|
||||
blendPix = ( DistYCbCr(src[0], src[7]) <= DistYCbCr(src[0], src[1]) ) ? src[7] : src[1];
|
||||
dst[ 1] = mix(dst[ 1], blendPix, (needBlend && doLineBlend) ? ((haveShallowLine) ? ((haveSteepLine) ? 1.0/3.0 : 0.25) : ((haveSteepLine) ? 0.25 : 0.00)) : 0.00);
|
||||
dst[ 6] = mix(dst[ 6], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.25 : 0.00);
|
||||
dst[ 7] = mix(dst[ 7], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.75 : 0.00);
|
||||
dst[ 8] = mix(dst[ 8], blendPix, (needBlend) ? ((doLineBlend) ? ((haveSteepLine) ? 1.00 : ((haveShallowLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[ 9] = mix(dst[ 9], blendPix, (needBlend) ? ((doLineBlend) ? 1.00 : 0.6848532563) : 0.00);
|
||||
dst[10] = mix(dst[10], blendPix, (needBlend) ? ((doLineBlend) ? ((haveShallowLine) ? 1.00 : ((haveSteepLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[11] = mix(dst[11], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.75 : 0.00);
|
||||
dst[12] = mix(dst[12], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.25 : 0.00);
|
||||
|
||||
dist_01_04 = DistYCbCr(src[5], src[8]);
|
||||
dist_03_08 = DistYCbCr(src[7], src[4]);
|
||||
haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_01_04 <= dist_03_08) && (v[0] != v[8]) && (v[1] != v[8]);
|
||||
haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_03_08 <= dist_01_04) && (v[0] != v[4]) && (v[3] != v[4]);
|
||||
needBlend = (blendResult[0] != BLEND_NONE);
|
||||
doLineBlend = ( blendResult[0] >= BLEND_DOMINANT ||
|
||||
!((blendResult[3] != BLEND_NONE && !IsPixEqual(src[0], src[8])) ||
|
||||
(blendResult[1] != BLEND_NONE && !IsPixEqual(src[0], src[4])) ||
|
||||
(IsPixEqual(src[8], src[7]) && IsPixEqual(src[7], src[6]) && IsPixEqual(src[6], src[5]) && IsPixEqual(src[5], src[4]) && !IsPixEqual(src[0], src[6])) ) );
|
||||
|
||||
blendPix = ( DistYCbCr(src[0], src[5]) <= DistYCbCr(src[0], src[7]) ) ? src[5] : src[7];
|
||||
dst[ 0] = mix(dst[ 0], blendPix, (needBlend && doLineBlend) ? ((haveShallowLine) ? ((haveSteepLine) ? 1.0/3.0 : 0.25) : ((haveSteepLine) ? 0.25 : 0.00)) : 0.00);
|
||||
dst[15] = mix(dst[15], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.25 : 0.00);
|
||||
dst[ 4] = mix(dst[ 4], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.75 : 0.00);
|
||||
dst[ 5] = mix(dst[ 5], blendPix, (needBlend) ? ((doLineBlend) ? ((haveSteepLine) ? 1.00 : ((haveShallowLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[ 6] = mix(dst[ 6], blendPix, (needBlend) ? ((doLineBlend) ? 1.00 : 0.6848532563) : 0.00);
|
||||
dst[ 7] = mix(dst[ 7], blendPix, (needBlend) ? ((doLineBlend) ? ((haveShallowLine) ? 1.00 : ((haveSteepLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[ 8] = mix(dst[ 8], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.75 : 0.00);
|
||||
dst[ 9] = mix(dst[ 9], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.25 : 0.00);
|
||||
|
||||
dist_01_04 = DistYCbCr(src[3], src[6]);
|
||||
dist_03_08 = DistYCbCr(src[5], src[2]);
|
||||
haveShallowLine = (STEEP_DIRECTION_THRESHOLD * dist_01_04 <= dist_03_08) && (v[0] != v[6]) && (v[7] != v[6]);
|
||||
haveSteepLine = (STEEP_DIRECTION_THRESHOLD * dist_03_08 <= dist_01_04) && (v[0] != v[2]) && (v[1] != v[2]);
|
||||
needBlend = (blendResult[3] != BLEND_NONE);
|
||||
doLineBlend = ( blendResult[3] >= BLEND_DOMINANT ||
|
||||
!((blendResult[2] != BLEND_NONE && !IsPixEqual(src[0], src[6])) ||
|
||||
(blendResult[0] != BLEND_NONE && !IsPixEqual(src[0], src[2])) ||
|
||||
(IsPixEqual(src[6], src[5]) && IsPixEqual(src[5], src[4]) && IsPixEqual(src[4], src[3]) && IsPixEqual(src[3], src[2]) && !IsPixEqual(src[0], src[4])) ) );
|
||||
|
||||
blendPix = ( DistYCbCr(src[0], src[3]) <= DistYCbCr(src[0], src[5]) ) ? src[3] : src[5];
|
||||
dst[ 3] = mix(dst[ 3], blendPix, (needBlend && doLineBlend) ? ((haveShallowLine) ? ((haveSteepLine) ? 1.0/3.0 : 0.25) : ((haveSteepLine) ? 0.25 : 0.00)) : 0.00);
|
||||
dst[12] = mix(dst[12], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.25 : 0.00);
|
||||
dst[13] = mix(dst[13], blendPix, (needBlend && doLineBlend && haveSteepLine) ? 0.75 : 0.00);
|
||||
dst[14] = mix(dst[14], blendPix, (needBlend) ? ((doLineBlend) ? ((haveSteepLine) ? 1.00 : ((haveShallowLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[15] = mix(dst[15], blendPix, (needBlend) ? ((doLineBlend) ? 1.00 : 0.6848532563) : 0.00);
|
||||
dst[ 4] = mix(dst[ 4], blendPix, (needBlend) ? ((doLineBlend) ? ((haveShallowLine) ? 1.00 : ((haveSteepLine) ? 0.75 : 0.50)) : 0.08677704501) : 0.00);
|
||||
dst[ 5] = mix(dst[ 5], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.75 : 0.00);
|
||||
dst[ 6] = mix(dst[ 6], blendPix, (needBlend && doLineBlend && haveShallowLine) ? 0.25 : 0.00);
|
||||
}
|
||||
|
||||
// select output pixel
|
||||
vec4 res = mix(mix(mix(mix(dst[ 6], dst[ 7], step(0.25, f.x)),
|
||||
mix(dst[ 8], dst[ 9], step(0.75, f.x)),
|
||||
step(0.50, f.x)),
|
||||
mix(mix(dst[ 5], dst[ 0], step(0.25, f.x)),
|
||||
mix(dst[ 1], dst[10], step(0.75, f.x)),
|
||||
step(0.50, f.x)),
|
||||
step(0.25, f.y)),
|
||||
mix(mix(mix(dst[ 4], dst[ 3], step(0.25, f.x)),
|
||||
mix(dst[ 2], dst[11], step(0.75, f.x)),
|
||||
step(0.50, f.x)),
|
||||
mix(mix(dst[15], dst[14], step(0.25, f.x)),
|
||||
mix(dst[13], dst[12], step(0.75, f.x)),
|
||||
step(0.50, f.x)),
|
||||
step(0.75, f.y)),
|
||||
step(0.50, f.y));
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
uint applyScalingu(uvec2 origxy, uvec2 xy) {
|
||||
return packUnorm4x8(applyScalingf(origxy, xy));
|
||||
}
|
||||
117
system/PPSSPP/shaders/tex_mmpx.csh
Normal file
117
system/PPSSPP/shaders/tex_mmpx.csh
Normal file
@@ -0,0 +1,117 @@
|
||||
/* MMPX.glc
|
||||
Copyright 2020 Morgan McGuire & Mara Gagiu.
|
||||
Provided under the Open Source MIT license https://opensource.org/licenses/MIT
|
||||
|
||||
See js-demo.html for the commented source code.
|
||||
This is an optimized GLSL port of that version
|
||||
by Morgan McGuire and Mara Gagiu.
|
||||
*/
|
||||
|
||||
#define ABGR8 uint
|
||||
|
||||
ABGR8 src(int x, int y) {
|
||||
return readColoru(uvec2(clamp(x, 0, params.width - 1), clamp(y, 0, params.height - 1)));
|
||||
}
|
||||
|
||||
uint luma(ABGR8 C) {
|
||||
uint alpha = (C & 0xFF000000u) >> 24;
|
||||
return (((C & 0x00FF0000u) >> 16) + ((C & 0x0000FF00u) >> 8) + (C & 0x000000FFu) + 1u) * (256u - alpha);
|
||||
}
|
||||
|
||||
bool all_eq2(ABGR8 B, ABGR8 A0, ABGR8 A1) {
|
||||
return ((B ^ A0) | (B ^ A1)) == 0u;
|
||||
}
|
||||
|
||||
bool all_eq3(ABGR8 B, ABGR8 A0, ABGR8 A1, ABGR8 A2) {
|
||||
return ((B ^ A0) | (B ^ A1) | (B ^ A2)) == 0u;
|
||||
}
|
||||
|
||||
bool all_eq4(ABGR8 B, ABGR8 A0, ABGR8 A1, ABGR8 A2, ABGR8 A3) {
|
||||
return ((B ^ A0) | (B ^ A1) | (B ^ A2) | (B ^ A3)) == 0u;
|
||||
}
|
||||
|
||||
bool any_eq3(ABGR8 B, ABGR8 A0, ABGR8 A1, ABGR8 A2) {
|
||||
return B == A0 || B == A1 || B == A2;
|
||||
}
|
||||
|
||||
bool none_eq2(ABGR8 B, ABGR8 A0, ABGR8 A1) {
|
||||
return (B != A0) && (B != A1);
|
||||
}
|
||||
|
||||
bool none_eq4(ABGR8 B, ABGR8 A0, ABGR8 A1, ABGR8 A2, ABGR8 A3) {
|
||||
return B != A0 && B != A1 && B != A2 && B != A3;
|
||||
}
|
||||
|
||||
uint applyScalingu(uvec2 origxy, uvec2 xy) {
|
||||
int srcX = int(origxy.x);
|
||||
int srcY = int(origxy.y);
|
||||
|
||||
ABGR8 A = src(srcX - 1, srcY - 1), B = src(srcX, srcY - 1), C = src(srcX + 1, srcY - 1);
|
||||
ABGR8 D = src(srcX - 1, srcY + 0), E = src(srcX, srcY + 0), F = src(srcX + 1, srcY + 0);
|
||||
ABGR8 G = src(srcX - 1, srcY + 1), H = src(srcX, srcY + 1), I = src(srcX + 1, srcY + 1);
|
||||
|
||||
ABGR8 J = E, K = E, L = E, M = E;
|
||||
|
||||
if (((A ^ E) | (B ^ E) | (C ^ E) | (D ^ E) | (F ^ E) | (G ^ E) | (H ^ E) | (I ^ E)) != 0u) {
|
||||
ABGR8 P = src(srcX, srcY - 2), S = src(srcX, srcY + 2);
|
||||
ABGR8 Q = src(srcX - 2, srcY), R = src(srcX + 2, srcY);
|
||||
ABGR8 Bl = luma(B), Dl = luma(D), El = luma(E), Fl = luma(F), Hl = luma(H);
|
||||
|
||||
// 1:1 slope rules
|
||||
if ((D == B && D != H && D != F) && (El >= Dl || E == A) && any_eq3(E, A, C, G) && ((El < Dl) || A != D || E != P || E != Q)) J = D;
|
||||
if ((B == F && B != D && B != H) && (El >= Bl || E == C) && any_eq3(E, A, C, I) && ((El < Bl) || C != B || E != P || E != R)) K = B;
|
||||
if ((H == D && H != F && H != B) && (El >= Hl || E == G) && any_eq3(E, A, G, I) && ((El < Hl) || G != H || E != S || E != Q)) L = H;
|
||||
if ((F == H && F != B && F != D) && (El >= Fl || E == I) && any_eq3(E, C, G, I) && ((El < Fl) || I != H || E != R || E != S)) M = F;
|
||||
|
||||
// Intersection rules
|
||||
if ((E != F && all_eq4(E, C, I, D, Q) && all_eq2(F, B, H)) && (F != src(srcX + 3, srcY))) K = M = F;
|
||||
if ((E != D && all_eq4(E, A, G, F, R) && all_eq2(D, B, H)) && (D != src(srcX - 3, srcY))) J = L = D;
|
||||
if ((E != H && all_eq4(E, G, I, B, P) && all_eq2(H, D, F)) && (H != src(srcX, srcY + 3))) L = M = H;
|
||||
if ((E != B && all_eq4(E, A, C, H, S) && all_eq2(B, D, F)) && (B != src(srcX, srcY - 3))) J = K = B;
|
||||
if (Bl < El && all_eq4(E, G, H, I, S) && none_eq4(E, A, D, C, F)) J = K = B;
|
||||
if (Hl < El && all_eq4(E, A, B, C, P) && none_eq4(E, D, G, I, F)) L = M = H;
|
||||
if (Fl < El && all_eq4(E, A, D, G, Q) && none_eq4(E, B, C, I, H)) K = M = F;
|
||||
if (Dl < El && all_eq4(E, C, F, I, R) && none_eq4(E, B, A, G, H)) J = L = D;
|
||||
|
||||
// 2:1 slope rules
|
||||
if (H != B) {
|
||||
if (H != A && H != E && H != C) {
|
||||
if (all_eq3(H, G, F, R) && none_eq2(H, D, src(srcX + 2, srcY - 1))) L = M;
|
||||
if (all_eq3(H, I, D, Q) && none_eq2(H, F, src(srcX - 2, srcY - 1))) M = L;
|
||||
}
|
||||
|
||||
if (B != I && B != G && B != E) {
|
||||
if (all_eq3(B, A, F, R) && none_eq2(B, D, src(srcX + 2, srcY + 1))) J = K;
|
||||
if (all_eq3(B, C, D, Q) && none_eq2(B, F, src(srcX - 2, srcY + 1))) K = J;
|
||||
}
|
||||
} // H !== B
|
||||
|
||||
if (F != D) {
|
||||
if (D != I && D != E && D != C) {
|
||||
if (all_eq3(D, A, H, S) && none_eq2(D, B, src(srcX + 1, srcY + 2))) J = L;
|
||||
if (all_eq3(D, G, B, P) && none_eq2(D, H, src(srcX + 1, srcY - 2))) L = J;
|
||||
}
|
||||
|
||||
if (F != E && F != A && F != G) {
|
||||
if (all_eq3(F, C, H, S) && none_eq2(F, B, src(srcX - 1, srcY + 2))) K = M;
|
||||
if (all_eq3(F, I, B, P) && none_eq2(F, H, src(srcX - 1, srcY - 2))) M = K;
|
||||
}
|
||||
} // F !== D
|
||||
} // not constant
|
||||
|
||||
// TODO: Write four pixels at once. For now, 1/4x speed.
|
||||
if ((xy.y & 1u) == 0u) {
|
||||
if ((xy.x & 1u) == 0u) {
|
||||
return J;
|
||||
}
|
||||
return K;
|
||||
}
|
||||
if ((xy.x & 1u) == 0u) {
|
||||
return L;
|
||||
}
|
||||
return M;
|
||||
}
|
||||
|
||||
vec4 applyScalingf(uvec2 origxy, uvec2 xy) {
|
||||
return unpackUnorm4x8(applyScalingu(origxy, xy));
|
||||
}
|
||||
@@ -1,120 +1,120 @@
|
||||
// Spline36 upscaling shader.
|
||||
// See issue #3921
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_position;
|
||||
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
|
||||
const vec2 HALF_PIXEL = vec2(0.5, 0.5);
|
||||
|
||||
float spline36_0_1(float x) {
|
||||
return ((13.0 / 11.0 * x - 453.0 / 209.0) * x - 3.0 / 209.0) * x + 1.0;
|
||||
}
|
||||
|
||||
float spline36_1_2(float x) {
|
||||
return ((-6.0 / 11.0 * x + 612.0 / 209.0) * x - 1038.0 / 209.0) * x + 540.0 / 209.0;
|
||||
}
|
||||
|
||||
float spline36_2_3(float x) {
|
||||
return ((1.0 / 11.0 * x - 159.0 / 209.0) * x + 434.0 / 209.0) * x - 384.0 / 209.0;
|
||||
}
|
||||
|
||||
vec4 rgb(int inputX, int inputY) {
|
||||
return texture2D(sampler0, (vec2(inputX, inputY) + HALF_PIXEL) * u_texelDelta);
|
||||
}
|
||||
|
||||
vec4 interpolateHorizontally(vec2 inputPos, ivec2 inputPosFloor, int dy) {
|
||||
float sumOfWeights = 0.0;
|
||||
vec4 sumOfWeightedPixel = vec4(0.0);
|
||||
|
||||
float x;
|
||||
float weight;
|
||||
|
||||
x = inputPos.x - float(inputPosFloor.x - 2);
|
||||
weight = spline36_2_3(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x - 2, inputPosFloor.y + dy);
|
||||
|
||||
--x;
|
||||
weight = spline36_1_2(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x - 1, inputPosFloor.y + dy);
|
||||
|
||||
--x;
|
||||
weight = spline36_0_1(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 0, inputPosFloor.y + dy);
|
||||
|
||||
x = 1.0 - x;
|
||||
weight = spline36_0_1(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 1, inputPosFloor.y + dy);
|
||||
|
||||
++x;
|
||||
weight = spline36_1_2(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 2, inputPosFloor.y + dy);
|
||||
|
||||
++x;
|
||||
weight = spline36_2_3(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 3, inputPosFloor.y + dy);
|
||||
|
||||
return sumOfWeightedPixel / sumOfWeights;
|
||||
}
|
||||
|
||||
vec4 process(vec2 outputPos) {
|
||||
vec2 inputPos = outputPos / u_texelDelta;
|
||||
ivec2 inputPosFloor = ivec2(inputPos);
|
||||
|
||||
// Vertical interporation
|
||||
float sumOfWeights = 0.0;
|
||||
vec4 sumOfWeightedPixel = vec4(0.0);
|
||||
|
||||
float weight;
|
||||
float y;
|
||||
|
||||
y = inputPos.y - float(inputPosFloor.y - 2);
|
||||
weight = spline36_2_3(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, -2);
|
||||
|
||||
--y;
|
||||
weight = spline36_1_2(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, -1);
|
||||
|
||||
--y;
|
||||
weight = spline36_0_1(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +0);
|
||||
|
||||
y = 1.0 - y;
|
||||
weight = spline36_0_1(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +1);
|
||||
|
||||
++y;
|
||||
weight = spline36_1_2(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +2);
|
||||
|
||||
++y;
|
||||
weight = spline36_2_3(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +3);
|
||||
|
||||
return vec4((sumOfWeightedPixel / sumOfWeights).xyz, 1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor.rgba = process(v_position);
|
||||
// Spline36 upscaling shader.
|
||||
// See issue #3921
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_position;
|
||||
|
||||
uniform vec2 u_texelDelta;
|
||||
uniform vec2 u_pixelDelta;
|
||||
|
||||
const vec2 HALF_PIXEL = vec2(0.5, 0.5);
|
||||
|
||||
float spline36_0_1(float x) {
|
||||
return ((13.0 / 11.0 * x - 453.0 / 209.0) * x - 3.0 / 209.0) * x + 1.0;
|
||||
}
|
||||
|
||||
float spline36_1_2(float x) {
|
||||
return ((-6.0 / 11.0 * x + 612.0 / 209.0) * x - 1038.0 / 209.0) * x + 540.0 / 209.0;
|
||||
}
|
||||
|
||||
float spline36_2_3(float x) {
|
||||
return ((1.0 / 11.0 * x - 159.0 / 209.0) * x + 434.0 / 209.0) * x - 384.0 / 209.0;
|
||||
}
|
||||
|
||||
vec4 rgb(int inputX, int inputY) {
|
||||
return texture2D(sampler0, (vec2(inputX, inputY) + HALF_PIXEL) * u_texelDelta);
|
||||
}
|
||||
|
||||
vec4 interpolateHorizontally(vec2 inputPos, ivec2 inputPosFloor, int dy) {
|
||||
float sumOfWeights = 0.0;
|
||||
vec4 sumOfWeightedPixel = vec4(0.0);
|
||||
|
||||
float x;
|
||||
float weight;
|
||||
|
||||
x = inputPos.x - float(inputPosFloor.x - 2);
|
||||
weight = spline36_2_3(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x - 2, inputPosFloor.y + dy);
|
||||
|
||||
--x;
|
||||
weight = spline36_1_2(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x - 1, inputPosFloor.y + dy);
|
||||
|
||||
--x;
|
||||
weight = spline36_0_1(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 0, inputPosFloor.y + dy);
|
||||
|
||||
x = 1.0 - x;
|
||||
weight = spline36_0_1(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 1, inputPosFloor.y + dy);
|
||||
|
||||
++x;
|
||||
weight = spline36_1_2(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 2, inputPosFloor.y + dy);
|
||||
|
||||
++x;
|
||||
weight = spline36_2_3(x);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * rgb(inputPosFloor.x + 3, inputPosFloor.y + dy);
|
||||
|
||||
return sumOfWeightedPixel / sumOfWeights;
|
||||
}
|
||||
|
||||
vec4 process(vec2 outputPos) {
|
||||
vec2 inputPos = outputPos / u_texelDelta;
|
||||
ivec2 inputPosFloor = ivec2(inputPos);
|
||||
|
||||
// Vertical interporation
|
||||
float sumOfWeights = 0.0;
|
||||
vec4 sumOfWeightedPixel = vec4(0.0);
|
||||
|
||||
float weight;
|
||||
float y;
|
||||
|
||||
y = inputPos.y - float(inputPosFloor.y - 2);
|
||||
weight = spline36_2_3(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, -2);
|
||||
|
||||
--y;
|
||||
weight = spline36_1_2(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, -1);
|
||||
|
||||
--y;
|
||||
weight = spline36_0_1(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +0);
|
||||
|
||||
y = 1.0 - y;
|
||||
weight = spline36_0_1(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +1);
|
||||
|
||||
++y;
|
||||
weight = spline36_1_2(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +2);
|
||||
|
||||
++y;
|
||||
weight = spline36_2_3(y);
|
||||
sumOfWeights += weight;
|
||||
sumOfWeightedPixel += weight * interpolateHorizontally(inputPos, inputPosFloor, +3);
|
||||
|
||||
return vec4((sumOfWeightedPixel / sumOfWeights).xyz, 1.0);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_FragColor.rgba = process(v_position);
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
|
||||
varying vec2 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
|
||||
v_position = a_texcoord0;
|
||||
}
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
attribute vec4 a_position;
|
||||
attribute vec2 a_texcoord0;
|
||||
|
||||
varying vec2 v_position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = a_position;
|
||||
|
||||
v_position = a_texcoord0;
|
||||
}
|
||||
|
||||
@@ -1,201 +1,201 @@
|
||||
/*
|
||||
AA shader 4.o / AA shader 4.o - filtro
|
||||
|
||||
Copyright (C) 2014 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// Modified as video aware smoothing effect for PPSSPP.
|
||||
// Some variable definitions had to be moved inside functions(and so repeated) due to glsl->hlsl auto translation failing.
|
||||
// Also auto translation fails with bool uniform, which is why u_video is defined as float.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform float u_video;
|
||||
|
||||
|
||||
//===========
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
const vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
vec3 texture2d (vec2 texcoord) {
|
||||
|
||||
float scale = 1.0;
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
}
|
||||
|
||||
vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale;
|
||||
vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale;
|
||||
|
||||
vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz;
|
||||
vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz;
|
||||
vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz;
|
||||
vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz;
|
||||
|
||||
float m1=dot(abs(s00-s22),dt)+0.001;
|
||||
float m2=dot(abs(s02-s20),dt)+0.001;
|
||||
|
||||
return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2);
|
||||
}
|
||||
vec3 texture2dd (vec2 texcoord) {
|
||||
|
||||
float scale = 1.0;
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
}
|
||||
|
||||
vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale;
|
||||
vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale;
|
||||
|
||||
vec3 c11 = texture2D(sampler0, texcoord ).xyz;
|
||||
vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz;
|
||||
vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz;
|
||||
vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz;
|
||||
vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz;
|
||||
vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz;
|
||||
vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz;
|
||||
vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz;
|
||||
vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz;
|
||||
|
||||
float d1=dot(abs(c00-c22),dt)+0.001;
|
||||
float d2=dot(abs(c20-c02),dt)+0.001;
|
||||
float m1=dot(abs(s00-s22),dt)+0.001;
|
||||
float m2=dot(abs(s02-s20),dt)+0.001;
|
||||
|
||||
vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2));
|
||||
|
||||
return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2));
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float scale = 7.0;
|
||||
bool filtro = false;
|
||||
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
filtro = true;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
filtro = false;
|
||||
}
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 size = vec2(480.0,272.0)*scale;
|
||||
vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale;
|
||||
|
||||
vec2 OGL2Pos = v_texcoord0 * size;
|
||||
vec2 fp = fract(OGL2Pos);
|
||||
vec2 dx = vec2(inv_size.x,0.0);
|
||||
vec2 dy = vec2(0.0, inv_size.y);
|
||||
vec2 g1 = vec2(inv_size.x,inv_size.y);
|
||||
vec2 g2 = vec2(-inv_size.x,inv_size.y);
|
||||
|
||||
vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size;
|
||||
|
||||
// Reading the texels
|
||||
vec3 C0 = texture2d(pC4 - g1);
|
||||
vec3 C1 = texture2d(pC4 - dy);
|
||||
vec3 C2 = texture2d(pC4 - g2);
|
||||
vec3 C3 = texture2d(pC4 - dx);
|
||||
vec3 C4 = texture2d(pC4 );
|
||||
vec3 C5 = texture2d(pC4 + dx);
|
||||
vec3 C6 = texture2d(pC4 + g2);
|
||||
vec3 C7 = texture2d(pC4 + dy);
|
||||
vec3 C8 = texture2d(pC4 + g1);
|
||||
|
||||
vec3 ul, ur, dl, dr;
|
||||
float m1, m2;
|
||||
|
||||
m1 = dot(abs(C0-C4),dt)+0.001;
|
||||
m2 = dot(abs(C1-C3),dt)+0.001;
|
||||
ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C1-C5),dt)+0.001;
|
||||
m2 = dot(abs(C2-C4),dt)+0.001;
|
||||
ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C3-C7),dt)+0.001;
|
||||
m2 = dot(abs(C6-C4),dt)+0.001;
|
||||
dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C4-C8),dt)+0.001;
|
||||
m2 = dot(abs(C5-C7),dt)+0.001;
|
||||
dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2);
|
||||
|
||||
vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)));
|
||||
|
||||
if(filtro){
|
||||
vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y));
|
||||
|
||||
inv_size = vec2(2.0/480.0,2.0/272.0)/scale;;
|
||||
|
||||
dx = vec2(inv_size.x,0.0);
|
||||
dy = vec2(0.0,inv_size.y);
|
||||
g1 = vec2( inv_size.x,inv_size.y);
|
||||
g2 = vec2(-inv_size.x,inv_size.y);
|
||||
pC4 = v_texcoord0;
|
||||
|
||||
C0 = texture2dd(pC4-g1);
|
||||
C1 = texture2dd(pC4-dy);
|
||||
C2 = texture2dd(pC4-g2);
|
||||
C3 = texture2dd(pC4-dx);
|
||||
C4 = texture2dd(pC4 );
|
||||
C5 = texture2dd(pC4+dx);
|
||||
C6 = texture2dd(pC4+g2);
|
||||
C7 = texture2dd(pC4+dy);
|
||||
C8 = texture2dd(pC4+g1);
|
||||
|
||||
vec3 mn1 = min(min(C0,C1),C2);
|
||||
vec3 mn2 = min(min(C3,C4),C5);
|
||||
vec3 mn3 = min(min(C6,C7),C8);
|
||||
vec3 mx1 = max(max(C0,C1),C2);
|
||||
vec3 mx2 = max(max(C3,C4),C5);
|
||||
vec3 mx3 = max(max(C6,C7),C8);
|
||||
|
||||
mn1 = min(min(mn1,mn2),mn3);
|
||||
mx1 = max(max(mx1,mx2),mx3);
|
||||
|
||||
vec3 dif1 = abs(c11-mn1) + 0.0001*dt;
|
||||
vec3 dif2 = abs(c11-mx1) + 0.0001*dt;
|
||||
|
||||
float filterparam = 2.0;
|
||||
|
||||
dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam));
|
||||
dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam));
|
||||
|
||||
c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x);
|
||||
c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y);
|
||||
c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z);
|
||||
|
||||
result = c11;
|
||||
}
|
||||
|
||||
|
||||
gl_FragColor.xyz=result.xyz;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
/*
|
||||
AA shader 4.o / AA shader 4.o - filtro
|
||||
|
||||
Copyright (C) 2014 guest(r) - guest.r@gmail.com
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// Modified as video aware smoothing effect for PPSSPP.
|
||||
// Some variable definitions had to be moved inside functions(and so repeated) due to glsl->hlsl auto translation failing.
|
||||
// Also auto translation fails with bool uniform, which is why u_video is defined as float.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
uniform float u_video;
|
||||
|
||||
|
||||
//===========
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
const vec3 dt = vec3(1.0,1.0,1.0);
|
||||
|
||||
vec3 texture2d (vec2 texcoord) {
|
||||
|
||||
float scale = 1.0;
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
}
|
||||
|
||||
vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale;
|
||||
vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale;
|
||||
|
||||
vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz;
|
||||
vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz;
|
||||
vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz;
|
||||
vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz;
|
||||
|
||||
float m1=dot(abs(s00-s22),dt)+0.001;
|
||||
float m2=dot(abs(s02-s20),dt)+0.001;
|
||||
|
||||
return 0.5*(m2*(s00+s22)+m1*(s02+s20))/(m1+m2);
|
||||
}
|
||||
vec3 texture2dd (vec2 texcoord) {
|
||||
|
||||
float scale = 1.0;
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
}
|
||||
|
||||
vec4 yx = vec4(1.0/480.0,1.0/272.0,-1.0/480.0,-1.0/272.0)/scale;
|
||||
vec4 xy = vec4(2.0/480.0,2.0/272.0,-2.0/480.0,-2.0/272.0)/scale;
|
||||
|
||||
vec3 c11 = texture2D(sampler0, texcoord ).xyz;
|
||||
vec3 c00 = texture2D(sampler0, texcoord + xy.zw).xyz;
|
||||
vec3 c20 = texture2D(sampler0, texcoord + xy.xw).xyz;
|
||||
vec3 c22 = texture2D(sampler0, texcoord + xy.xy).xyz;
|
||||
vec3 c02 = texture2D(sampler0, texcoord + xy.zy).xyz;
|
||||
vec3 s00 = texture2D(sampler0, texcoord + yx.zw).xyz;
|
||||
vec3 s20 = texture2D(sampler0, texcoord + yx.xw).xyz;
|
||||
vec3 s22 = texture2D(sampler0, texcoord + yx.xy).xyz;
|
||||
vec3 s02 = texture2D(sampler0, texcoord + yx.zy).xyz;
|
||||
|
||||
float d1=dot(abs(c00-c22),dt)+0.001;
|
||||
float d2=dot(abs(c20-c02),dt)+0.001;
|
||||
float m1=dot(abs(s00-s22),dt)+0.001;
|
||||
float m2=dot(abs(s02-s20),dt)+0.001;
|
||||
|
||||
vec3 t2=(d1*(c20+c02)+d2*(c00+c22))/(2.0*(d1+d2));
|
||||
|
||||
return 0.25*(c11+t2+(m2*(s00+s22)+m1*(s02+s20))/(m1+m2));
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
float scale = 7.0;
|
||||
bool filtro = false;
|
||||
|
||||
if (u_video==1.0){
|
||||
scale = 2.0;
|
||||
filtro = true;
|
||||
} else {
|
||||
scale = 7.0;
|
||||
filtro = false;
|
||||
}
|
||||
|
||||
// Calculating texel coordinates
|
||||
|
||||
vec2 size = vec2(480.0,272.0)*scale;
|
||||
vec2 inv_size = vec2(1.0/480.0,1.0/272.0)/scale;
|
||||
|
||||
vec2 OGL2Pos = v_texcoord0 * size;
|
||||
vec2 fp = fract(OGL2Pos);
|
||||
vec2 dx = vec2(inv_size.x,0.0);
|
||||
vec2 dy = vec2(0.0, inv_size.y);
|
||||
vec2 g1 = vec2(inv_size.x,inv_size.y);
|
||||
vec2 g2 = vec2(-inv_size.x,inv_size.y);
|
||||
|
||||
vec2 pC4 = floor(OGL2Pos) * inv_size + 0.5*inv_size;
|
||||
|
||||
// Reading the texels
|
||||
vec3 C0 = texture2d(pC4 - g1);
|
||||
vec3 C1 = texture2d(pC4 - dy);
|
||||
vec3 C2 = texture2d(pC4 - g2);
|
||||
vec3 C3 = texture2d(pC4 - dx);
|
||||
vec3 C4 = texture2d(pC4 );
|
||||
vec3 C5 = texture2d(pC4 + dx);
|
||||
vec3 C6 = texture2d(pC4 + g2);
|
||||
vec3 C7 = texture2d(pC4 + dy);
|
||||
vec3 C8 = texture2d(pC4 + g1);
|
||||
|
||||
vec3 ul, ur, dl, dr;
|
||||
float m1, m2;
|
||||
|
||||
m1 = dot(abs(C0-C4),dt)+0.001;
|
||||
m2 = dot(abs(C1-C3),dt)+0.001;
|
||||
ul = (m2*(C0+C4)+m1*(C1+C3))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C1-C5),dt)+0.001;
|
||||
m2 = dot(abs(C2-C4),dt)+0.001;
|
||||
ur = (m2*(C1+C5)+m1*(C2+C4))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C3-C7),dt)+0.001;
|
||||
m2 = dot(abs(C6-C4),dt)+0.001;
|
||||
dl = (m2*(C3+C7)+m1*(C6+C4))/(m1+m2);
|
||||
|
||||
m1 = dot(abs(C4-C8),dt)+0.001;
|
||||
m2 = dot(abs(C5-C7),dt)+0.001;
|
||||
dr = (m2*(C4+C8)+m1*(C5+C7))/(m1+m2);
|
||||
|
||||
vec3 result = vec3(0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y)));
|
||||
|
||||
if(filtro){
|
||||
vec3 c11 = 0.5*((dr*fp.x+dl*(1.0-fp.x))*fp.y+(ur*fp.x+ul*(1.0-fp.x))*(1.0-fp.y));
|
||||
|
||||
inv_size = vec2(2.0/480.0,2.0/272.0)/scale;;
|
||||
|
||||
dx = vec2(inv_size.x,0.0);
|
||||
dy = vec2(0.0,inv_size.y);
|
||||
g1 = vec2( inv_size.x,inv_size.y);
|
||||
g2 = vec2(-inv_size.x,inv_size.y);
|
||||
pC4 = v_texcoord0;
|
||||
|
||||
C0 = texture2dd(pC4-g1);
|
||||
C1 = texture2dd(pC4-dy);
|
||||
C2 = texture2dd(pC4-g2);
|
||||
C3 = texture2dd(pC4-dx);
|
||||
C4 = texture2dd(pC4 );
|
||||
C5 = texture2dd(pC4+dx);
|
||||
C6 = texture2dd(pC4+g2);
|
||||
C7 = texture2dd(pC4+dy);
|
||||
C8 = texture2dd(pC4+g1);
|
||||
|
||||
vec3 mn1 = min(min(C0,C1),C2);
|
||||
vec3 mn2 = min(min(C3,C4),C5);
|
||||
vec3 mn3 = min(min(C6,C7),C8);
|
||||
vec3 mx1 = max(max(C0,C1),C2);
|
||||
vec3 mx2 = max(max(C3,C4),C5);
|
||||
vec3 mx3 = max(max(C6,C7),C8);
|
||||
|
||||
mn1 = min(min(mn1,mn2),mn3);
|
||||
mx1 = max(max(mx1,mx2),mx3);
|
||||
|
||||
vec3 dif1 = abs(c11-mn1) + 0.0001*dt;
|
||||
vec3 dif2 = abs(c11-mx1) + 0.0001*dt;
|
||||
|
||||
float filterparam = 2.0;
|
||||
|
||||
dif1=vec3(pow(dif1.x,filterparam),pow(dif1.y,filterparam),pow(dif1.z,filterparam));
|
||||
dif2=vec3(pow(dif2.x,filterparam),pow(dif2.y,filterparam),pow(dif2.z,filterparam));
|
||||
|
||||
c11.r = (dif1.x*mx1.x + dif2.x*mn1.x)/(dif1.x + dif2.x);
|
||||
c11.g = (dif1.y*mx1.y + dif2.y*mn1.y)/(dif1.y + dif2.y);
|
||||
c11.b = (dif1.z*mx1.z + dif2.z*mn1.z)/(dif1.z + dif2.z);
|
||||
|
||||
result = c11;
|
||||
}
|
||||
|
||||
|
||||
gl_FragColor.xyz=result.xyz;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Simple vignette shader - darker towards the corners like in the unprocessed output of a real camera.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
float vignette = 1.1 - 0.6 * (dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5) * 2.0);
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
gl_FragColor.rgb = vignette * rgb;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
// Simple vignette shader - darker towards the corners like in the unprocessed output of a real camera.
|
||||
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
precision mediump int;
|
||||
#endif
|
||||
|
||||
uniform sampler2D sampler0;
|
||||
varying vec2 v_texcoord0;
|
||||
|
||||
void main() {
|
||||
float vignette = 1.1 - 0.6 * (dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5) * 2.0);
|
||||
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
|
||||
gl_FragColor.rgb = vignette * rgb;
|
||||
gl_FragColor.a = 1.0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user