13xforever 

Status:Offline Date registered: 05.02.2006 Post:1 Send Message | Created on 05.02.2006 - 08:21 |  |
Can't find this one, so this is my own implementation (works very well on my PC )
---------------- gpuPeteOGL2.slv: ---------------- /**************************************************************************************** Scale3x GLslang shader - ported by 13xforever
Nearly riginal Pete's comments: ----------------------------------------------------------------------------------------- see the .slf file for algorithm/license informations
How to use the shaders: copy both files ("gpuPeteOGL2.slv" and "gpuPeteOGL2.slf" into the emu's "shaders" subdirectory. Configure the plugin: set "shader effects" to mode "5 - GLslang files". Set the "effect level" to "4 - Maximum" (needed for best scaling!). Important: to get a real Scale3x effect, your configured window/fullscreen size has to be at least three times as the internal resolution. That means: if your internal resolution is "0 - low", than the window/fullscreen size has to be at least 960x720 with most games. If you are using an internal resolution of "1 - high", your window/fullscreen size has to be at least 1920x1440... it will not crash or something, if you are using smaller window/fullscreen sizes, but the algorithm will not work properly on all pixels. Also, the above values may vary, depending on the psx game's display size. The complete formula to set your window/fullscreen size is: "psx game resolution" * "plugin internal resolution mode + 1" * 3
So, for a psx game which is using 320x240, and the "1 - high" mode, you would need 320x240 * (1 + 1) * 3 = 640x480 * 3 = 1920x1440... mmmkay?
Ah, and final note: Scale3X works best on games using clear 2D gfx ----------------------------------------------------------------------------------------- All we have to do is just expand pixel E into 9 new pixels E0-E9
A B C D E F > E0 E1 E2 G H I > E3 E4 E5 E6 E7 E8 ****************************************************************************************/
uniform vec4 OGL2Param; uniform vec4 OGL2Size;
void main() { vec2 dx, dy;
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
dx = vec2(OGL2Param.x, 0); // setup one x/y texel d // we could also use "1.0/OGL2Size.x (y)", than it wouldn't dy = vec2(0, OGL2Param.y); // be dependand on the "shader effect level" setting... // but more choice is usual better, eh? gl_TexCoord[0] = gl_MultiTexCoord0; // E gl_TexCoord[0].zw = gl_TexCoord[0].xy - dx - dy; // A gl_TexCoord[1].xy = gl_TexCoord[0].xy - dy; // B gl_TexCoord[1].zw = gl_TexCoord[0].xy + dx - dy; // C gl_TexCoord[2].xy = gl_TexCoord[0].xy - dx; // D gl_TexCoord[2].zw = gl_TexCoord[0].xy + dx; // F gl_TexCoord[3].xy = gl_TexCoord[0].xy - dx + dy; // G gl_TexCoord[3].zw = gl_TexCoord[0].xy + dy; // H gl_TexCoord[4].xy = gl_TexCoord[0].xy + dx + dy; // I }
---------------- gpuPeteOGL2.slf: ---------------- /****************************************************************************** Scale3x GLslang shader - ported by 13xforever
Scale3x Homepage: http://scale2x.sourceforge.net/
Scale3X is using the GPL, so feel free to use this shader in your work, but publish the source as well, for other interested coders to see and/or modify.
All we have to do is just expand pixel E into 9 new pixels E0-E9:
A B C > D E F > E0 E1 E2 G H I > E3 E4 E5 E6 E7 E8 ******************************************************************************/
uniform vec4 OGL2Param; uniform vec4 OGL2Size; uniform sampler2D OGL2Texture;
void main() { const vec2 sep = vec2(0.33333, 0.66667); // sufficient precision for HDTV (1920x1080) 
vec4 A, B, C, D, E, F, G, H, I, X, T; vec2 sel;
E = texture2D(OGL2Texture, gl_TexCoord[0].xy); // E A = texture2D(OGL2Texture, gl_TexCoord[0].zw); // A B = texture2D(OGL2Texture, gl_TexCoord[1].xy); // B C = texture2D(OGL2Texture, gl_TexCoord[1].zw); // C D = texture2D(OGL2Texture, gl_TexCoord[2].xy); // D F = texture2D(OGL2Texture, gl_TexCoord[2].zw); // F G = texture2D(OGL2Texture, gl_TexCoord[3].xy); // G H = texture2D(OGL2Texture, gl_TexCoord[3].zw); // H I = texture2D(OGL2Texture, gl_TexCoord[4].xy); // I X = vec4(1) - E; // to be sure that ((E != A) == true) in function call
sel = fract(gl_TexCoord[0].xy * OGL2Size.xy);// where are we (E0-E8)?
// branching is very undesirable, so we make a lot of reassignments // of original pixels to make sure that rule for E1 pixel will work // with any other (rotate second matrix and swap some Ex) // // native function call --> x y --> equivalent transpose (to minimize reassignments) //(E, B, X, D, E, F, H) --> 0 0 --> (E, B, X, D, E, F, H) for E0 //(A, B, C, D, E, F, H) --> 1 0 --> (A, B, C, D, E, F, H) for E1 //(E, F, X, B, E, H, D) --> 2 0 --> (X, F, E, D, E, B, H) for E2
//(G, D, A, H, E, B, F) --> 0 1 --> (A, D, G, B, E, H, F) for E3 //( , E, , , E, , ) --> 1 1 --> ( , E, , , E, , ) for E4 //(C, F, I, B, E, H, D) --> 2 1 --> (I, F, C, H, E, B, D) for E5
//(E, D, X, H, E, B, F) --> 0 2 --> (E, D, X, H, E, F, B) for E6 //(I, H, G, F, E, D, B) --> 1 2 --> (G, H, I, D, E, F, B) for E7 //(E, H, X, F, E, D, B) --> 2 2 --> (X, H, E, D, E, F, B) for E8
if (sel.y < sep.x) { if (sel.x < sep.x) { A = E; C = X; } else if (sel.x >= sep.y) { A = X; C = E; T = B; B = F; F = T; } } else if (sel.y < sep.y) { T = B; if (sel.x < sep.x) { B = D; D = T; C = G; T = F; F = H; } else if (sel.x < sep.y) { B = E; } else { A = I; B = F; F = T; T = D; D = H; } H = T; } else { T = B; if (sel.x < sep.x) { A = E; C = X; B = D; D = H; } else { if (sel.x < sep.y) { A = G; C = I; } else { A = X; C = E; } B = H; } H = T; }
gl_FragColor = ((D == B && B != F && D != H && E != C) || (B == F && B != D && F != H && E != A)) ? B : E; // Scale3x rule }
Signature AMD Athlon64 2800+ (S754) / 1 GB DDR400 / GeForce 6600GT / 128 MB GDDR3 / Seagate 160 GB SATA |