diff --git a/hqflt/cg/quad.cg b/hqflt/cg/quad.cg new file mode 100644 index 0000000000..41b771f5ae --- /dev/null +++ b/hqflt/cg/quad.cg @@ -0,0 +1,99 @@ +/* + + Copyright (C) 2007 guest(r) - guest.r@gmail.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 + of the License, 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 this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +/* + + The 2xSaL shader processes a gfx. surface and redraws it 2x finer. + + A linear post-resize can fit the image to any resolution. + + Note: set scaler to normal2x. + +*/ + +/* Default Vertex shader */ +void main_vertex +( + float4 position : POSITION, + float4 color : COLOR, + float2 texCoord : TEXCOORD0, + + uniform float4x4 modelViewProj, + + out float4 oPosition : POSITION, + out float4 oColor : COLOR, + out float2 otexCoord : TEXCOORD + ) +{ + oPosition = mul(modelViewProj, position); + oColor = color; + otexCoord = texCoord; +} + +struct output +{ + float4 color : COLOR; +}; + +struct input +{ + float2 video_size; + float2 texture_size; + float2 output_size; +}; + +struct deltas +{ + float2 UL, UR, DL, DR; +}; + +float3 quad_inter(float3 x0, float3 x1, float3 x2, float x) +{ + float3 poly[3]; + poly[2] = 0.5*x0 - x1 + 0.5*x2; + poly[1] = -1.5*x0 + 2.0*x1 - 0.5*x2; + poly[0] = x0; + return poly[2] * x * x + poly[1] * x + poly[0]; +} + +output main_fragment (float2 tex : TEXCOORD0, uniform input IN, uniform sampler2D s0 : TEXUNIT0) +{ + float2 texsize = IN.texture_size; + float vid_height = IN.output_size.y; + float dx = float(pow(2.0 * texsize.x, -1.0)); + float dy = float(pow(2.0 * texsize.y, -1.0)); + + float3 c01 = tex2D(s0, tex + float2(-dx, 0)).xyz; + float3 c10 = tex2D(s0, tex + float2(0, -dy)).xyz; + float3 c11 = tex2D(s0, tex + float2(0, 0)).xyz; + float3 c12 = tex2D(s0, tex + float2(0, dy)).xyz; + float3 c21 = tex2D(s0, tex + float2(dx, 0)).xyz; + + float3 xval0 = quad_inter(c01, c11, c21, tex.x * texsize.x - floor(tex.x * texsize.x) + 1.0); + float3 yval0 = quad_inter(c10, c11, c12, tex.y * texsize.y - floor(tex.y * texsize.y) + 1.0); + + output OUT; + //float scanline_mod = 1.0 - 0.1 * floor(fmod(vid_height * tex.y, 2.0)); + float scanline_mod = 1.0; + + OUT.color = float4(lerp(xval0, yval0, 0.5), 1.0) * scanline_mod; + return OUT; +} +