MariENB 2.0.2
This commit is contained in:
parent
8522940c0e
commit
ab0714c476
13 changed files with 951 additions and 88 deletions
|
|
@ -58,9 +58,9 @@
|
|||
#define LUTMODE_64
|
||||
/* some textures can be provided as DDS rather than PNG to save space */
|
||||
//#define HEAT_DDS
|
||||
#define LENSDIRT_DDS
|
||||
//#define LENSDIRT_DDS
|
||||
//#define FROST_DDS
|
||||
//#define FROSTBUMP_DDS
|
||||
/* experimental features (TODO) */
|
||||
//#define USE_BOKEH
|
||||
#define USE_BOKEH
|
||||
//#define MULTIPASS_RMAO
|
||||
|
|
|
|||
|
|
@ -400,6 +400,99 @@ float4 PS_DoFPrepass( VS_OUTPUT_POST IN, float2 vPos : VPOS ) : COLOR
|
|||
This method skips blurring areas that are perfectly in focus. The
|
||||
performance gain is negligible in most cases, though.
|
||||
*/
|
||||
#ifdef USE_BOKEH
|
||||
/* gather blur pass */
|
||||
float4 PS_DoFBlurH( VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
|
||||
{
|
||||
float2 coord = IN.txcoord.xy;
|
||||
if ( dofdisable ) return tex2D(SamplerColor,coord);
|
||||
float dfc = tex2D(SamplerColor,coord).a;
|
||||
if ( dofdebug ) return tex2D(SamplerDepth,coord).x;
|
||||
if ( dfcdebug ) return dfc;
|
||||
float2 bresl;
|
||||
if ( (fixedx > 0) && (fixedy > 0) ) bresl = float2(fixedx,fixedy);
|
||||
else bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w);
|
||||
float2 bof = 1.0/bresl;
|
||||
float4 res = tex2D(SamplerColor,coord);
|
||||
float4 ccol = res;
|
||||
if ( dfc > 0.0 )
|
||||
{
|
||||
res *= 0;
|
||||
float dep = tex2D(SamplerDepth,coord).x;
|
||||
float sd, ds, sw, tw = 0;
|
||||
float2 bsz = bof*dofpradius*dfc;
|
||||
float4 sc;
|
||||
[unroll] for ( int i=0; i<16; i++ )
|
||||
{
|
||||
sc = tex2Dlod(SamplerColor,float4(coord.x
|
||||
+poisson16[i].x*bsz.x,coord.y+poisson16[i].y
|
||||
*bsz.y,0.0,dfc));
|
||||
ds = tex2D(SamplerDepth,coord+poisson16[i]*bsz).x;
|
||||
sd = tex2D(SamplerColor,coord+poisson16[i]*bsz).a;
|
||||
sw = (ds>dep)?1.0:sd;
|
||||
tw += sw;
|
||||
res += sc*sw;
|
||||
}
|
||||
res /= tw;
|
||||
}
|
||||
/* check if bokeh point */
|
||||
const float2 pts[9] =
|
||||
{
|
||||
float2(-1.5,-1.5),float2( 0.5,-1.5),float2( 1.5,-1.5),
|
||||
float2(-1.5, 0.5),float2( 0.5, 0.5),float2( 1.5, 1.5),
|
||||
float2(-1.5, 1.5),float2( 0.5, 1.5),float2( 1.5, 1.5)
|
||||
};
|
||||
float4 col = float4(0,0,0,0);
|
||||
[unroll] for ( int i=0; i<9; i++ )
|
||||
col += tex2D(SamplerColor,coord+pts[i]*bof);
|
||||
col /= 9.0;
|
||||
float lum = luminance(col), clum = luminance(ccol);
|
||||
if ( (max(clum-lum,0.0) > bokthr) && (dfc > bokbthr) )
|
||||
col.a = min(clum*dfc,1.0);
|
||||
else col.a = 0.0;
|
||||
res.a = col.a;
|
||||
return res;
|
||||
}
|
||||
/* bokeh pass */
|
||||
float4 PS_DoFBlurV( VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
|
||||
{
|
||||
float2 coord = IN.txcoord.xy;
|
||||
if ( dofdisable ) return tex2D(SamplerColor,coord);
|
||||
float dfc = tex2D(SamplerColor,coord).a;
|
||||
if ( dofdebug ) return tex2D(SamplerDepth,coord).x;
|
||||
if ( dfcdebug ) return dfc;
|
||||
float2 bresl;
|
||||
if ( (fixedx > 0) && (fixedy > 0) ) bresl = float2(fixedx,fixedy);
|
||||
else bresl = float2(ScreenSize.x,ScreenSize.x*ScreenSize.w);
|
||||
float2 bof = (1.0/bresl);
|
||||
float4 res = tex2D(SamplerColor,coord);
|
||||
// It's bokeh time
|
||||
float2 rcoord;
|
||||
int rsmp;
|
||||
float rstep, bsmp, bft, tw = 0;
|
||||
float4 bcol = float4(0,0,0,0);
|
||||
[unroll] for ( int r=1; r<=5; r++ )
|
||||
{
|
||||
rsmp = r*3;
|
||||
[loop] for ( int s=0; s<rsmp; s++ )
|
||||
{
|
||||
rstep = pi*2.0/float(rsmp);
|
||||
rcoord.x = (cos(float(s)*rstep)*float(r));
|
||||
rcoord.y = (sin(float(s)*rstep)*float(r));
|
||||
bsmp = tex2D(SamplerBokeh,0.5+rcoord/10.0).x;
|
||||
bft = tex2D(SamplerColor,coord+(rcoord/5.0)*bof
|
||||
*boksiz).a;
|
||||
bcol += tex2D(SamplerColor,coord+(rcoord/5.0)*bof
|
||||
*boksiz)*bft*bsmp;
|
||||
tw += bsmp;
|
||||
}
|
||||
}
|
||||
bcol /= tw;
|
||||
res = res+bcol;
|
||||
res.a = 1.0;
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
float4 PS_DoFBlurH( VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
|
||||
{
|
||||
float2 coord = IN.txcoord.xy;
|
||||
|
|
@ -464,6 +557,7 @@ float4 PS_DoFBlurV( VS_OUTPUT_POST IN, float2 vPos : VPOS) : COLOR
|
|||
res.a = 1.0;
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
/* Screen frost shader. Not very realistic either, but looks fine too. */
|
||||
float2 ScreenFrost( float2 coord )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -81,6 +81,20 @@ static const float3 ssao_samples_hq[64] =
|
|||
float3(-0.7190, 0.1767, 0.4489),float3(-0.5617, 0.5845,-0.4116),
|
||||
float3(-0.8919,-0.0384, 0.3360),float3(-0.0144, 0.9775,-0.2105)
|
||||
};
|
||||
/* For high quality DOF */
|
||||
#ifdef USE_BOKEH
|
||||
static const float2 poisson16[16] =
|
||||
{
|
||||
float2( 0.20698410, 0.22452690),float2( 0.52580800,-0.23108170),
|
||||
float2( 0.13839430, 0.90561220),float2( 0.66330090, 0.51298430),
|
||||
float2(-0.40027920, 0.37270580),float2( 0.07912822,-0.65129210),
|
||||
float2(-0.77260670,-0.51512170),float2(-0.38431930,-0.14941320),
|
||||
float2(-0.91077820, 0.25006330),float2( 0.69401530,-0.70989270),
|
||||
float2(-0.19646690,-0.37938900),float2(-0.47692860, 0.18408630),
|
||||
float2(-0.24732800,-0.87984590),float2( 0.42065410,-0.71477200),
|
||||
float2( 0.58293480,-0.09794202),float2( 0.36918380, 0.41406420)
|
||||
};
|
||||
#endif
|
||||
/* standard stuff */
|
||||
float4 ScreenSize;
|
||||
float ENightDayFactor;
|
||||
|
|
@ -122,6 +136,12 @@ texture2D texFrostBump
|
|||
string ResourceName = "menbfrostbump.png";
|
||||
#endif
|
||||
>;
|
||||
#ifdef USE_BOKEH
|
||||
texture2D texBokeh
|
||||
<
|
||||
string ResourceName = "menbbokeh.png";
|
||||
>;
|
||||
#endif
|
||||
texture2D texFocus;
|
||||
texture2D texCurr;
|
||||
texture2D texPrev;
|
||||
|
|
@ -197,6 +217,20 @@ sampler2D SamplerFrostBump = sampler_state
|
|||
MaxMipLevel = 0;
|
||||
MipMapLodBias = 0;
|
||||
};
|
||||
#ifdef USE_BOKEH
|
||||
sampler2D SamplerBokeh = sampler_state
|
||||
{
|
||||
Texture = <texBokeh>;
|
||||
MinFilter = LINEAR;
|
||||
MagFilter = LINEAR;
|
||||
MipFilter = NONE;
|
||||
AddressU = Border;
|
||||
AddressV = Border;
|
||||
SRGBTexture = FALSE;
|
||||
MaxMipLevel = 0;
|
||||
MipMapLodBias = 0;
|
||||
};
|
||||
#endif
|
||||
sampler2D SamplerFocus = sampler_state
|
||||
{
|
||||
Texture = <texFocus>;
|
||||
|
|
|
|||
|
|
@ -619,6 +619,7 @@ bool dofdisable
|
|||
string UIName = "Disable DOF";
|
||||
string UIWidget = "Checkbox";
|
||||
> = {false};
|
||||
#ifndef USE_BOKEH
|
||||
float dofbfact
|
||||
<
|
||||
string UIName = "DOF Bilateral Factor";
|
||||
|
|
@ -630,6 +631,14 @@ float dofbradius
|
|||
string UIWidget = "Spinner";
|
||||
float UIMin = 0.0;
|
||||
> = {1.0};
|
||||
#else
|
||||
float dofpradius
|
||||
<
|
||||
string UIName = "DOF Gather Blur Radius";
|
||||
string UIWidget = "Spinner";
|
||||
float UIMin = 0.0;
|
||||
> = {6.0};
|
||||
#endif
|
||||
#ifndef FALLOUT
|
||||
bool dofrelfov
|
||||
<
|
||||
|
|
@ -664,6 +673,26 @@ float relfovfactor_id
|
|||
string UIWidget = "Spinner";
|
||||
> = {2.0};
|
||||
#endif
|
||||
#ifdef USE_BOKEH
|
||||
float bokthr
|
||||
<
|
||||
string UIName = "Bokeh Threshold";
|
||||
string UIWidget = "Spinner";
|
||||
float UIMin = 0.0;
|
||||
> = {1.0};
|
||||
float bokbthr
|
||||
<
|
||||
string UIName = "Bokeh Blur Threshold";
|
||||
string UIWidget = "Spinner";
|
||||
float UIMin = 0.0;
|
||||
> = {0.5};
|
||||
float boksiz
|
||||
<
|
||||
string UIName = "Bokeh Size";
|
||||
string UIWidget = "Spinner";
|
||||
float UIMin = 0.0;
|
||||
> = {8.0};
|
||||
#endif
|
||||
bool dofdebug
|
||||
<
|
||||
string UIName = "Debug Depth";
|
||||
|
|
|
|||
Reference in a new issue