用户
 找回密码
 立即注册
搜索

转贴-上古4 FakeHDR(让N卡用户也可以HDR和AA同开!)

[复制链接]

10

主题

182

帖子

61

积分

注册会员

Rank: 2

积分
61
发表于 2006-12-25 15:06:00
转贴-上古4 FakeHDR(让N卡用户也可以HDR和AA同开!)
我是什么都不懂的,大家看看就好

原帖链接

http://www3.eastgame.net/read.php?tid=1031207

N卡相对A卡有一个明显的弱点就是不支持HDR和AA同开,所以高人Timeslip(OBMM的作者)开发了FakeHDR这个工具,替代游戏中原有的HDR。FakeHDR的优势是不管是A卡还是N卡都可以和AA同开,当然效果上可能比游戏中原本的HDR差点(其实也不尽然,有人就认为FakeHDR的效果比游戏中原本的HDR更好!

CODE:

//These variables will get set automatically
texture tex1;
texture tex2;
//float2 rcpres;
float CurrentEye;
//float CurrentBrightness;

sampler s0 = sampler_state { AddressU = Clamp; AddressV = Clamp; texture = <tex1>; };
sampler s1 = sampler_state { texture = <tex2>; };

//Use these to modify the behaviour of the dll
bool SinglePixel=false;
bool AffectMenus=false;
int ToggleKey=107;
int ToggleSinglePixelKey=109;
int ToggleAffectMenusKey=106;
float ReactionSpeed=0.95;

//Current Settings
static const float BloomScale = 0.65;
static const float HDRScale = -0.38;
static const float HDRAdjust = -0.10;

//rcpres must be set to the reciprical of your screen resolution
//static const float2 rcpres = { 0.0015625, 0.0020833333333 };    //640x480
//static const float2 rcpres = { 0.00125, 0.0016666666667 };    //800x600
//static const float2 rcpres = { 0.0009765625, 0.0013020833 };    //1024x768
//static const float2 rcpres = { 0.000625, 0.0008333333333 };    //1600x1200
static const float2 rcpres = { 0.00078125, 0.0009765625 };     //1280x1024

float2 PixelKernelH[13] =
{
    { -6, 0 },
    { -5, 0 },
    { -4, 0 },
    { -3, 0 },
    { -2, 0 },
    { -1, 0 },
    {  0, 0 },
    {  1, 0 },
    {  2, 0 },
    {  3, 0 },
    {  4, 0 },
    {  5, 0 },
    {  6, 0 },
};

float2 PixelKernelV[13] =
{
    { 0, -6 },
    { 0, -5 },
    { 0, -4 },
    { 0, -3 },
    { 0, -2 },
    { 0, -1 },
    { 0,  0 },
    { 0,  1 },
    { 0,  2 },
    { 0,  3 },
    { 0,  4 },
    { 0,  5 },
    { 0,  6 },
};

static const float BlurWeights[13] =
{
    0.002216,
    0.008764,
    0.026995,
    0.064759,
    0.120985,
    0.176033,
    0.199471,
    0.176033,
    0.120985,
    0.064759,
    0.026995,
    0.008764,
    0.002216,
};


float4 Bloom( in float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 Color = tex2D( s0, Tex );
    float tempHDRScale=(0.70*smoothstep(0.00,0.75,CurrentEye))+HDRScale;
    float4 Color2=0;   
    for (int i = 0; i < 13; i++)
    {   
        Color2 += tex2D( s1, Tex + (PixelKernelH*rcpres) ) * BlurWeights;
          Color2 += tex2D( s1, Tex + (PixelKernelV*rcpres) ) * BlurWeights;
    }
    float4 Curvemod = (0.70*Color);
    Color = clamp((0.30*Color)+((0.70-Curvemod+tempHDRScale)*pow(Color,2))+((Curvemod-tempHDRScale)*(1-pow((1-Color),2))),0,1);
    Color2 *= (BloomScale-(0.00*CurrentEye));
    return clamp(Color + Color2,0,1);
}

float4 HDRBrightPass( in float2 Tex : TEXCOORD0 ) : COLOR0
{
    float4 color = tex2D( s0, Tex );
    float tempbright = clamp((0.27*color[1])+(0.67*color[2])+(0.06*color[3]),0,1);
    float HDRAdjustBias = (0.18*pow((1-CurrentEye),3));
    float curvemod = (0.25*tempbright);
    float4 colorbias = (1-pow((1-color),2));
    float4 adjust = clamp(((color-CurrentEye)-HDRAdjust-(HDRAdjustBias)),0,1);
    color = clamp((8*pow(adjust,5)),0,1);
    //color += clamp(tex2D( s1, Tex ) - (2*(CurrentEye + 0.10)) ,0,0.75); //Uncomment this line for retina burn
    color = clamp(((1-curvemod+HDRAdjustBias)*color)+((curvemod-HDRAdjustBias)*colorbias),0,1);
    color.a = 1;
    return color;
}

technique T0
{
    pass p0 { PixelShader = compile ps_2_0 HDRBrightPass(); }
    pass p1 { PixelShader = compile ps_2_0 Bloom();    }
}
使用道具 举报 回复
发表于 2006-12-25 15:08:00
另一种实现方式的HDR+AA
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:16:00
和真正的HDR不能比的。
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:17:00
提示: 作者被禁止或删除 内容自动屏蔽
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:20:00
原帖由 jhj9 于 2006-12-25 15:17 发表


你用过吗?恐怕见都没见过吧?
不知道你这个pro-n知道不知道

上测试吧
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:27:00
原帖由 casper2003 于 2006-12-25 15:20 发表

不知道你这个pro-n知道不知道

上测试吧
上古4我都没下载,无法进行测试
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:30:00
原帖由 jhj9 于 2006-12-25 15:27 发表


上古4我都没下载,无法进行测试
你这个pro-n不称职啊
使用道具 举报 回复 支持 反对
发表于 2006-12-25 15:56:00
人家有神卡7900GS呢  人家有编写的程序绝对能让79系列支持FP16HDR+AA
使用道具 举报 回复 支持 反对
发表于 2006-12-25 16:43:00
原帖由 jhj9 于 2006-12-25 15:17 发表


你用过吗?恐怕见都没见过吧?
放屁。我用的是6600你说我有没有见过
使用道具 举报 回复 支持 反对
发表于 2006-12-25 16:46:00
原帖由 jhj9 于 2006-12-25 15:17 发表


你用过吗?恐怕见都没见过吧?
不过,仍然要感谢你对我们NVIDIA的支持
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则