mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-06-02 09:41:41 +00:00
Tweaked shadowmap bias to fight shadow acne
This commit is contained in:
parent
319b659302
commit
395ef525b1
5 changed files with 13 additions and 5 deletions
|
@ -196,7 +196,9 @@ void main( PS_IN fragment, out PS_OUT result )
|
||||||
float bias = 0.001;
|
float bias = 0.001;
|
||||||
|
|
||||||
shadowTexcoord.xyz /= shadowTexcoord.w;
|
shadowTexcoord.xyz /= shadowTexcoord.w;
|
||||||
shadowTexcoord.z = shadowTexcoord.z * 0.9995;
|
|
||||||
|
shadowTexcoord.z = shadowTexcoord.z * rpScreenCorrectionFactor.w;
|
||||||
|
//shadowTexcoord.z = shadowTexcoord.z * 0.999991;
|
||||||
//shadowTexcoord.z = shadowTexcoord.z - bias;
|
//shadowTexcoord.z = shadowTexcoord.z - bias;
|
||||||
shadowTexcoord.w = float(shadowIndex);
|
shadowTexcoord.w = float(shadowIndex);
|
||||||
|
|
||||||
|
@ -216,7 +218,7 @@ void main( PS_IN fragment, out PS_OUT result )
|
||||||
float shadow = 0.0;
|
float shadow = 0.0;
|
||||||
|
|
||||||
//float stepSize = 1.0 / 16.0;
|
//float stepSize = 1.0 / 16.0;
|
||||||
float numSamples = rpScreenCorrectionFactor.w;
|
float numSamples = 16;
|
||||||
float stepSize = 1.0 / numSamples;
|
float stepSize = 1.0 / numSamples;
|
||||||
|
|
||||||
float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;
|
float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;
|
||||||
|
|
|
@ -4389,7 +4389,9 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" float bias = 0.001;\n"
|
" float bias = 0.001;\n"
|
||||||
" \n"
|
" \n"
|
||||||
" shadowTexcoord.xyz /= shadowTexcoord.w;\n"
|
" shadowTexcoord.xyz /= shadowTexcoord.w;\n"
|
||||||
" shadowTexcoord.z = shadowTexcoord.z * 0.9995;\n"
|
" \n"
|
||||||
|
" shadowTexcoord.z = shadowTexcoord.z * rpScreenCorrectionFactor.w;\n"
|
||||||
|
" //shadowTexcoord.z = shadowTexcoord.z * 0.999991;\n"
|
||||||
" //shadowTexcoord.z = shadowTexcoord.z - bias;\n"
|
" //shadowTexcoord.z = shadowTexcoord.z - bias;\n"
|
||||||
" shadowTexcoord.w = float(shadowIndex);\n"
|
" shadowTexcoord.w = float(shadowIndex);\n"
|
||||||
"\n"
|
"\n"
|
||||||
|
@ -4409,7 +4411,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
||||||
" float shadow = 0.0;\n"
|
" float shadow = 0.0;\n"
|
||||||
" \n"
|
" \n"
|
||||||
" //float stepSize = 1.0 / 16.0;\n"
|
" //float stepSize = 1.0 / 16.0;\n"
|
||||||
" float numSamples = rpScreenCorrectionFactor.w;\n"
|
" float numSamples = 16;\n"
|
||||||
" float stepSize = 1.0 / numSamples;\n"
|
" float stepSize = 1.0 / numSamples;\n"
|
||||||
" \n"
|
" \n"
|
||||||
" float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;\n"
|
" float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;\n"
|
||||||
|
|
|
@ -235,6 +235,8 @@ idCVar r_shadowMapLodBias( "r_shadowMapLodBias", "0", CVAR_RENDERER | CVAR_INTEG
|
||||||
idCVar r_shadowMapPolygonFactor( "r_shadowMapPolygonFactor", "2", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset factor for drawing shadow buffer" );
|
idCVar r_shadowMapPolygonFactor( "r_shadowMapPolygonFactor", "2", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset factor for drawing shadow buffer" );
|
||||||
idCVar r_shadowMapPolygonOffset( "r_shadowMapPolygonOffset", "3000", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset units for drawing shadow buffer" );
|
idCVar r_shadowMapPolygonOffset( "r_shadowMapPolygonOffset", "3000", CVAR_RENDERER | CVAR_FLOAT, "polygonOffset units for drawing shadow buffer" );
|
||||||
idCVar r_shadowMapOccluderFacing( "r_shadowMapOccluderFacing", "2", CVAR_RENDERER | CVAR_INTEGER, "0 = front faces, 1 = back faces, 2 = twosided" );
|
idCVar r_shadowMapOccluderFacing( "r_shadowMapOccluderFacing", "2", CVAR_RENDERER | CVAR_INTEGER, "0 = front faces, 1 = back faces, 2 = twosided" );
|
||||||
|
idCVar r_shadowMapRegularDepthBiasScale( "r_shadowMapRegularDepthBiasScale", "0.999", CVAR_RENDERER | CVAR_FLOAT, "shadowmap bias to fight shadow acne for point and spot lights" );
|
||||||
|
idCVar r_shadowMapSunDepthBiasScale( "r_shadowMapSunDepthBiasScale", "0.999991", CVAR_RENDERER | CVAR_FLOAT, "shadowmap bias to fight shadow acne for cascaded shadow mapping with parallel lights" );
|
||||||
// RB end
|
// RB end
|
||||||
|
|
||||||
const char* fileExten[3] = { "tga", "png", "jpg" };
|
const char* fileExten[3] = { "tga", "png", "jpg" };
|
||||||
|
|
|
@ -1302,7 +1302,7 @@ static void RB_RenderInteractions( const drawSurf_t* surfList, const viewLight_t
|
||||||
screenCorrectionParm[0] = 1.0f / ( JITTER_SIZE * shadowMapSamples ) ;
|
screenCorrectionParm[0] = 1.0f / ( JITTER_SIZE * shadowMapSamples ) ;
|
||||||
screenCorrectionParm[1] = 1.0f / JITTER_SIZE;
|
screenCorrectionParm[1] = 1.0f / JITTER_SIZE;
|
||||||
screenCorrectionParm[2] = 1.0f / shadowMapResolutions[vLight->shadowLOD];
|
screenCorrectionParm[2] = 1.0f / shadowMapResolutions[vLight->shadowLOD];
|
||||||
screenCorrectionParm[3] = shadowMapSamples;
|
screenCorrectionParm[3] = vLight->parallel ? r_shadowMapSunDepthBiasScale.GetFloat() : r_shadowMapRegularDepthBiasScale.GetFloat();
|
||||||
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
SetFragmentParm( RENDERPARM_SCREENCORRECTIONFACTOR, screenCorrectionParm ); // rpScreenCorrectionFactor
|
||||||
|
|
||||||
float jitterTexScale[4];
|
float jitterTexScale[4];
|
||||||
|
|
|
@ -1070,6 +1070,8 @@ extern idCVar r_shadowMapLodBias;
|
||||||
extern idCVar r_shadowMapPolygonFactor;
|
extern idCVar r_shadowMapPolygonFactor;
|
||||||
extern idCVar r_shadowMapPolygonOffset;
|
extern idCVar r_shadowMapPolygonOffset;
|
||||||
extern idCVar r_shadowMapOccluderFacing;
|
extern idCVar r_shadowMapOccluderFacing;
|
||||||
|
extern idCVar r_shadowMapRegularDepthBiasScale;
|
||||||
|
extern idCVar r_shadowMapSunDepthBiasScale;
|
||||||
// RB end
|
// RB end
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue