cubic B - spline5 height doubler, ebook
[ Pobierz całość w formacie PDF ]
// (C) 2011 Jan-Willem Krans (janwillem32 <at> hotmail.com)// This file is part of Video pixel shader pack.// 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, version 2.// 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 this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.// cubic B-spline5 height doubler// This shader should be run as a screen space pixel shader.// If possible, avoid compiling with the software emulation modes (ps_?_sw). Pixel shaders require a lot of processing power to run in real-time software mode.// This shader is meant to work with linear RGB input and output. Regular R'G'B' with a video gamma encoding will have to be converted with the linear gamma shaders to work properly.// Use this shader to double the height of an image by cubic B-spline5 interpolation.sampler s0;float2 c0;float2 c1;#define sp(a, b) float4 a = tex2D(s0, float2(tex.x, coord+b*fy*c1.y));float4 main(float2 tex : TEXCOORD0) : COLOR{float coord = (tex.y/2.+.25)*c0.y;// assign the output position, normalized to texture width in pixelsfloat t = frac(coord);// calculate the difference between the output pixel and the original surrounding two pixels// adjust sampling matrix to put the ouput pixel on Q2+.25float fy;if(t > .5) {coord = (coord-t+1.5)*c1.y; fy = -1;}else {coord = (coord-t+.5)*c1.y; fy = 1;}sp(Q0, -2) sp(Q1, -1) sp(Q2, 0) sp(Q3, 1) sp(Q4, 2)// original pixelsreturn (Q0+Q1*46+Q2*1656+Q3*578+Q4*23)/2304.;// output interpolated value}
[ Pobierz całość w formacie PDF ]