diff options
Diffstat (limited to '')
56 files changed, 2535 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; +} diff --git a/system/shaders/GL/1.5/gl_convolution-4x4.glsl b/system/shaders/GL/1.5/gl_convolution-4x4.glsl new file mode 100644 index 0000000..2a6404e --- /dev/null +++ b/system/shaders/GL/1.5/gl_convolution-4x4.glsl @@ -0,0 +1,71 @@ +#version 150 + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +uniform float m_alpha; +in vec2 m_cord; +out vec4 fragColor; +uniform sampler1D kernelTex; + +vec4 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture(kernelTex, pos); +#else + return texture(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 texture(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.5/gl_convolution-6x6.glsl b/system/shaders/GL/1.5/gl_convolution-6x6.glsl new file mode 100644 index 0000000..b4410cc --- /dev/null +++ b/system/shaders/GL/1.5/gl_convolution-6x6.glsl @@ -0,0 +1,83 @@ +#version 150 + +uniform sampler2D img; +uniform vec2 stepxy; +uniform float m_stretch; +uniform float m_alpha; +in vec2 m_cord; +out vec4 fragColor; +uniform sampler1D kernelTex; + +vec3 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture(kernelTex, pos).rgb; +#else + return texture(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 texture(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.5/gl_output.glsl b/system/shaders/GL/1.5/gl_output.glsl new file mode 100644 index 0000000..9823102 --- /dev/null +++ b/system/shaders/GL/1.5/gl_output.glsl @@ -0,0 +1,37 @@ +#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 = texture(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 = texture(m_dither, ditherpos).r * 16.0; + rgb = floor(rgb * m_ditherquant + ditherval) / m_ditherquant; +#endif + + fragColor = rgb; +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_default.glsl b/system/shaders/GL/1.5/gl_shader_frag_default.glsl new file mode 100644 index 0000000..d57f576 --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_default.glsl @@ -0,0 +1,14 @@ +#version 150 + +uniform vec4 m_unicol; +out vec4 fragColor; + +// SM_DEFAULT shader +void main () +{ + fragColor = m_unicol; +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl b/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl new file mode 100644 index 0000000..1de6ddc --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_fonts.glsl @@ -0,0 +1,19 @@ +#version 150 + +uniform sampler2D m_samp0; +in vec4 m_cord0; +in vec4 m_colour; +out vec4 fragColor; + +// SM_FONTS shader +void main () +{ + fragColor.r = m_colour.r; + fragColor.g = m_colour.g; + fragColor.b = m_colour.b; + fragColor.a = m_colour.a * texture(m_samp0, m_cord0.xy).r; +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_multi.glsl b/system/shaders/GL/1.5/gl_shader_frag_multi.glsl new file mode 100644 index 0000000..3e6412b --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_multi.glsl @@ -0,0 +1,17 @@ +#version 150 + +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +in vec4 m_cord0; +in vec4 m_cord1; +out vec4 fragColor; + +// SM_MULTI shader +void main () +{ + fragColor.rgba = (texture(m_samp0, m_cord0.xy) * texture(m_samp1, m_cord1.xy)).rgba; +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl b/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl new file mode 100644 index 0000000..96310ce --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_multi_blendcolor.glsl @@ -0,0 +1,18 @@ +#version 150 + +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +uniform vec4 m_unicol; +in vec4 m_cord0; +in vec4 m_cord1; +out vec4 fragColor; + +// SM_MULTI shader +void main () +{ + fragColor.rgba = m_unicol * texture(m_samp0, m_cord0.xy) * texture(m_samp1, m_cord1.xy); +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture.glsl new file mode 100644 index 0000000..71b1d21 --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_texture.glsl @@ -0,0 +1,16 @@ +#version 150 + +uniform sampler2D m_samp0; +uniform vec4 m_unicol; +in vec4 m_cord0; +out vec4 fragColor; + +// SM_TEXTURE shader +void main () +{ + fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba * m_unicol); +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl new file mode 100644 index 0000000..def4349 --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_texture_lim.glsl @@ -0,0 +1,15 @@ +#version 150 + +uniform sampler2D m_samp0; +uniform vec4 m_unicol; +in vec4 m_cord0; +out vec4 fragColor; + +// SM_TEXTURE shader +void main () +{ + fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba * m_unicol); +#if !defined(KODI_LIMITED_RANGE) + fragColor.rgb = clamp((fragColor.rgb-(16.0/255.0)) * 255.0/219.0, 0, 1); +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl b/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl new file mode 100644 index 0000000..e5d627e --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_frag_texture_noblend.glsl @@ -0,0 +1,15 @@ +#version 150 + +uniform sampler2D m_samp0; +in vec4 m_cord0; +out vec4 fragColor; + +// SM_TEXTURE_NOBLEND shader +void main () +{ + fragColor.rgba = vec4(texture(m_samp0, m_cord0.xy).rgba); +#if defined(KODI_LIMITED_RANGE) + fragColor.rgb *= (235.0-16.0) / 255.0; + fragColor.rgb += 16.0 / 255.0; +#endif +} diff --git a/system/shaders/GL/1.5/gl_shader_vert.glsl b/system/shaders/GL/1.5/gl_shader_vert.glsl new file mode 100644 index 0000000..a856831 --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_vert.glsl @@ -0,0 +1,20 @@ +#version 150 + +in vec4 m_attrpos; +in vec4 m_attrcol; +in vec4 m_attrcord0; +in vec4 m_attrcord1; +out vec4 m_cord0; +out vec4 m_cord1; +out 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.5/gl_shader_vert_default.glsl b/system/shaders/GL/1.5/gl_shader_vert_default.glsl new file mode 100644 index 0000000..e4f2d7c --- /dev/null +++ b/system/shaders/GL/1.5/gl_shader_vert_default.glsl @@ -0,0 +1,11 @@ +#version 150 + +in 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.5/gl_stretch.glsl b/system/shaders/GL/1.5/gl_stretch.glsl new file mode 100644 index 0000000..9a31e54 --- /dev/null +++ b/system/shaders/GL/1.5/gl_stretch.glsl @@ -0,0 +1,22 @@ +#version 150 + +uniform sampler2D img; +uniform float m_stretch; +uniform float m_alpha; +in vec2 m_cord; +out vec4 fragColor; + +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() +{ + fragColor.rgb = texture(img, stretch(m_cord)).rgb; + fragColor.a = m_alpha; +} diff --git a/system/shaders/GL/1.5/gl_tonemap.glsl b/system/shaders/GL/1.5/gl_tonemap.glsl new file mode 100644 index 0000000..a70dca2 --- /dev/null +++ b/system/shaders/GL/1.5/gl_tonemap.glsl @@ -0,0 +1,50 @@ +#if (defined(KODI_TONE_MAPPING_REINHARD) || defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE)) +const float ST2084_m1 = 2610.0 / (4096.0 * 4.0); +const float ST2084_m2 = (2523.0 / 4096.0) * 128.0; +const float ST2084_c1 = 3424.0 / 4096.0; +const float ST2084_c2 = (2413.0 / 4096.0) * 32.0; +const float ST2084_c3 = (2392.0 / 4096.0) * 32.0; +#endif + +#if defined(KODI_TONE_MAPPING_REINHARD) +float reinhard(float x) +{ + return x * (1.0 + x / (m_toneP1 * m_toneP1)) / (1.0 + x); +} +#endif + +#if defined(KODI_TONE_MAPPING_ACES) +vec3 aces(vec3 x) +{ + float A = 2.51; + float B = 0.03; + float C = 2.43; + float D = 0.59; + float E = 0.14; + return (x * (A * x + B)) / (x * (C * x + D) + E); +} +#endif + +#if defined(KODI_TONE_MAPPING_HABLE) +vec3 hable(vec3 x) +{ + float A = 0.15; + float B = 0.5; + float C = 0.1; + float D = 0.2; + float E = 0.02; + float F = 0.3; + return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; +} +#endif + +#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE)) +vec3 inversePQ(vec3 x) +{ + x = pow(max(x, 0.0), vec3(1.0 / ST2084_m2)); + x = max(x - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * x); + x = pow(x, vec3(1.0 / ST2084_m1)); + return x; +} +#endif + diff --git a/system/shaders/GL/1.5/gl_videofilter_frag.glsl b/system/shaders/GL/1.5/gl_videofilter_frag.glsl new file mode 100644 index 0000000..2eb4155 --- /dev/null +++ b/system/shaders/GL/1.5/gl_videofilter_frag.glsl @@ -0,0 +1,12 @@ +#version 150 + +uniform sampler2D img; +uniform float m_alpha; +in vec2 m_cord; +out vec4 fragColor; + +void main() +{ + fragColor = texture(img, m_cord); + fragColor.a = m_alpha; +} diff --git a/system/shaders/GL/1.5/gl_videofilter_vertex.glsl b/system/shaders/GL/1.5/gl_videofilter_vertex.glsl new file mode 100644 index 0000000..edb8847 --- /dev/null +++ b/system/shaders/GL/1.5/gl_videofilter_vertex.glsl @@ -0,0 +1,14 @@ +#version 150 + +in vec4 m_attrpos; +in vec2 m_attrcord; +out 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.5/gl_yuv2rgb_basic.glsl b/system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl new file mode 100644 index 0000000..7d5605c --- /dev/null +++ b/system/shaders/GL/1.5/gl_yuv2rgb_basic.glsl @@ -0,0 +1,123 @@ +#version 150 + +#if(XBMC_texture_rectangle) +# define texture2D texture2DRect +# define sampler2D sampler2DRect +#endif + +uniform sampler2D m_sampY; +uniform sampler2D m_sampU; +uniform sampler2D m_sampV; +uniform vec2 m_step; +uniform mat4 m_yuvmat; +uniform float m_stretch; +uniform float m_alpha; +uniform mat3 m_primMat; +uniform float m_gammaDstInv; +uniform float m_gammaSrc; +uniform float m_toneP1; +uniform float m_luminance; +uniform vec3 m_coefsDst; +in vec2 m_cordY; +in vec2 m_cordU; +in vec2 m_cordV; +out vec4 fragColor; + +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; + vec4 yuv; + +#if defined(XBMC_YV12) + + yuv.rgba = vec4( texture(m_sampY, stretch(m_cordY)).r + , texture(m_sampU, stretch(m_cordU)).r + , texture(m_sampV, stretch(m_cordV)).r + , 1.0 ); + +#elif defined(XBMC_NV12) + + yuv.rgba = vec4( texture(m_sampY, stretch(m_cordY)).r + , texture(m_sampU, stretch(m_cordU)).rg + , 1.0 ); + +#elif defined(XBMC_YUY2) || defined(XBMC_UYVY) + + vec2 stepxy = m_step; + vec2 pos = stretch(m_cordY); + pos = vec2(pos.x - stepxy.x * 0.25, pos.y); + vec2 f = fract(pos / stepxy); + + //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 = texture(m_sampY, vec2(pos.x + (0.5 - f.x) * stepxy.x, pos.y)); + vec4 c2 = texture(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)); + + yuv = vec4(outY, outUV, 1.0); + +#endif + + rgb = m_yuvmat * yuv; + rgb.a = m_alpha; + +#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)); + +#if defined(KODI_TONE_MAPPING_REINHARD) + float luma = dot(rgb.rgb, m_coefsDst); + rgb.rgb *= reinhard(luma) / luma; + +#elif defined(KODI_TONE_MAPPING_ACES) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1); + rgb.rgb = aces(rgb.rgb); + rgb.rgb *= (1.24 / m_toneP1); + rgb.rgb = pow(rgb.rgb, vec3(0.27)); + +#elif defined(KODI_TONE_MAPPING_HABLE) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= m_toneP1; + float wp = m_luminance / 100.0; + rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp)); + rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2)); +#endif + +#endif + + return rgb; +} diff --git a/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl b/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl new file mode 100644 index 0000000..4772bd4 --- /dev/null +++ b/system/shaders/GL/1.5/gl_yuv2rgb_vertex.glsl @@ -0,0 +1,20 @@ +#version 150 + +uniform mat4 m_proj; +uniform mat4 m_model; +in vec4 m_attrpos; +in vec2 m_attrcordY; +in vec2 m_attrcordU; +in vec2 m_attrcordV; +out vec2 m_cordY; +out vec2 m_cordU; +out vec2 m_cordV; + +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; +} diff --git a/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl new file mode 100644 index 0000000..8a4658c --- /dev/null +++ b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl @@ -0,0 +1,141 @@ +#version 400 + +#if(XBMC_texture_rectangle) +# define texture2D texture2DRect +# define sampler2D sampler2DRect +#endif + +uniform sampler2D m_sampY; +uniform sampler2D m_sampU; +uniform sampler2D m_sampV; +uniform vec2 m_step; +uniform mat4 m_yuvmat; +uniform float m_stretch; +uniform float m_alpha; +uniform sampler1D m_kernelTex; +uniform mat3 m_primMat; +uniform float m_gammaDstInv; +uniform float m_gammaSrc; +uniform float m_toneP1; +uniform float m_luminance; +uniform vec3 m_coefsDst; +in vec2 m_cordY; +in vec2 m_cordU; +in vec2 m_cordV; +out vec4 fragColor; + +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[4] load4x4_0(sampler2D sampler, vec2 pos) +{ + vec4[4] tex4x4; + vec4 tex2x2 = textureGather(sampler, pos, 0); + tex4x4[0].xy = tex2x2.wz; + tex4x4[1].xy = tex2x2.xy; + tex2x2 = textureGatherOffset(sampler, pos, ivec2(2,0), 0); + tex4x4[0].zw = tex2x2.wz; + tex4x4[1].zw = tex2x2.xy; + tex2x2 = textureGatherOffset(sampler, pos, ivec2(0,2), 0); + tex4x4[2].xy = tex2x2.wz; + tex4x4[3].xy = tex2x2.xy; + tex2x2 = textureGatherOffset(sampler, pos, ivec2(2,2), 0); + tex4x4[2].zw = tex2x2.wz; + tex4x4[3].zw = tex2x2.xy; + return tex4x4; +} + +float filter_0(sampler2D sampler, vec2 coord) +{ + vec2 pos = coord + m_step * 0.5; + vec2 f = fract(pos / m_step); + + vec4 linetaps = texture(m_kernelTex, 1.0 - f.x); + vec4 coltaps = texture(m_kernelTex, 1.0 - f.y); + linetaps /= linetaps.r + linetaps.g + linetaps.b + linetaps.a; + coltaps /= coltaps.r + coltaps.g + coltaps.b + coltaps.a; + mat4 conv; + conv[0] = linetaps * coltaps.x; + conv[1] = linetaps * coltaps.y; + conv[2] = linetaps * coltaps.z; + conv[3] = linetaps * coltaps.w; + + vec2 startPos = (-1.0 - f) * m_step + pos; + vec4[4] tex4x4 = load4x4_0(sampler, startPos); + vec4 imageLine0 = tex4x4[0]; + vec4 imageLine1 = tex4x4[1]; + vec4 imageLine2 = tex4x4[2]; + vec4 imageLine3 = tex4x4[3]; + + return dot(imageLine0, conv[0]) + + dot(imageLine1, conv[1]) + + dot(imageLine2, conv[2]) + + dot(imageLine3, conv[3]); +} + +vec4 process() +{ + vec4 rgb; + vec4 yuv; + +#if defined(XBMC_YV12) + + yuv = vec4(filter_0(m_sampY, stretch(m_cordY)), + texture(m_sampU, stretch(m_cordU)).r, + texture(m_sampV, stretch(m_cordV)).r, + 1.0); + +#elif defined(XBMC_NV12) + + yuv = vec4(filter_0(m_sampY, stretch(m_cordY)), + texture(m_sampU, stretch(m_cordU)).rg, + 1.0); + +#endif + + rgb = m_yuvmat * yuv; + rgb.a = m_alpha; + +#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)); + +#if defined(KODI_TONE_MAPPING_REINHARD) + float luma = dot(rgb.rgb, m_coefsDst); + rgb.rgb *= reinhard(luma) / luma; + +#elif defined(KODI_TONE_MAPPING_ACES) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1); + rgb.rgb = aces(rgb.rgb); + rgb.rgb *= (1.24 / m_toneP1); + rgb.rgb = pow(rgb.rgb, vec3(0.27)); + +#elif defined(KODI_TONE_MAPPING_HABLE) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= m_toneP1; + float wp = m_luminance / 100.0; + rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp)); + rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2)); +#endif + +#endif + + return rgb; +} diff --git a/system/shaders/GLES/2.0/gles_convolution-4x4.frag b/system/shaders/GLES/2.0/gles_convolution-4x4.frag new file mode 100644 index 0000000..3043b10 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_convolution-4x4.frag @@ -0,0 +1,78 @@ +/* + * 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 100 + +precision highp float; + +uniform sampler2D img; +uniform vec2 stepxy; +varying vec2 cord; +uniform float m_alpha; +uniform sampler2D kernelTex; + +vec4 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture2D(kernelTex, vec2(pos, 0.5)); +#else + return texture2D(kernelTex, vec2(pos - 0.5)) * 2.0 - 1.0; +#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; +} + +void main() +{ + vec4 rgb; + vec2 pos = 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; + + gl_FragColor = rgb; +} + diff --git a/system/shaders/GLES/2.0/gles_convolution-6x6.frag b/system/shaders/GLES/2.0/gles_convolution-6x6.frag new file mode 100644 index 0000000..d043c75 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_convolution-6x6.frag @@ -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/>. + * + */ + +#version 100 + +precision highp float; + +uniform sampler2D img; +uniform vec2 stepxy; +varying vec2 cord; +uniform float m_alpha; +uniform sampler2D kernelTex; + +vec3 weight(float pos) +{ +#if defined(HAS_FLOAT_TEXTURE) + return texture2D(kernelTex, vec2(pos, 0.5)).rgb; +#else + return texture2D(kernelTex, vec2(pos - 0.5)).rgb * 2.0 - 1.0; +#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; +} + +void main() +{ + vec4 rgb; + vec2 pos = 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; + + gl_FragColor = rgb; +} + diff --git a/system/shaders/GLES/2.0/gles_shader.vert b/system/shaders/GLES/2.0/gles_shader.vert new file mode 100644 index 0000000..890acbb --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader.vert @@ -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 100 + +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 lowp vec4 m_colour; +uniform mat4 m_proj; +uniform mat4 m_model; +uniform mat4 m_coord0Matrix; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; + m_colour = m_attrcol; + m_cord0 = m_coord0Matrix * m_attrcord0; + m_cord1 = m_attrcord1; +} diff --git a/system/shaders/GLES/2.0/gles_shader_default.frag b/system/shaders/GLES/2.0/gles_shader_default.frag new file mode 100644 index 0000000..f213360 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_default.frag @@ -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/>. + * + */ + +#version 100 + +precision mediump float; +uniform lowp vec4 m_unicol; + +void main () +{ + vec4 rgb; + + rgb = m_unicol; + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_fonts.frag b/system/shaders/GLES/2.0/gles_shader_fonts.frag new file mode 100644 index 0000000..075d26f --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_fonts.frag @@ -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 100 + +precision mediump float; +uniform sampler2D m_samp0; +varying vec4 m_cord0; +varying lowp vec4 m_colour; + +void main () +{ + vec4 rgb; + + rgb.rgb = m_colour.rgb; + rgb.a = m_colour.a * texture2D(m_samp0, m_cord0.xy).a; + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_multi.frag b/system/shaders/GLES/2.0/gles_shader_multi.frag new file mode 100644 index 0000000..9f28898 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_multi.frag @@ -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 100 + +precision mediump float; +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy); + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag new file mode 100644 index 0000000..35153da --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_multi_blendcolor.frag @@ -0,0 +1,42 @@ +/* + * 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 100 + +precision mediump float; +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +uniform lowp vec4 m_unicol; + +void main () +{ + vec4 rgb; + + rgb = m_unicol * texture2D(m_samp0, m_cord0.xy) * texture2D(m_samp1, m_cord1.xy); + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_rgba.frag b/system/shaders/GLES/2.0/gles_shader_rgba.frag new file mode 100644 index 0000000..cdbb076 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_rgba.frag @@ -0,0 +1,43 @@ +/* + * 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 100 + +precision mediump float; +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying lowp vec4 m_colour; +uniform int m_method; + +uniform float m_brightness; +uniform float m_contrast; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy); + rgb *= m_contrast; + rgb += m_brightness; + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag b/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag new file mode 100644 index 0000000..3f08da0 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_rgba_blendcolor.frag @@ -0,0 +1,43 @@ +/* + * 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 100 + +precision mediump float; +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying lowp vec4 m_colour; +uniform int m_method; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy).rgba * m_colour; + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag b/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag new file mode 100644 index 0000000..fd4a83b --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_rgba_bob.frag @@ -0,0 +1,56 @@ +/* + * 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 100 + +precision highp float; +uniform sampler2D m_samp0; +uniform sampler2D m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying lowp vec4 m_colour; +uniform int m_method; +uniform int m_field; +uniform float m_step; + +uniform float m_brightness; +uniform float m_contrast; + +void main () +{ + vec2 source; + source = m_cord0.xy; + + float temp1 = mod(source.y, 2.0 * m_step); + float temp2 = source.y - temp1; + source.y = temp2 + m_step / 2.0 - float(m_field) * m_step; + + // Blend missing line + vec2 below; + float bstep = step(m_step, temp1); + below.x = source.x; + below.y = source.y + (2.0 * m_step * bstep); + + vec4 color = mix(texture2D(m_samp0, source), texture2D(m_samp0, below), 0.5); + color *= m_contrast; + color += m_brightness; + + gl_FragColor = color; +} diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag b/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag new file mode 100644 index 0000000..16894af --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_rgba_bob_oes.frag @@ -0,0 +1,58 @@ +/* + * 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 100 + +#extension GL_OES_EGL_image_external : require + +precision highp float; +uniform samplerExternalOES m_samp0; +uniform samplerExternalOES m_samp1; +varying vec4 m_cord0; +varying vec4 m_cord1; +varying lowp vec4 m_colour; +uniform int m_method; +uniform int m_field; +uniform float m_step; + +uniform float m_brightness; +uniform float m_contrast; + +void main () +{ + vec2 source; + source = m_cord0.xy; + + float temp1 = mod(source.y, 2.0 * m_step); + float temp2 = source.y - temp1; + source.y = temp2 + m_step / 2.0 - float(m_field) * m_step; + + // Blend missing line + vec2 below; + float bstep = step(m_step, temp1); + below.x = source.x; + below.y = source.y + (2.0*m_step * bstep); + + vec4 color = mix(texture2D(m_samp0, source), texture2D(m_samp0, below), 0.5); + color *= m_contrast; + color += m_brightness; + + gl_FragColor = color; +} diff --git a/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag b/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag new file mode 100644 index 0000000..2936954 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_rgba_oes.frag @@ -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 100 + +#extension GL_OES_EGL_image_external : require + +precision mediump float; +uniform samplerExternalOES m_samp0; +varying vec4 m_cord0; + +uniform float m_brightness; +uniform float m_contrast; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy); + rgb *= m_contrast; + rgb += m_brightness; + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_texture.frag b/system/shaders/GLES/2.0/gles_shader_texture.frag new file mode 100644 index 0000000..a2ac2de --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_texture.frag @@ -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 100 + +precision mediump float; +uniform sampler2D m_samp0; +uniform lowp vec4 m_unicol; +varying vec4 m_cord0; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy).rgba * m_unicol; + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag b/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag new file mode 100644 index 0000000..9f478ed --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_texture_noalpha.frag @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2019 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#version 100 + +precision mediump float; +uniform sampler2D m_samp0; +varying vec4 m_cord0; + +void main () +{ + vec3 rgb = texture2D(m_samp0, m_cord0.xy).rgb; + +#if defined(KODI_LIMITED_RANGE) + rgb *= (235.0 - 16.0) / 255.0; + rgb += 16.0 / 255.0; +#endif + + gl_FragColor = vec4(rgb, 1.0); +} diff --git a/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag new file mode 100644 index 0000000..8cc66c9 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_shader_texture_noblend.frag @@ -0,0 +1,39 @@ +/* + * 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 100 + +precision mediump float; +uniform sampler2D m_samp0; +varying vec4 m_cord0; + +void main () +{ + vec4 rgb; + + rgb = texture2D(m_samp0, m_cord0.xy); + +#if defined(KODI_LIMITED_RANGE) + rgb.rgb *= (235.0 - 16.0) / 255.0; + rgb.rgb += 16.0 / 255.0; +#endif + + gl_FragColor = rgb; +} diff --git a/system/shaders/GLES/2.0/gles_tonemap.frag b/system/shaders/GLES/2.0/gles_tonemap.frag new file mode 100644 index 0000000..28b2402 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_tonemap.frag @@ -0,0 +1,50 @@ +#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE)) +const float ST2084_m1 = 2610.0 / (4096.0 * 4.0); +const float ST2084_m2 = (2523.0 / 4096.0) * 128.0; +const float ST2084_c1 = 3424.0 / 4096.0; +const float ST2084_c2 = (2413.0 / 4096.0) * 32.0; +const float ST2084_c3 = (2392.0 / 4096.0) * 32.0; +#endif + +#if defined(KODI_TONE_MAPPING_REINHARD) +float reinhard(float x) +{ + return x * (1.0 + x / (m_toneP1 * m_toneP1)) / (1.0 + x); +} +#endif + +#if defined(KODI_TONE_MAPPING_ACES) +vec3 aces(vec3 x) +{ + float A = 2.51; + float B = 0.03; + float C = 2.43; + float D = 0.59; + float E = 0.14; + return (x * (A * x + B)) / (x * (C * x + D) + E); +} +#endif + +#if defined(KODI_TONE_MAPPING_HABLE) +vec3 hable(vec3 x) +{ + float A = 0.15; + float B = 0.5; + float C = 0.1; + float D = 0.2; + float E = 0.02; + float F = 0.3; + return ((x * (A * x + C * B) + D * E) / (x * (A * x + B) + D * F)) - E / F; +} +#endif + +#if (defined(KODI_TONE_MAPPING_ACES) || defined(KODI_TONE_MAPPING_HABLE)) +vec3 inversePQ(vec3 x) +{ + x = pow(max(x, 0.0), vec3(1.0 / ST2084_m2)); + x = max(x - ST2084_c1, 0.0) / (ST2084_c2 - ST2084_c3 * x); + x = pow(x, vec3(1.0 / ST2084_m1)); + return x; +} +#endif + diff --git a/system/shaders/GLES/2.0/gles_videofilter.frag b/system/shaders/GLES/2.0/gles_videofilter.frag new file mode 100644 index 0000000..d4c15ee --- /dev/null +++ b/system/shaders/GLES/2.0/gles_videofilter.frag @@ -0,0 +1,11 @@ +#version 100 + +precision mediump float; + +uniform sampler2D img; +varying vec2 cord; + +void main() +{ + gl_FragColor = texture2D(img, cord); +}
\ No newline at end of file diff --git a/system/shaders/GLES/2.0/gles_videofilter.vert b/system/shaders/GLES/2.0/gles_videofilter.vert new file mode 100644 index 0000000..2d5a0f9 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_videofilter.vert @@ -0,0 +1,14 @@ +#version 100 + +attribute vec4 m_attrpos; +attribute vec2 m_attrcord; +varying vec2 cord; +uniform mat4 m_proj; +uniform mat4 m_model; + +void main () +{ + mat4 mvp = m_proj * m_model; + gl_Position = mvp * m_attrpos; + cord = m_attrcord.xy; +} diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb.vert b/system/shaders/GLES/2.0/gles_yuv2rgb.vert new file mode 100644 index 0000000..bc437af --- /dev/null +++ b/system/shaders/GLES/2.0/gles_yuv2rgb.vert @@ -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 100 + +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; +} diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag b/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag new file mode 100644 index 0000000..d76a3b8 --- /dev/null +++ b/system/shaders/GLES/2.0/gles_yuv2rgb_basic.frag @@ -0,0 +1,93 @@ +/* + * 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 100 + +precision mediump float; + +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 mat3 m_primMat; +uniform float m_gammaDstInv; +uniform float m_gammaSrc; +uniform float m_toneP1; +uniform float m_luminance; +uniform vec3 m_coefsDst; +uniform float m_alpha; + +void main() +{ + vec4 rgb; + vec4 yuv; + +#if defined(XBMC_YV12) || defined(XBMC_NV12) + + yuv = vec4(texture2D(m_sampY, m_cordY).r, + texture2D(m_sampU, m_cordU).g, + texture2D(m_sampV, m_cordV).a, + 1.0); + +#elif defined(XBMC_NV12_RRG) + + yuv = vec4(texture2D(m_sampY, m_cordY).r, + texture2D(m_sampU, m_cordU).r, + texture2D(m_sampV, m_cordV).g, + 1.0); + +#endif + + rgb = m_yuvmat * yuv; + rgb.a = m_alpha; + +#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)); + +#if defined(KODI_TONE_MAPPING_REINHARD) + float luma = dot(rgb.rgb, m_coefsDst); + rgb.rgb *= reinhard(luma) / luma; + +#elif defined(KODI_TONE_MAPPING_ACES) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1); + rgb.rgb = aces(rgb.rgb); + rgb.rgb *= (1.24 / m_toneP1); + rgb.rgb = pow(rgb.rgb, vec3(0.27)); + +#elif defined(KODI_TONE_MAPPING_HABLE) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= m_toneP1; + float wp = m_luminance / 100.0; + rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp)); + rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2)); +#endif + +#endif + + gl_FragColor = rgb; +} + diff --git a/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag b/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag new file mode 100644 index 0000000..a82de9d --- /dev/null +++ b/system/shaders/GLES/2.0/gles_yuv2rgb_bob.frag @@ -0,0 +1,113 @@ +/* + * 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 100 + +precision highp float; +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 float m_alpha; +uniform mat4 m_yuvmat; +uniform float m_stepX; +uniform float m_stepY; +uniform int m_field; +uniform mat3 m_primMat; +uniform float m_gammaDstInv; +uniform float m_gammaSrc; +uniform float m_toneP1; +uniform float m_luminance; +uniform vec3 m_coefsDst; + +void main() +{ + vec4 rgb; + + vec2 offsetY; + vec2 offsetU; + vec2 offsetV; + float temp1 = mod(m_cordY.y, 2.0 * m_stepY); + + offsetY = m_cordY; + offsetU = m_cordU; + offsetV = m_cordV; + + offsetY.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY); + offsetU.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY) / 2.0; + offsetV.y -= (temp1 - m_stepY / 2.0 + float(m_field) * m_stepY) / 2.0; + + float bstep = step(m_stepY, temp1); + + // Blend missing line + vec2 belowY, belowU, belowV; + + belowY.x = offsetY.x; + belowY.y = offsetY.y + (2.0 * m_stepY * bstep); + belowU.x = offsetU.x; + belowU.y = offsetU.y + (m_stepY * bstep); + belowV.x = offsetV.x; + belowV.y = offsetV.y + (m_stepY * bstep); + + vec4 rgbAbove; + vec4 rgbBelow; + vec4 yuvAbove; + vec4 yuvBelow; + + yuvAbove = vec4(texture2D(m_sampY, offsetY).r, texture2D(m_sampU, offsetU).g, texture2D(m_sampV, offsetV).a, 1.0); + rgbAbove = m_yuvmat * yuvAbove; + rgbAbove.a = m_alpha; + + yuvBelow = vec4(texture2D(m_sampY, belowY).r, texture2D(m_sampU, belowU).g, texture2D(m_sampV, belowV).a, 1.0); + rgbBelow = m_yuvmat * yuvBelow; + rgbBelow.a = m_alpha; + + rgb = mix(rgb, rgbBelow, 0.5); + +#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)); + +#if defined(KODI_TONE_MAPPING_REINHARD) + float luma = dot(rgb.rgb, m_coefsDst); + rgb.rgb *= reinhard(luma) / luma; + +#elif defined(KODI_TONE_MAPPING_ACES) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1); + rgb.rgb = aces(rgb.rgb); + rgb.rgb *= (1.24 / m_toneP1); + rgb.rgb = pow(rgb.rgb, vec3(0.27)); + +#elif defined(KODI_TONE_MAPPING_HABLE) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= m_toneP1; + float wp = m_luminance / 100.0; + rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp)); + rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2)); +#endif + +#endif + + gl_FragColor = rgb; +} |