home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2005 May
/
PCWorld_2005-05_cd.bin
/
software
/
topware
/
mpcl
/
mplayerc.exe
/
1033
/
FILE
/
407
< prev
Wrap
Text File
|
2005-03-20
|
2KB
|
78 lines
sampler s0 : register(s0);
float4 p0 : register(c0);
float2 dxdy : register(c1);
float2 dx : register(c2);
float2 dy : register(c3);
#define size (p0.xy)
#define A _The_Value_Of_A_Is_Set_Here_
float4 main_bilinear(float2 tex : TEXCOORD0) : COLOR
{
// not usable for 1:1 mapping!
// tex * size won't be 0, 1, 2, 3, .. as you might expect, but something like 0, 0.999, 2.001, 2.999, ...
// this means when the fractional part becomes 0.999 we will be interpolating with the wrong value!!!
tex -= 0.5*dxdy;
float2 dd = frac(tex * size);
float4 c = lerp(
lerp(tex2D(s0, tex), tex2D(s0, tex + dx), dd.x),
lerp(tex2D(s0, tex + dy), tex2D(s0, tex + dxdy), dd.x),
dd.y);
return c;
}
static float4x4 tco =
{
0, A, -2*A, A,
1, 0, -A-3, A+2,
0, -A, 2*A+3, -A-2,
0, 0, A, -A
};
float4 taps(float x)
{
return mul(tco, float4(1, x, x*x, x*x*x));
}
float4 c3sample(float4 taps, float2 t)
{
return
mul(taps,
float4x4(
tex2D(s0, t-dx),
tex2D(s0, t),
tex2D(s0, t+dx),
tex2D(s0, t+dx+dx)
)
);
}
float4 main_bicubic(float2 tex : TEXCOORD0) : COLOR
{
// not usable for 1:1 mapping!
// tex * size won't be 0, 1, 2, 3, .. as you might expect, but something like 0, 0.999, 2.001, 2.999, ...
// this means when the fractional part becomes 0.999 we will be interpolating with the wrong value!!!
tex -= 0.5*dxdy;
float2 dd = frac(tex * size);
float4 tx = taps(dd.x);
float4 c = mul(
taps(dd.y),
float4x4(
c3sample(tx, tex-dy),
c3sample(tx, tex),
c3sample(tx, tex+dy),
c3sample(tx, tex+dy+dy)
)
);
return c;
}