|
發表於 2005-7-22 05:34:16
|
顯示全部樓層
xsharpen??(完整版),适用于支持ps3.0的?卡,如NVIDIA 6xxx系列卡. ?于ATI X系列卡等也?也可以用
可以自行修改strength/threshold的值
sampler2D s0 : register(s0);
float4 p0 : register(c0);
#define width (p0[0])
#define height (p0[1])
float luma(float4 color)
{
float4 lum = {0.21484375, 0.7109375, 0.07421875, 0};
return dot(color, lum);
}
float4 main(float2 tex : TEXCOORD0) : COLOR0
{
float strength = 1.0f; //min 0.0f, max 1.0f
float threshold = 1.0f; //min 0.0f, max 1.0f
float4 pmin, pmax,porg;
float lmin = 1.0f, lmax = 0.0f,lorg;
for(int i=-1; i<=1; i++)
{
for(int j=-1; j<=1; j++)
{
float4 pcur = tex2D(s0, tex.xy + float2(i/width, j/height));
float lcur = luma(pcur);
if (lcur < lmin) { lmin = lcur; pmin = pcur; }
if (lcur > lmax) { lmax = lcur; pmax = pcur; }
if(i==0 && j==0) { porg = pcur;lorg=lcur;}
}
}
if(lorg-lmin > lmax-lorg)
{
if(lmax-lorg < threshold)
return pmax*strength+porg*(1-strength);
else
return porg;
}
else
{
if(lorg-lmin < threshold)
return pmin*strength+porg*(1-strength);
else
return porg;
}
}
xsharpen??(?照版),适用于?支持ps2.0的?卡
可以自行修改strength/threshold的值。屏幕左半?是原始?像,右半?是?化的?像
sampler2D s0 : register(s0);
float4 p0 : register(c0);
#define width (p0[0])
#define height (p0[1])
float luma(float4 color)
{
float4 lum = {0.21484375, 0.7109375, 0.07421875, 0};
return dot(color, lum);
}
float4 main(float2 tex : TEXCOORD0) : COLOR0
{
float strength = 1.0f; //min 0.0f, max 1.0f
float threshold = 1.0f; //min 0.0f, max 1.0f
float4 pmin, pmax,porg;
float lmin = 1.0f, lmax = 0.0f,lorg;
for(int i=-1; i<=1; i++)
{
for(int j=-1; j<=1; j++)
{
if(i==0||j==0)
{
float4 pcur = tex2D(s0, tex.xy + float2(i/width, j/height));
float lcur = luma(pcur);
if (lcur < lmin) { lmin = lcur; pmin = pcur; }
if (lcur > lmax) { lmax = lcur; pmax = pcur; }
if(i==0 && j==0) { porg = pcur;lorg=lcur;}
}
}
}
if(tex.x < 0.5f)
return porg;
else
if(lorg-lmin > lmax-lorg)
{
if(lmax-lorg < threshold)
return pmax*strength+porg*(1-strength);
else
return porg;
}
else
{
if(lorg-lmin < threshold)
return pmin*strength+porg*(1-strength);
else
return porg;
}
}
|
|