diff options
author | bobo1on1 <bobo1on1@svn> | 2010-01-14 01:17:10 +0000 |
---|---|---|
committer | bobo1on1 <bobo1on1@svn> | 2010-01-14 01:17:10 +0000 |
commit | 642c6d57bbc3ef21ac5c9cf40a7b1ca487076f81 (patch) | |
tree | 42c56ada276e6141803961310dd3d50c096bfcad /system/shaders/convolution-6x6.glsl | |
parent | b67491e9a5a4c9f0e1d936b760759b954c77f6e8 (diff) |
improved efficiency by precalculating more values
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@26775 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'system/shaders/convolution-6x6.glsl')
-rw-r--r-- | system/shaders/convolution-6x6.glsl | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/system/shaders/convolution-6x6.glsl b/system/shaders/convolution-6x6.glsl index 2c5710d16a..5cb060c78b 100644 --- a/system/shaders/convolution-6x6.glsl +++ b/system/shaders/convolution-6x6.glsl @@ -10,19 +10,19 @@ vec4 weight(float pos) vec4 pixel(float xpos, float ypos) { - return texture2D(img, vec2(gl_TexCoord[0].x + xpos * stepx, gl_TexCoord[0].y + ypos * stepy)); + return texture2D(img, vec2(xpos, ypos)); } -vec4 line (float ypos, float xf, vec4 linetaps1, vec4 linetaps2) +vec4 line (float ypos, vec3 xpos1, vec3 xpos2, vec4 linetaps1, vec4 linetaps2) { vec4 pixels; - pixels = pixel(-1.5 - xf, ypos) * linetaps1.r; - pixels += pixel(-0.5 - xf, ypos) * linetaps2.r; - pixels += pixel( 0.5 - xf, ypos) * linetaps1.g; - pixels += pixel( 1.5 - xf, ypos) * linetaps2.g; - pixels += pixel( 2.5 - xf, ypos) * linetaps1.b; - pixels += pixel( 3.5 - xf, ypos) * linetaps2.b; + pixels = pixel(xpos1.r, ypos) * linetaps1.r; + pixels += pixel(xpos1.g, ypos) * linetaps2.r; + pixels += pixel(xpos1.b, ypos) * linetaps1.g; + pixels += pixel(xpos2.r, ypos) * linetaps2.g; + pixels += pixel(xpos2.g, ypos) * linetaps1.b; + pixels += pixel(xpos2.b, ypos) * linetaps2.b; return pixels; } @@ -37,12 +37,21 @@ void main() vec4 columntaps1 = weight((1.0 - yf) / 2.0); vec4 columntaps2 = weight((1.0 - yf) / 2.0 + 0.5); - gl_FragColor = line(-1.5 - yf, xf, linetaps1, linetaps2) * columntaps1.r; - gl_FragColor += line(-0.5 - yf, xf, linetaps1, linetaps2) * columntaps2.r; - gl_FragColor += line( 0.5 - yf, xf, linetaps1, linetaps2) * columntaps1.g; - gl_FragColor += line( 1.5 - yf, xf, linetaps1, linetaps2) * columntaps2.g; - gl_FragColor += line( 2.5 - yf, xf, linetaps1, linetaps2) * columntaps1.b; - gl_FragColor += line( 3.5 - yf, xf, linetaps1, linetaps2) * columntaps2.b; + vec3 xpos1 = vec3( + (-1.5 - xf) * stepx + gl_TexCoord[0].x, + (-0.5 - xf) * stepx + gl_TexCoord[0].x, + ( 0.5 - xf) * stepx + gl_TexCoord[0].x); + vec3 xpos2 = vec3( + ( 1.5 - xf) * stepx + gl_TexCoord[0].x, + ( 2.5 - xf) * stepx + gl_TexCoord[0].x, + ( 3.5 - xf) * stepx + gl_TexCoord[0].x); + + gl_FragColor = line((-1.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r; + gl_FragColor += line((-0.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r; + gl_FragColor += line(( 0.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g; + gl_FragColor += line(( 1.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g; + gl_FragColor += line(( 2.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b; + gl_FragColor += line(( 3.5 - yf) * stepy + gl_TexCoord[0].y, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b; gl_FragColor.a = gl_Color.a; } |