Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Copyright (C) 2010 Team XBMC
- http://www.xbmc.org
- Copyright (C) 2011 Stefanos A.
- http://www.opentk.com
- 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, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- http://www.gnu.org/copyleft/gpl.html
- -->
- <!--
- From this forum post:
- http://board.byuu.org/viewtopic.php?p=33597
- -->
- <shader language="GLSL">
- <vertex><![CDATA[
- void main()
- {
- gl_TexCoord[0] = gl_MultiTexCoord0; //center
- gl_Position = ftransform();
- }
- ]]></vertex>
- <fragment><![CDATA[
- #define FIX(c) max(abs(c), 1e-5);
- uniform sampler2D rubyTexture;
- uniform vec2 rubyTextureSize;
- const float PI = 3.1415926535897932384626433832795;
- vec4 weight4(float x)
- {
- vec4 sample = FIX(PI * vec4(1.0 + x, x, 1.0 - x, 2.0 - x));
- // Lanczos2
- vec4 ret = 2.0 * sin(sample) * sin(sample / 2.0) / pow(sample, 2.0);
- // Normalize
- return ret / dot(ret, vec4(1.0));
- }
- vec3 pixel(float xpos, float ypos)
- {
- return texture2D(rubyTexture, vec2(xpos, ypos)).rgb;
- }
- vec3 line(float ypos, vec4 xpos, vec4 linetaps)
- {
- return mat4x3(
- pixel(xpos.x, ypos),
- pixel(xpos.y, ypos),
- pixel(xpos.z, ypos),
- pixel(xpos.w, ypos)) * linetaps;
- }
- void main()
- {
- vec2 stepxy = 1.0 / rubyTextureSize.xy;
- vec2 pos = gl_TexCoord[0].xy + stepxy * 0.5;
- vec2 f = fract(pos / stepxy);
- 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);
- vec4 linetaps = weight4(f.x);
- vec4 columntaps = weight4(f.y);
- gl_FragColor.rgb = mat4x3(
- line(xystart.y , xpos, linetaps),
- line(xystart.y + stepxy.y , xpos, linetaps),
- line(xystart.y + stepxy.y * 2.0, xpos, linetaps),
- line(xystart.y + stepxy.y * 3.0, xpos, linetaps)) * columntaps;
- gl_FragColor.a = 1.0;
- }
- ]]></fragment>
- </shader>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement