mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2025-04-24 02:32:18 +00:00
Blend shadowmaps smoothly in for small distant lights #746
This commit is contained in:
parent
ee3fbb46f0
commit
99d7338d12
5 changed files with 25 additions and 15 deletions
|
@ -1663,7 +1663,7 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
float jitterTexScale[4];
|
||||
jitterTexScale[0] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale; // TODO shadow buffer size fraction shadowMapSize / maxShadowMapSize
|
||||
jitterTexScale[1] = vLight->imageSize.x / float( r_shadowMapAtlasSize.GetInteger() );
|
||||
jitterTexScale[2] = -r_shadowMapBiasScale.GetFloat();
|
||||
jitterTexScale[2] = vLight->shadowFadeOut;
|
||||
jitterTexScale[3] = shadowMapSamples;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
|
@ -1691,7 +1691,7 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
float jitterTexScale[4];
|
||||
jitterTexScale[0] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale; // TODO shadow buffer size fraction shadowMapSize / maxShadowMapSize
|
||||
jitterTexScale[1] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale;
|
||||
jitterTexScale[2] = -r_shadowMapBiasScale.GetFloat();
|
||||
jitterTexScale[2] = 1;
|
||||
jitterTexScale[3] = shadowMapSamples;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
}
|
||||
|
@ -1718,7 +1718,7 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
lightRegs[ lightStage->color.registers[3] ] );
|
||||
|
||||
// apply the world-global overbright and the 2x factor for specular
|
||||
const idVec4 diffuseColor = lightColor;
|
||||
idVec4 diffuseColor = lightColor;
|
||||
// jmarshall
|
||||
idVec4 specularColor = lightColor * 2.0f;
|
||||
|
||||
|
@ -1728,6 +1728,11 @@ void idRenderBackend::RenderInteractions( const drawSurf_t* surfList, const view
|
|||
}
|
||||
// jmarshall end
|
||||
|
||||
//if( vLight->shadowLOD == 4 )
|
||||
//{
|
||||
// diffuseColor = colorRed;
|
||||
//}
|
||||
|
||||
float lightTextureMatrix[16];
|
||||
if( lightStage->texture.hasMatrix )
|
||||
{
|
||||
|
@ -6037,9 +6042,9 @@ void idRenderBackend::DrawScreenSpaceAmbientOcclusion( const viewDef_t* _viewDef
|
|||
const float jitterSampleScale = 1.0f;
|
||||
|
||||
float jitterTexScale[4];
|
||||
jitterTexScale[0] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale; // TODO shadow buffer size fraction shadowMapSize / maxShadowMapSize
|
||||
jitterTexScale[0] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale;
|
||||
jitterTexScale[1] = r_shadowMapJitterScale.GetFloat() * jitterSampleScale;
|
||||
jitterTexScale[2] = -r_shadowMapBiasScale.GetFloat();
|
||||
jitterTexScale[2] = 0.0f;
|
||||
jitterTexScale[3] = 0.0f;
|
||||
SetFragmentParm( RENDERPARM_JITTERTEXSCALE, jitterTexScale ); // rpJitterTexScale
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Doom 3 BFG Edition GPL Source Code
|
||||
Copyright (C) 1993-2012 id Software LLC, a ZeniMax Media company.
|
||||
Copyright (C) 2012-2021 Robert Beckebans
|
||||
Copyright (C) 2012-2023 Robert Beckebans
|
||||
Copyright (C) 2014-2016 Kot in Action Creative Artel
|
||||
Copyright (C) 2022 Stephen Pridham
|
||||
|
||||
|
@ -395,6 +395,7 @@ struct viewLight_t
|
|||
bool parallel; // lightCenter gives the direction to the light at infinity
|
||||
idVec3 lightCenter; // offset the lighting direction for shading and
|
||||
int shadowLOD; // level of detail for shadowmap selection
|
||||
float shadowFadeOut; // blending from last shadow LOD to invisible
|
||||
idRenderMatrix shadowV[6]; // shadow depth view matrix for lighting pass
|
||||
idRenderMatrix shadowP[6]; // shadow depth projection matrix for lighting pass
|
||||
idVec2i imageSize;
|
||||
|
@ -1260,7 +1261,7 @@ extern idCVar r_shadowMapFrustumFOV;
|
|||
extern idCVar r_shadowMapSingleSide;
|
||||
extern idCVar r_shadowMapImageSize;
|
||||
extern idCVar r_shadowMapJitterScale;
|
||||
extern idCVar r_shadowMapBiasScale;
|
||||
//extern idCVar r_shadowMapBiasScale;
|
||||
extern idCVar r_shadowMapRandomizeJitter;
|
||||
extern idCVar r_shadowMapSamples;
|
||||
extern idCVar r_shadowMapSplits;
|
||||
|
|
|
@ -276,12 +276,12 @@ idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVA
|
|||
idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" );
|
||||
idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 );
|
||||
idCVar r_shadowMapJitterScale( "r_shadowMapJitterScale", "2.5", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter offset" );
|
||||
idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter bias" );
|
||||
//idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter bias" );
|
||||
idCVar r_shadowMapRandomizeJitter( "r_shadowMapRandomizeJitter", "1", CVAR_RENDERER | CVAR_BOOL, "randomly offset jitter texture each draw" );
|
||||
idCVar r_shadowMapSamples( "r_shadowMapSamples", "16", CVAR_RENDERER | CVAR_INTEGER, "1, 4, 12 or 16", 1, 64 );
|
||||
idCVar r_shadowMapSplits( "r_shadowMapSplits", "3", CVAR_RENDERER | CVAR_INTEGER, "number of splits for cascaded shadow mapping with parallel lights", 0, 4 );
|
||||
idCVar r_shadowMapSplitWeight( "r_shadowMapSplitWeight", "0.9", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_shadowMapLodScale( "r_shadowMapLodScale", "0.9", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_shadowMapLodScale( "r_shadowMapLodScale", "1.4", CVAR_RENDERER | CVAR_FLOAT, "" );
|
||||
idCVar r_shadowMapLodBias( "r_shadowMapLodBias", "0", CVAR_RENDERER | CVAR_INTEGER, "" );
|
||||
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" );
|
||||
|
|
|
@ -269,6 +269,7 @@ static void R_AddSingleLight( viewLight_t* vLight )
|
|||
|
||||
// -1 means no shadows
|
||||
vLight->shadowLOD = -1;
|
||||
vLight->shadowFadeOut = 0;
|
||||
|
||||
if( r_useShadowMapping.GetBool() && lightCastsShadows )
|
||||
{
|
||||
|
@ -316,12 +317,6 @@ static void R_AddSingleLight( viewLight_t* vLight )
|
|||
}
|
||||
|
||||
lod = idMath::Ftoi( flod );
|
||||
|
||||
//if( lod >= numLods )
|
||||
//{
|
||||
// lod = numLods - 1;
|
||||
//}
|
||||
|
||||
lod += r_shadowMapLodBias.GetInteger();
|
||||
|
||||
if( lod < 0 )
|
||||
|
@ -335,6 +330,12 @@ static void R_AddSingleLight( viewLight_t* vLight )
|
|||
lod = -1;
|
||||
}
|
||||
|
||||
if( lod == ( numLods - 1 ) )
|
||||
{
|
||||
// blend shadows smoothly in
|
||||
vLight->shadowFadeOut = idMath::Frac( flod );
|
||||
}
|
||||
|
||||
// 2048^2 ultra quality is only for cascaded shadow mapping with sun lights
|
||||
if( lod == 0 && !light->parms.parallel )
|
||||
{
|
||||
|
|
|
@ -455,6 +455,9 @@ void main( PS_IN fragment, out PS_OUT result )
|
|||
|
||||
#endif
|
||||
|
||||
// allow shadows to fade out
|
||||
shadow = saturate( max( shadow, rpJitterTexScale.z ) );
|
||||
|
||||
float3 halfAngleVector = normalize( lightVector + viewVector );
|
||||
float hdotN = clamp( dot3( halfAngleVector, localNormal ), 0.0, 1.0 );
|
||||
|
||||
|
|
Loading…
Reference in a new issue