Merge pull request #10 from OpenArena/leifxfix

update slightly obsolete filter code
This commit is contained in:
leilei-
2016-04-23 19:48:34 -04:00

View File

@@ -16,25 +16,65 @@ uniform float u_ScreenToNextPixelY;
uniform float u_ScreenSizeX;
uniform float u_ScreenSizeY;
#define PIXELWIDTH 0.66f
uniform float u_CC_Brightness; // pass indicator from engine
//#define BOXFILTER; // blind attempt at "22-bit" filter
#ifdef BOXFILTER
#define PIXELWIDTH 1.0f
//#define FILTCAP 0.085 // filtered pixel should not exceed this
#define FILTCAP (32.0f / 255) // filtered pixel should not exceed this
#define FILTCAP 0.075 // filtered pixel should not exceed this
#define FILTCAPG (FILTCAP / 2)
float filtertable_x[4] = {
1, -1,-1,1
};
float filtertable_y[4] = {
-1,1,-1,1
};
#else
#define PIXELWIDTH 1.0f
//#define FILTCAP 0.175 // filtered pixel should not exceed this
#define FILTCAP (64.0f / 255) // filtered pixel should not exceed this
#define FILTCAPG (FILTCAP / 2)
float filtertable_x[4] = {
1,-1,1,1
};
float filtertable_y[4] = {
0,0,0,0
};
#endif
void main()
{
vec2 px; // shut
float PIXELWIDTHH = u_ScreenToNextPixelX;
int pass = int(u_CC_Brightness);
px.x = u_ScreenToNextPixelX;
px.y = u_ScreenToNextPixelY;
px.x = u_ScreenToNextPixelX / 1.5;
px.y = u_ScreenToNextPixelY / 1.5;
// Sampling The Texture And Passing It To The Frame Buffer
gl_FragColor = texture2D(u_Texture0, texture_coordinate);
vec4 pixel1 = texture2D(u_Texture0, texture_coordinate + vec2(px.x * PIXELWIDTH, 0));
vec4 pixel2 = texture2D(u_Texture0, texture_coordinate + vec2(-px.x * PIXELWIDTH, 0));
vec4 pixel1 = texture2D(u_Texture0, texture_coordinate + vec2(px.x * (filtertable_x[pass] * PIXELWIDTH), vec2(px.y * (PIXELWIDTH * filtertable_y[pass]))));
vec4 pixel2 = texture2D(u_Texture0, texture_coordinate + vec2(-px.x * (filtertable_x[pass] * PIXELWIDTH), vec2(px.y * (PIXELWIDTH * filtertable_y[pass]))));
vec4 pixeldiff; // Pixel difference for the dither check
vec4 pixelmake; // Pixel to make for adding to the buffer
@@ -46,8 +86,6 @@ void main()
pixelmake.rgb = 0;
pixeldiff.rgb = pixel2.rgb- gl_FragColor.rgb;
pixeldiffleft.rgb = pixel1.rgb - gl_FragColor.rgb;
if (pixeldiff.r > FILTCAP) pixeldiff.r = FILTCAP;
if (pixeldiff.g > FILTCAPG) pixeldiff.g = FILTCAPG;
if (pixeldiff.b > FILTCAP) pixeldiff.b = FILTCAP;
@@ -56,17 +94,9 @@ void main()
if (pixeldiff.g < -FILTCAPG) pixeldiff.g = -FILTCAPG;
if (pixeldiff.b < -FILTCAP) pixeldiff.b = -FILTCAP;
if (pixeldiffleft.r > FILTCAP) pixeldiffleft.r = FILTCAP;
if (pixeldiffleft.g > FILTCAPG) pixeldiffleft.g = FILTCAPG;
if (pixeldiffleft.b > FILTCAP) pixeldiffleft.b = FILTCAP;
if (pixeldiffleft.r < -FILTCAP) pixeldiffleft.r = -FILTCAP;
if (pixeldiffleft.g < -FILTCAPG) pixeldiffleft.g = -FILTCAPG;
if (pixeldiffleft.b < -FILTCAP) pixeldiffleft.b = -FILTCAP;
pixelmake.rgb = (pixeldiff.rgb / 4) + (pixeldiffleft.rgb / 16);
pixelmake.rgb = (pixeldiff.rgb / 4);
gl_FragColor.rgb= (gl_FragColor.rgb + pixelmake.rgb);
}
}
}