forked from jdgleaver/ppsspp_shaders
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path2xbr.fsh
More file actions
69 lines (56 loc) · 2.24 KB
/
Copy path2xbr.fsh
File metadata and controls
69 lines (56 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
Hyllian's 2xBR 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.
*/
// filter="nearest" output_width="200%" output_height="200%"
#ifdef GL_FRAGMENT_PRECISION_HIGH
precision highp float;
#else
precision mediump float;
#endif
uniform mediump vec2 u_texelDelta;
uniform sampler2D sampler0;
varying vec2 v_texcoord0[3];
const vec3 dtt = vec3(65536.0, 255.0, 1.0);
float reduce(vec3 color) {
return dot(color, dtt);
}
void main() {
vec2 fp = fract(v_texcoord0[0] / u_texelDelta);
vec2 g1 = v_texcoord0[1] * (step(0.5, fp.x) + step(0.5, fp.y) - 1.0) +
v_texcoord0[2] * (step(0.5, fp.x) - step(0.5, fp.y));
vec2 g2 = v_texcoord0[1] * (step(0.5, fp.y) - step(0.5, fp.x)) +
v_texcoord0[2] * (step(0.5, fp.x) + step(0.5, fp.y) - 1.0);
vec3 B = texture2D(sampler0, v_texcoord0[0] + g1 ).xyz;
vec3 C = texture2D(sampler0, v_texcoord0[0] + g1 - g2).xyz;
vec3 D = texture2D(sampler0, v_texcoord0[0] + g2).xyz;
vec3 E = texture2D(sampler0, v_texcoord0[0] ).xyz;
vec3 F = texture2D(sampler0, v_texcoord0[0] - g2).xyz;
vec3 G = texture2D(sampler0, v_texcoord0[0] - g1 + g2).xyz;
vec3 H = texture2D(sampler0, v_texcoord0[0] - g1 ).xyz;
vec3 I = texture2D(sampler0, v_texcoord0[0] - g1 - g2).xyz;
float b = reduce(B);
float c = reduce(C);
float d = reduce(D);
float e = reduce(E);
float f = reduce(F);
float g = reduce(G);
float h = reduce(H);
float i = reduce(I);
gl_FragColor.rgb = E;
if (h==f && h!=e && ( e==g && (h==i || e==d) || e==c && (h==i || e==b) ))
{
gl_FragColor.rgb = mix(E, F, 0.5);
}
}