sebt3
homebrew player (P. & C.)
Hi there,
I do have written these 2 shaders. But they are _way_ _too_ _slow_ to be anything usefull
Anyway here they are :
scale2x :
scale3x :
Fragment :
I tried to optimize them, but that's the best I can get. They are at least as slow as their CPU counter-part.
PS : I'm doing more this as a warning/starting point for the next man as I spend some days doing so and the result are... not satisfying at least...
I do have written these 2 shaders. But they are _way_ _too_ _slow_ to be anything usefull
Anyway here they are :
scale2x :
Vert :
Fragment : B) || (p.y< 0.5 && D == H))) E = D;
if(p.x< 0.5 && p.y>=0.5 && D == B) E = D; // E0
if(p.x< 0.5 && p.y< 0.5 && D == H) E = D; // E2
// if(p.x>=0.5 && ((p.y>=0.5 && B == F) || (p.y< 0.5 && H == F))) E = F;
if(p.x>=0.5 && p.y>=0.5 && B == F) E = F; // E1
if(p.x>=0.5 && p.y< 0.5 && H == F) E = F; // E3
}
gl_FragColor = E;
}
Note that the commented lines should do the same thing as the 2 lines bellow them but dont... :wacko:
Code:
attribute vec4 a_position;
attribute vec2 a_texCoord0;
varying vec2 v_texCoord[5];
varying vec2 pos;
uniform vec4 u_param;
void main()
{
vec2 osx = vec2(1.0/u_param.x, 0.0);
vec2 osy = vec2(0.0, 1.0/u_param.y);
gl_Position = a_position;
v_texCoord[0] = a_texCoord0;
v_texCoord[1] = v_texCoord[0] - osx;
v_texCoord[2] = v_texCoord[0] + osx;
v_texCoord[3] = v_texCoord[0] - osy;
v_texCoord[4] = v_texCoord[0] + osy;
pos = v_texCoord[0].xy * u_param.xy;
}
Fragment : B) || (p.y< 0.5 && D == H))) E = D;
if(p.x< 0.5 && p.y>=0.5 && D == B) E = D; // E0
if(p.x< 0.5 && p.y< 0.5 && D == H) E = D; // E2
// if(p.x>=0.5 && ((p.y>=0.5 && B == F) || (p.y< 0.5 && H == F))) E = F;
if(p.x>=0.5 && p.y>=0.5 && B == F) E = F; // E1
if(p.x>=0.5 && p.y< 0.5 && H == F) E = F; // E3
}
gl_FragColor = E;
}
Code:
precision mediump float;
varying vec2 v_texCoord[5];
varying vec2 pos;
uniform sampler2D s_texture0;
uniform vec4 u_param;
void main()
{
vec4 E = texture2D(s_texture0, v_texCoord[0]);
vec4 D = texture2D(s_texture0, v_texCoord[1]);
vec4 F = texture2D(s_texture0, v_texCoord[2]);
vec4 H = texture2D(s_texture0, v_texCoord[3]);
vec4 B = texture2D(s_texture0, v_texCoord[4]);
vec2 p = fract(pos);
if (B != H && D != F) {
// if(p.x< 0.5 && ((p.y>=0.5 && D ==
Note that the commented lines should do the same thing as the 2 lines bellow them but dont... :wacko:
scale3x :
Vertice :
Code:
attribute vec4 a_position;
attribute vec2 a_texCoord0;
varying vec2 v_texCoord[9];
uniform vec4 u_param;
void main()
{
vec2 osx = vec2(1.0/u_param.x, 0.0);
vec2 osy = vec2(0.0, 1.0/u_param.y);
gl_Position = a_position;
v_texCoord[0] = a_texCoord0; // E
v_texCoord[1] = v_texCoord[0] - osx; // D
v_texCoord[2] = v_texCoord[0] + osx; // F
v_texCoord[3] = v_texCoord[0] - osy; // H
v_texCoord[4] = v_texCoord[0] + osy; // B
v_texCoord[5] = v_texCoord[0] - osx + osy; // A
v_texCoord[6] = v_texCoord[0] + osx + osy; // C
v_texCoord[7] = v_texCoord[0] - osx - osy; // G
v_texCoord[8] = v_texCoord[0] + osx - osy; // I
}
Code:
precision mediump float;
varying vec2 v_texCoord[9];
uniform sampler2D s_texture0;
uniform vec4 u_param;
/*
A B C
D E F
G H I
k0k1
k2k3
E0E1E2
E3E4E5
E6E7E8
*/
void main()
{
vec2 p = fract(v_texCoord[0].xy * u_param.xy);
vec4 E = texture2D(s_texture0, v_texCoord[0]);
vec4 D = texture2D(s_texture0, v_texCoord[1]);
vec4 F = texture2D(s_texture0, v_texCoord[2]);
vec4 H = texture2D(s_texture0, v_texCoord[3]);
vec4 B = texture2D(s_texture0, v_texCoord[4]);
vec4 A = texture2D(s_texture0, v_texCoord[5]);
vec4 C = texture2D(s_texture0, v_texCoord[6]);
vec4 G = texture2D(s_texture0, v_texCoord[7]);
vec4 I = texture2D(s_texture0, v_texCoord[8]);
vec4 r = E;
if (D == B && B != F && D != H) { //=k0=
if(p.x< 0.33 && p.y>=0.66) r = D; // E0
if(p.x>=0.33&&p.x< 0.66 && p.y>=0.66 && E != C) r = B; // E1
if(p.x< 0.33 && p.y>=0.33&&p.y< 0.66 && E != G) r = D; // E3
}
if (B == F && B != D && F != H) { //=k1=
if(p.x>=0.66 && p.y>=0.66) r = F; // E2
if(p.x>=0.33&&p.x< 0.66 && p.y>=0.66 && E != A) r = B; // E1
if(p.x>=0.66 && p.y>=0.33&&p.y< 0.66 && E != I) r = F; // E5
}
if (D == H && D != B && H != F) { //=k2=
if(p.x< 0.33 && p.y< 0.33) r = D; // E6
if(p.x< 0.33 && p.y>=0.33&&p.y< 0.66 && E != A) r = D; // E3
if(p.x>=0.33&&p.x< 0.66 && p.y< 0.33 && E != I) r = H; // E7
}
if (H == F && D != H && B != F) { //=k3=
if(p.x>=0.66 && p.y< 0.33) r = F; // E8
if(p.x>=0.66 && p.y>=0.33&&p.y< 0.66 && E != C) r = F; // E5
if(p.x>=0.33&&p.x< 0.66 && p.y< 0.33 && E != G) r = H; // E7
}
gl_FragColor = r;
}
I tried to optimize them, but that's the best I can get. They are at least as slow as their CPU counter-part.
PS : I'm doing more this as a warning/starting point for the next man as I spend some days doing so and the result are... not satisfying at least...
Last edited by a moderator: