RetroArch/hqflt/cg/quad.cg

72 lines
1.6 KiB
Plaintext
Raw Normal View History

2010-11-14 22:25:47 +01:00
/*
2010-11-15 00:45:21 +01:00
Author: Themaister
License: Public domain
2010-11-14 22:25:47 +01:00
*/
/* 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;
2010-11-15 00:45:21 +01:00
float dx = float(pow(1.0 * texsize.x, -1.0));
float dy = float(pow(1.0 * texsize.y, -1.0));
2010-11-14 22:25:47 +01:00
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;
2010-11-15 00:45:21 +01:00
float blur = 1.5;
float3 xval0 = quad_inter(c01, c11, c21, blur*(frac(tex.x * texsize.x)) + (2.0 - blur) * 0.5);
float3 yval0 = quad_inter(c10, c11, c12, blur*(frac(tex.y * texsize.y)) + (2.0 - blur) * 0.5);
2010-11-14 22:25:47 +01:00
output OUT;
2010-11-15 00:45:21 +01:00
OUT.color = float4(lerp(xval0, yval0, 0.5), 1.0);
2010-11-14 22:25:47 +01:00
return OUT;
}