PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Fake HDR (timeslip) mit shader von shirosae



imported_DWS
14.05.2006, 08:58
Für GraKa's, die HDR nicht supporten...

Nachdem ich eine Weile verschiedene Einstellungen an der fakeHDR.fx getestet habe, sah ich einen optimierten shader für Fake HDR von shirosae, mit dem es sehr gut läuft.

So geht's:

1) http://timeslip.chorrol.com/FakeHDRDownload.html installieren

2) In Oblivion/Data/Shaders die Datei fakeHDR.fx mit einem Texteditor öffnen, den Text komplett markieren und ersetzen mit shirosae's 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.5;

//Current Settings
static const float BloomScale = 0.95;
static const float HDRScale = -0.50;
static const float HDRAdjust = -0.05;

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=(1.00*smoothstep(0.00,0.75,CurrentEye))+HDRScale;
float4 Color2=0;
for (int i = 0; i < 13; i++)
{
Color2 += tex2D( s1, Tex + (PixelKernelH[i]*rcpres) ) * BlurWeights[i];
Color2 += tex2D( s1, Tex + (PixelKernelV[i]*rcpres) ) * BlurWeights[i];
}
float4 Curvemod = (0.75*Color);
Color = clamp((0.25*Color)+((0.75-Curvemod+tempHDRScale)*pow(Color,2))+((Curvemod-tempHDRScale)*(1-pow((1-Color),2))),0,1);
Color2 *= (BloomScale-(0.1*CurrentEye));
return clamp(Color + Color2,0,1);
}

float4 HDRBrightPass( in float2 Tex : TEXCOORD0 ) : COLOR0
{
float4 color = tex2D( s0, Tex );
//color += clamp(tex2D( s1, Tex ) - (2*(CurrentEye + 0.10)) ,0,1); //Uncomment this line for retina burn
//float4 retinaburn = clamp(tex2D( s1, Tex ) - (2*(CurrentEye + 0.10)) ,0,1);
//color += clamp(1-pow((1-retinaburn),2),0,0.5);
float tempbright = clamp((0.27*color[1])+(0.67*color[2])+(0.06*color[3]),0,1);
float HDRAdjustBias = (0.10*pow((1-CurrentEye),3));
float curvemod = (0.35*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(); }
}