diff options
Diffstat (limited to 'system/shaders/GL/1.2')
-rw-r--r-- | system/shaders/GL/1.2/gl_convolution-4x4.glsl | 89 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_convolution-6x6.glsl | 100 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_output.glsl | 58 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_default.glsl | 29 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_fonts.glsl | 34 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_multi.glsl | 32 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl | 33 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_texture.glsl | 31 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl | 30 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_vert.glsl | 40 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_shader_vert_default.glsl | 31 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_stretch.glsl | 41 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_videofilter_frag.glsl | 30 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_videofilter_vertex.glsl | 34 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl | 131 | ||||
-rw-r--r-- | system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl | 38 |
16 files changed, 781 insertions, 0 deletions
diff --git a/system/shaders/GL/1.2/gl_convolution-4x4.glsl b/system/shaders/GL/1.2/gl_convolution-4x4.glsl new file mode 100644 index 0000000..8c97423 --- /dev/null +++ b/system/shaders/GL/1.2/gl_convolution-4x4.glsl @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +uniform float m_alpha; +varying vec2 m_cord; +uniform sampler1D kernelTex; + +vec4 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture1D(kernelTex, pos); +#else + return texture1D(kernelTex, pos) * 2.0 - 1.0; +#endif +} + +vec2 stretch(vec2 pos) +{ +#if (XBMC_STRETCH) + // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b. + // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5 + // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1) + float x = pos.x - 0.5; + return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y); +#else + return pos; +#endif +} + +vec3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +vec3 line (float ypos, vec4 xpos, vec4 linetaps) +{ + return + pixel(xpos.r, ypos) * linetaps.r + + pixel(xpos.g, ypos) * linetaps.g + + pixel(xpos.b, ypos) * linetaps.b + + pixel(xpos.a, ypos) * linetaps.a; +} + +vec4 process() +{ + vec4 rgb; + vec2 pos = stretch(m_cord) + stepxy * 0.5; + vec2 f = fract(pos / stepxy); + + vec4 linetaps = weight(1.0 - f.x); + vec4 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 = (-1.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); + + rgb.rgb = + 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; + + rgb.a = m_alpha; + + return rgb; +} diff --git a/system/shaders/GL/1.2/gl_convolution-6x6.glsl b/system/shaders/GL/1.2/gl_convolution-6x6.glsl new file mode 100644 index 0000000..26c9f49 --- /dev/null +++ b/system/shaders/GL/1.2/gl_convolution-6x6.glsl @@ -0,0 +1,100 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +uniform float m_alpha; +varying vec2 m_cord; +uniform sampler1D kernelTex; + +vec3 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture1D(kernelTex, pos).rgb; +#else + return texture1D(kernelTex, pos).rgb * 2.0 - 1.0; +#endif +} + +vec2 stretch(vec2 pos) +{ +#if (XBMC_STRETCH) + // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b. + // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5 + // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1) + float x = pos.x - 0.5; + return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y); +#else + return pos; +#endif +} + +vec3 pixel(float xpos, float ypos) +{ + return texture2D(img, vec2(xpos, ypos)).rgb; +} + +vec3 line (float ypos, vec3 xpos1, vec3 xpos2, vec3 linetaps1, vec3 linetaps2) +{ + return + 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; +} + +vec4 process() +{ + vec4 rgb; + vec2 pos = stretch(m_cord) + stepxy * 0.5; + 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); + + //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; + linetaps1 /= sum; + linetaps2 /= sum; + sum = columntaps1.r + columntaps1.g + columntaps1.b + columntaps2.r + columntaps2.g + columntaps2.b; + columntaps1 /= sum; + columntaps2 /= sum; + + vec2 xystart = (-2.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); + + rgb.rgb = + 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; + + rgb.a = m_alpha; + + return rgb; +} diff --git a/system/shaders/GL/1.2/gl_output.glsl b/system/shaders/GL/1.2/gl_output.glsl new file mode 100644 index 0000000..d3294a8 --- /dev/null +++ b/system/shaders/GL/1.2/gl_output.glsl @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2010-2017 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + + +#if defined(XBMC_DITHER) +uniform sampler2D m_dither; +uniform float m_ditherquant; +uniform vec2 m_dithersize; +#endif +#if defined(KODI_3DLUT) +uniform float m_CLUTsize; +uniform sampler3D m_CLUT; +#endif + +void main() +{ + vec4 rgb = process(); + +#if defined(KODI_3DLUT) + // FIXME: can this be optimized? + rgb = texture3D(m_CLUT, (rgb.rgb*(m_CLUTsize-1.0) + 0.5) / m_CLUTsize); +#endif + +#if defined(XBMC_FULLRANGE) +#if __VERSION__ <= 120 + rgb = (rgb-(16.0/255.0)) * 255.0/219.0; +#else + rgb = clamp((rgb-(16.0/255.0)) * 255.0/219.0, 0, 1); +#endif +#endif + +#if defined(XBMC_DITHER) + vec2 ditherpos = gl_FragCoord.xy / m_dithersize; + // ditherval is multiplied by 65536/(dither_size^2) to make it [0,1[ + // FIXME: scale dither values before uploading? + float ditherval = texture2D(m_dither, ditherpos).r * 16.0; + rgb = floor(rgb * m_ditherquant + ditherval) / m_ditherquant; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_default.glsl b/system/shaders/GL/1.2/gl_shader_frag_default.glsl new file mode 100644 index 0000000..d9aba5f --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_default.glsl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform vec4 m_unicol; + +// SM_DEFAULT shader +void main () +{ + gl_FragColor = m_unicol; +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl b/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl new file mode 100644 index 0000000..eed605f --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_fonts.glsl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D m_samp0; +varying vec4 m_cord0; +varying vec4 m_colour; + +// SM_FONTS shader +void main () +{ + gl_FragColor.r = m_colour.r; + gl_FragColor.g = m_colour.g; + gl_FragColor.b = m_colour.b; + gl_FragColor.a = m_colour.a * texture2D(m_samp0, m_cord0.xy).r; +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_multi.glsl b/system/shaders/GL/1.2/gl_shader_frag_multi.glsl new file mode 100644 index 0000000..804a716 --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_multi.glsl @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; + +// SM_MULTI shader +void main () +{ + gl_FragColor.rgba = (texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy)).rgba; +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl b/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl new file mode 100644 index 0000000..20622d2 --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_multi_blendcolor.glsl @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +uniform vec4 m_unicol; + +// SM_MULTI shader +void main () +{ + gl_FragColor.rgba = m_unicol * texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy); +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_texture.glsl b/system/shaders/GL/1.2/gl_shader_frag_texture.glsl new file mode 100644 index 0000000..c15681f --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_texture.glsl @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D m_samp0; +uniform vec4 m_unicol; +varying vec4 m_cord0; + +// SM_TEXTURE shader +void main () +{ + gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba * m_unicol); +} diff --git a/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl b/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl new file mode 100644 index 0000000..16a1f8b --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_frag_texture_noblend.glsl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D m_samp0; +varying vec4 m_cord0; + +// SM_TEXTURE_NOBLEND shader +void main () +{ + gl_FragColor.rgba = vec4(texture2D(m_samp0, m_cord0.xy).rgba); +} diff --git a/system/shaders/GL/1.2/gl_shader_vert.glsl b/system/shaders/GL/1.2/gl_shader_vert.glsl new file mode 100644 index 0000000..7c10b5f --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_vert.glsl @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +attribute vec4 m_attrpos; +attribute vec4 m_attrcol; +attribute vec4 m_attrcord0; +attribute vec4 m_attrcord1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying vec4 m_colour; +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; + m_colour = m_attrcol; + m_cord0 = m_attrcord0; + m_cord1 = m_attrcord1; +} diff --git a/system/shaders/GL/1.2/gl_shader_vert_default.glsl b/system/shaders/GL/1.2/gl_shader_vert_default.glsl new file mode 100644 index 0000000..554e15c --- /dev/null +++ b/system/shaders/GL/1.2/gl_shader_vert_default.glsl @@ -0,0 +1,31 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +attribute vec4 m_attrpos; +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; +} diff --git a/system/shaders/GL/1.2/gl_stretch.glsl b/system/shaders/GL/1.2/gl_stretch.glsl new file mode 100644 index 0000000..9cc3388 --- /dev/null +++ b/system/shaders/GL/1.2/gl_stretch.glsl @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D img; +uniform float m_stretch; +uniform float m_alpha; +varying vec2 m_cord; + +vec2 stretch(vec2 pos) +{ + // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b. + // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5 + // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1) + float x = pos.x - 0.5; + return vec2(mix(x * abs(x) * 2.0, x, m_stretch) + 0.5, pos.y); +} + +void main() +{ + gl_FragColor.rgb = texture2D(img, stretch(m_cord)).rgb; + gl_FragColor.a = m_alpha; +} diff --git a/system/shaders/GL/1.2/gl_videofilter_frag.glsl b/system/shaders/GL/1.2/gl_videofilter_frag.glsl new file mode 100644 index 0000000..ff7af3b --- /dev/null +++ b/system/shaders/GL/1.2/gl_videofilter_frag.glsl @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +uniform sampler2D img; +varying vec2 m_cord; + +void main() +{ + gl_FragColor.rgb = texture2D(img, m_cord).rgb; + gl_FragColor.a = gl_Color.a; +} diff --git a/system/shaders/GL/1.2/gl_videofilter_vertex.glsl b/system/shaders/GL/1.2/gl_videofilter_vertex.glsl new file mode 100644 index 0000000..aa124b5 --- /dev/null +++ b/system/shaders/GL/1.2/gl_videofilter_vertex.glsl @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#version 120 + +attribute vec4 m_attrpos; +attribute vec2 m_attrcord; +varying vec2 m_cord; +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; + m_cord = m_attrcord; +} diff --git a/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl b/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl new file mode 100644 index 0000000..57c3a17 --- /dev/null +++ b/system/shaders/GL/1.2/gl_yuv2rgb_basic.glsl @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +#if(XBMC_texture_rectangle) +# extension GL_ARB_texture_rectangle : enable +# define texture2D texture2DRect +# define sampler2D sampler2DRect +#endif + +uniform sampler2D m_sampY; +uniform sampler2D m_sampU; +uniform sampler2D m_sampV; +varying vec2 m_cordY; +varying vec2 m_cordU; +varying vec2 m_cordV; +uniform vec2 m_step; +uniform mat4 m_yuvmat; +uniform float m_stretch; +uniform mat3 m_primMat; +uniform float m_gammaDstInv; +uniform float m_gammaSrc; +uniform float m_alpha; + +vec2 stretch(vec2 pos) +{ +#if (XBMC_STRETCH) + // our transform should map [0..1] to itself, with f(0) = 0, f(1) = 1, f(0.5) = 0.5, and f'(0.5) = b. + // a simple curve to do this is g(x) = b(x-0.5) + (1-b)2^(n-1)(x-0.5)^n + 0.5 + // where the power preserves sign. n = 2 is the simplest non-linear case (required when b != 1) + #if(XBMC_texture_rectangle) + float x = (pos.x * m_step.x) - 0.5; + return vec2((mix(2.0 * x * abs(x), x, m_stretch) + 0.5) / m_step.x, pos.y); + #else + float x = pos.x - 0.5; + return vec2(mix(2.0 * x * abs(x), x, m_stretch) + 0.5, pos.y); + #endif +#else + return pos; +#endif +} + +vec4 process() +{ + vec4 rgb; +#if defined(XBMC_YV12) + + vec4 yuv; + yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r + , texture2D(m_sampU, stretch(m_cordU)).r + , texture2D(m_sampV, stretch(m_cordV)).r + , 1.0 ); + + rgb = m_yuvmat * yuv; + rgb.a = m_alpha; + +#elif defined(XBMC_NV12) + + vec4 yuv; + yuv.rgba = vec4( texture2D(m_sampY, stretch(m_cordY)).r + , texture2D(m_sampU, stretch(m_cordU)).rg + , 1.0 ); + + rgb = m_yuvmat * yuv; + rgb.a = m_alpha; + +#elif defined(XBMC_YUY2) || defined(XBMC_UYVY) + +#if(XBMC_texture_rectangle) + vec2 stepxy = vec2(1.0, 1.0); + vec2 pos = stretch(m_cordY); + pos = vec2(pos.x - 0.25, pos.y); + vec2 f = fract(pos); +#else + vec2 stepxy = m_step; + vec2 pos = stretch(m_cordY); + pos = vec2(pos.x - stepxy.x * 0.25, pos.y); + vec2 f = fract(pos / stepxy); +#endif + + //y axis will be correctly interpolated by opengl + //x axis will not, so we grab two pixels at the center of two columns and interpolate ourselves + vec4 c1 = texture2D(m_sampY, vec2(pos.x + (0.5 - f.x) * stepxy.x, pos.y)); + vec4 c2 = texture2D(m_sampY, vec2(pos.x + (1.5 - f.x) * stepxy.x, pos.y)); + + /* each pixel has two Y subpixels and one UV subpixel + YUV Y YUV + check if we're left or right of the middle Y subpixel and interpolate accordingly*/ +#ifdef XBMC_YUY2 //BGRA = YUYV + float leftY = mix(c1.b, c1.r, f.x * 2.0); + float rightY = mix(c1.r, c2.b, f.x * 2.0 - 1.0); + vec2 outUV = mix(c1.ga, c2.ga, f.x); +#else //BGRA = UYVY + float leftY = mix(c1.g, c1.a, f.x * 2.0); + float rightY = mix(c1.a, c2.g, f.x * 2.0 - 1.0); + vec2 outUV = mix(c1.br, c2.br, f.x); +#endif //XBMC_YUY2 + + float outY = mix(leftY, rightY, step(0.5, f.x)); + + vec4 yuv = vec4(outY, outUV, 1.0); + rgb = m_yuvmat * yuv; + + rgb.a = m_alpha; + +#endif + +#if defined(XBMC_COL_CONVERSION) + rgb.rgb = pow(max(vec3(0), rgb.rgb), vec3(m_gammaSrc)); + rgb.rgb = max(vec3(0), m_primMat * rgb.rgb); + rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv)); +#endif + + return rgb; +} diff --git a/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl b/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl new file mode 100644 index 0000000..cdf3c56 --- /dev/null +++ b/system/shaders/GL/1.2/gl_yuv2rgb_vertex.glsl @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2010-2013 Team XBMC + * http://xbmc.org + * + * This Program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This Program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with XBMC; see the file COPYING. If not, see + * <http://www.gnu.org/licenses/>. + * + */ + +attribute vec4 m_attrpos; +attribute vec2 m_attrcordY; +attribute vec2 m_attrcordU; +attribute vec2 m_attrcordV; +varying vec2 m_cordY; +varying vec2 m_cordU; +varying vec2 m_cordV; +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; + m_cordY = m_attrcordY; + m_cordU = m_attrcordU; + m_cordV = m_attrcordV; +} |