diff options
author | bobo1on1 <bobo1on1@svn> | 2010-03-22 20:43:31 +0000 |
---|---|---|
committer | bobo1on1 <bobo1on1@svn> | 2010-03-22 20:43:31 +0000 |
commit | dcb4e268e68c95b86e36d040f0251166b2fe3f3a (patch) | |
tree | 63396303eacebaf0317fb1276467092517903e00 /system/shaders | |
parent | e2cd7aab657ec9796dd3235b12bbc6385ef536cf (diff) |
revert r28750 and r28588 to keep compatibility with opengl versions lower than 3.0
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@28753 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'system/shaders')
-rw-r--r-- | system/shaders/convolution-4x4.glsl | 51 | ||||
-rw-r--r-- | system/shaders/convolution-6x6.glsl | 66 |
2 files changed, 68 insertions, 49 deletions
diff --git a/system/shaders/convolution-4x4.glsl b/system/shaders/convolution-4x4.glsl index 70813f45cb..fa3f8c11ec 100644 --- a/system/shaders/convolution-4x4.glsl +++ b/system/shaders/convolution-4x4.glsl @@ -1,22 +1,25 @@ -#version 130 - uniform sampler2D img; uniform sampler1D kernelTex; uniform vec2 stepxy; uniform float m_stretch; -out vec4 gl_FragColor; -in vec4 gl_TexCoord[]; -in vec4 gl_Color; + +//nvidia's half is a 16 bit float and can bring some speed improvements +//without affecting quality +#ifndef __GLSL_CG_DATA_TYPES + #define half float + #define half3 vec3 + #define half4 vec4 +#endif #if (HAS_FLOAT_TEXTURE) -vec4 weight(float pos) +half4 weight(float pos) { - return texture(kernelTex, pos); + return texture1D(kernelTex, pos); } #else -vec4 weight(float pos) +half4 weight(float pos) { - return texture(kernelTex, pos) * 2.0 - 1.0; + return texture1D(kernelTex, pos) * 2.0 - 1.0; } #endif @@ -33,13 +36,18 @@ vec2 stretch(vec2 pos) #endif } -vec3 line (vec2 pos, const int yoffset, vec4 linetaps) +half3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +half3 line (float ypos, vec4 xpos, half4 linetaps) { return - textureOffset(img, pos, ivec2(-1, yoffset)).rgb * linetaps.r + - textureOffset(img, pos, ivec2( 0, yoffset)).rgb * linetaps.g + - textureOffset(img, pos, ivec2( 1, yoffset)).rgb * linetaps.b + - textureOffset(img, pos, ivec2( 2, yoffset)).rgb * linetaps.a; + pixel(xpos.r, ypos) * linetaps.r + + pixel(xpos.g, ypos) * linetaps.g + + pixel(xpos.b, ypos) * linetaps.b + + pixel(xpos.a, ypos) * linetaps.a; } void main() @@ -47,20 +55,21 @@ void main() vec2 pos = stretch(gl_TexCoord[0].xy); vec2 f = fract(pos / stepxy); - vec4 linetaps = weight(1.0 - f.x); - vec4 columntaps = weight(1.0 - f.y); + half4 linetaps = weight(1.0 - f.x); + half4 columntaps = weight(1.0 - f.y); //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a; columntaps /= columntaps.r + columntaps.g + columntaps.b + columntaps.a; - vec2 xystart = (0.5 - f) * stepxy + pos; + vec2 xystart = (-0.5 - f) * stepxy + pos; + vec4 xpos = vec4(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0, xystart.x + stepxy.x * 3.0); gl_FragColor.rgb = - line(xystart, -1, linetaps) * columntaps.r + - line(xystart, 0, linetaps) * columntaps.g + - line(xystart, 1, linetaps) * columntaps.b + - line(xystart, 2, linetaps) * columntaps.a; + line(xystart.y , xpos, linetaps) * columntaps.r + + line(xystart.y + stepxy.y , xpos, linetaps) * columntaps.g + + line(xystart.y + stepxy.y * 2.0, xpos, linetaps) * columntaps.b + + line(xystart.y + stepxy.y * 3.0, xpos, linetaps) * columntaps.a; gl_FragColor.a = gl_Color.a; } diff --git a/system/shaders/convolution-6x6.glsl b/system/shaders/convolution-6x6.glsl index 7741a8c57f..f37dd6105a 100644 --- a/system/shaders/convolution-6x6.glsl +++ b/system/shaders/convolution-6x6.glsl @@ -1,22 +1,25 @@ -#version 130 - uniform sampler2D img; uniform sampler1D kernelTex; uniform vec2 stepxy; uniform float m_stretch; -out vec4 gl_FragColor; -in vec4 gl_TexCoord[]; -in vec4 gl_Color; + +//nvidia's half is a 16 bit float and can bring some speed improvements +//without affecting quality +#ifndef __GLSL_CG_DATA_TYPES + #define half float + #define half3 vec3 + #define half4 vec4 +#endif #if (HAS_FLOAT_TEXTURE) -vec3 weight(float pos) +half3 weight(float pos) { - return texture(kernelTex, pos).rgb; + return texture1D(kernelTex, pos).rgb; } #else -vec3 weight(float pos) +half3 weight(float pos) { - return texture(kernelTex, pos).rgb * 2.0 - 1.0; + return texture1D(kernelTex, pos).rgb * 2.0 - 1.0; } #endif @@ -33,15 +36,20 @@ vec2 stretch(vec2 pos) #endif } -vec3 line (vec2 pos, const int yoffset, vec3 linetaps1, vec3 linetaps2) +half3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +half3 line (float ypos, vec3 xpos1, vec3 xpos2, half3 linetaps1, half3 linetaps2) { return - textureOffset(img, pos, ivec2(-2, yoffset)).rgb * linetaps1.r + - textureOffset(img, pos, ivec2(-1, yoffset)).rgb * linetaps2.r + - textureOffset(img, pos, ivec2( 0, yoffset)).rgb * linetaps1.g + - textureOffset(img, pos, ivec2( 1, yoffset)).rgb * linetaps2.g + - textureOffset(img, pos, ivec2( 2, yoffset)).rgb * linetaps1.b + - textureOffset(img, pos, ivec2( 3, yoffset)).rgb * linetaps2.b; + pixel(xpos1.r, ypos) * linetaps1.r + + pixel(xpos1.g, ypos) * linetaps2.r + + pixel(xpos1.b, ypos) * linetaps1.g + + pixel(xpos2.r, ypos) * linetaps2.g + + pixel(xpos2.g, ypos) * linetaps1.b + + pixel(xpos2.b, ypos) * linetaps2.b; } void main() @@ -49,28 +57,30 @@ void main() vec2 pos = stretch(gl_TexCoord[0].xy); vec2 f = fract(pos / stepxy); - vec3 linetaps1 = weight((1.0 - f.x) / 2.0); - vec3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5); - vec3 columntaps1 = weight((1.0 - f.y) / 2.0); - vec3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5); + half3 linetaps1 = weight((1.0 - f.x) / 2.0); + half3 linetaps2 = weight((1.0 - f.x) / 2.0 + 0.5); + half3 columntaps1 = weight((1.0 - f.y) / 2.0); + half3 columntaps2 = weight((1.0 - f.y) / 2.0 + 0.5); //make sure all taps added together is exactly 1.0, otherwise some (very small) distortion can occur - float sum = linetaps1.r + linetaps1.g + linetaps1.b + linetaps2.r + linetaps2.g + linetaps2.b; + half sum = linetaps1.r + linetaps1.g + linetaps1.b + linetaps2.r + linetaps2.g + linetaps2.b; linetaps1 /= sum; linetaps2 /= sum; sum = columntaps1.r + columntaps1.g + columntaps1.b + columntaps2.r + columntaps2.g + columntaps2.b; columntaps1 /= sum; columntaps2 /= sum; - vec2 xystart = (0.5 - f) * stepxy + pos; + vec2 xystart = (-1.5 - f) * stepxy + pos; + vec3 xpos1 = vec3(xystart.x, xystart.x + stepxy.x, xystart.x + stepxy.x * 2.0); + vec3 xpos2 = vec3(xystart.x + stepxy.x * 3.0, xystart.x + stepxy.x * 4.0, xystart.x + stepxy.x * 5.0); gl_FragColor.rgb = - line(xystart, -2, linetaps1, linetaps2) * columntaps1.r + - line(xystart, -1, linetaps1, linetaps2) * columntaps2.r + - line(xystart, 0, linetaps1, linetaps2) * columntaps1.g + - line(xystart, 1, linetaps1, linetaps2) * columntaps2.g + - line(xystart, 2, linetaps1, linetaps2) * columntaps1.b + - line(xystart, 3, linetaps1, linetaps2) * columntaps2.b; + line(xystart.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps1.r + + line(xystart.y + stepxy.y , xpos1, xpos2, linetaps1, linetaps2) * columntaps2.r + + line(xystart.y + stepxy.y * 2.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.g + + line(xystart.y + stepxy.y * 3.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.g + + line(xystart.y + stepxy.y * 4.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps1.b + + line(xystart.y + stepxy.y * 5.0, xpos1, xpos2, linetaps1, linetaps2) * columntaps2.b; gl_FragColor.a = gl_Color.a; } |