Minor graphics fixes

This commit is contained in:
Eduardo Bart
2012-06-18 20:58:56 -03:00
parent cb58d2dcfa
commit 5a048eb7ea
7 changed files with 24 additions and 14 deletions

View File

@@ -25,7 +25,6 @@ local shadersPanel
function Shaders.init()
importStyle 'shaders.otui'
Keyboard.bindKeyDown(HOTKEY, Shaders.toggle)
shadersPanel = createWidget('ShadersPanel', GameInterface.getMapPanel())
@@ -37,6 +36,8 @@ function Shaders.init()
map:setMapShader(g_shaders.getShader(option))
end
if not g_graphics.canUseShaders() then return end
for _i,opts in pairs(MAP_SHADERS) do
local shader = g_shaders.createFragmentShader(opts.name, opts.frag)

View File

@@ -7,9 +7,6 @@ const float sampleStrength = 2.2;
void main(void)
{
// some sample positions
float samples[] = { -0.08,-0.05,-0.03,-0.02,-0.01,0.01,0.02,0.03,0.05,0.08 };
// 0.5,0.5 is the center of the screen
// so substracting v_TexCoord from it will result in
// a vector pointing to the middle of the screen
@@ -29,8 +26,16 @@ void main(void)
// take 10 additional blur samples in the direction towards
// the center of the screen
for(int i = 0; i < 10; i++)
sum += texture2D(u_Tex0, v_TexCoord + dir * samples[i] * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord - 0.08 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord - 0.05 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord - 0.03 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord - 0.02 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord - 0.01 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord + 0.01 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord + 0.02 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord + 0.03 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord + 0.05 * dir * sampleDist);
sum += texture2D(u_Tex0, v_TexCoord + 0.08 * dir * sampleDist);
// we have taken eleven samples
sum *= 1.0/11.0;
@@ -42,4 +47,4 @@ void main(void)
//Blend the original color with the averaged pixels
gl_FragColor = mix(color, sum, t);
}
}