Added Third CSM Level

-Added csm_third_intensity ConVar
-Added enablethird Hammer option
-Changed csm_current_distance ConVar
-Added csm_third_fov ConVar
-Added csm_nearz and csm_farz ConVars
-Entity-helpers was renamed

-Now r_farz will be 210000 all the time, so fog's one will not work
This commit is contained in:
2022-12-15 17:10:27 +03:00
parent 4f9f455454
commit 87020dcb97
4 changed files with 561 additions and 96 deletions

View File

@@ -96,10 +96,6 @@
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"
const char* maxprojlights = CommandLine()->ParmValue("-ptmax", "10");
ConVar pr_max("pr_max", maxprojlights, 0, "Changes maximum of enabled env_projectedtexture and everything related to it at one time.");
static ConVar r_flashlightdrawfrustum( "r_flashlightdrawfrustum", "0" );
static ConVar r_flashlightmodels( "r_flashlightmodels", "1" );
static ConVar r_shadowrendertotexture( "r_shadowrendertotexture", "0" );
@@ -111,14 +107,16 @@ static ConVar r_shadow_mincastintensity( "r_shadow_mincastintensity", "0.3", FCV
#endif
static ConVar r_flashlight_version2( "r_flashlight_version2", "0", FCVAR_CHEAT | FCVAR_DEVELOPMENTONLY );
ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "1" );
ConVar r_flashlightdepthtexture( "r_flashlightdepthtexture", "0" );
#if defined( _X360 )
ConVar r_flashlightdepthres( "r_flashlightdepthres", "512" );
#else
const char* projlightres = CommandLine()->ParmValue("-ptr", "2048"); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> env_projectedtexture
ConVar r_flashlightdepthres("r_flashlightdepthres", projlightres, 0, "Changes resolution of env_projectedtexture and everything related to it.");
#ifdef MAPBASE
ConVar r_flashlightdepthres( "r_flashlightdepthres", "2048" );
#else
ConVar r_flashlightdepthres( "r_flashlightdepthres", "1024" );
#endif
#endif
#ifdef ASW_PROJECTED_TEXTURES
@@ -127,6 +125,11 @@ ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "1"
ConVar r_threaded_client_shadow_manager( "r_threaded_client_shadow_manager", "0" );
#endif
#ifdef MAPBASE
ConVarRef mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap" );
ConVarRef mat_depthbias_shadowmap( "mat_depthbias_shadowmap" );
#endif
#ifdef _WIN32
#pragma warning( disable: 4701 )
#endif
@@ -1396,7 +1399,14 @@ bool CClientShadowMgr::Init()
SetShadowBlobbyCutoffArea( 0.005 );
m_nMaxDepthTextureShadows = pr_max.GetInt();
#ifndef MAPBASE
bool bTools = CommandLine()->CheckParm( "-tools" ) != NULL;
m_nMaxDepthTextureShadows = bTools ? 4 : 1; // Just one shadow depth texture in games, more in tools
#else
// 5 lets mappers use up to 4 shadow-casting projected textures, which is better than 3.
int iNumShadows = CommandLine()->ParmValue( "-numshadowtextures", 5 );
m_nMaxDepthTextureShadows = iNumShadows;
#endif
bool bLowEnd = ( g_pMaterialSystemHardwareConfig->GetDXSupportLevel() < 80 );
@@ -1419,6 +1429,15 @@ bool CClientShadowMgr::Init()
materials->AddRestoreFunc( ShadowRestoreFunc );
#ifdef MAPBASE
// These need to be referenced here since the cvars don't exist in the initial declaration
mat_slopescaledepthbias_shadowmap = ConVarRef( "mat_slopescaledepthbias_shadowmap" );
mat_depthbias_shadowmap = ConVarRef( "mat_depthbias_shadowmap" );
mat_slopescaledepthbias_shadowmap.SetValue( "16" ); // Would do something like 2 here, but it causes citizens to look weird under flashlights
mat_depthbias_shadowmap.SetValue( "0.00005" );
#endif
return true;
}
@@ -2319,25 +2338,20 @@ void CClientShadowMgr::BuildWorldToShadowMatrix( VMatrix& matWorldToShadow, cons
matWorldToShadow[3][3] = 1.0f;
}
void CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix( VMatrix& matWorldToShadow, const FlashlightState_t &flashlightState )
{
VPROF_BUDGET( "CClientShadowMgr::BuildPerspectiveWorldToFlashlightMatrix", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
// Buildworld to shadow matrix, then perspective projection and concatenate
VMatrix matWorldToShadowView, matPerspective, addW, scaleHalf;
BuildWorldToShadowMatrix(matWorldToShadowView, flashlightState.m_vecLightOrigin,
flashlightState.m_quatOrientation);
MatrixBuildPerspective(matPerspective, flashlightState.m_fHorizontalFOVDegrees,
flashlightState.m_fVerticalFOVDegrees,
flashlightState.m_NearZ, flashlightState.m_FarZ);
MatrixMultiply(matPerspective, matWorldToShadowView, matWorldToShadow);
VMatrix matWorldToShadowView, matPerspective;
BuildWorldToShadowMatrix( matWorldToShadowView, flashlightState.m_vecLightOrigin,
flashlightState.m_quatOrientation );
MatrixBuildPerspective( matPerspective, flashlightState.m_fHorizontalFOVDegrees,
flashlightState.m_fVerticalFOVDegrees,
flashlightState.m_NearZ, flashlightState.m_FarZ );
MatrixMultiply( matPerspective, matWorldToShadowView, matWorldToShadow );
}
#ifdef ASW_PROJECTED_TEXTURES
@@ -4470,13 +4484,18 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
}
CViewSetup shadowView;
#ifndef MAPBASE
shadowView.m_flAspectRatio = 1.0f;
#endif
shadowView.x = shadowView.y = 0;
shadowView.width = shadowDepthTexture->GetActualWidth();
shadowView.height = shadowDepthTexture->GetActualHeight();
#ifndef ASW_PROJECTED_TEXTURES
shadowView.m_bOrtho = false;
shadowView.m_bDoBloomAndToneMapping = false;
#ifdef MAPBASE
shadowView.m_flAspectRatio = (flashlightState.m_fHorizontalFOVDegrees / flashlightState.m_fVerticalFOVDegrees);
#endif // MAPBASE
#endif
// Copy flashlight parameters
@@ -4484,6 +4503,10 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
if ( !flashlightState.m_bOrtho )
{
shadowView.m_bOrtho = false;
#ifdef MAPBASE
shadowView.m_flAspectRatio = (flashlightState.m_fHorizontalFOVDegrees / flashlightState.m_fVerticalFOVDegrees);
#endif // MAPBASE
}
else
{
@@ -4492,6 +4515,10 @@ void CClientShadowMgr::ComputeShadowDepthTextures( const CViewSetup &viewSetup )
shadowView.m_OrthoTop = flashlightState.m_fOrthoTop;
shadowView.m_OrthoRight = flashlightState.m_fOrthoRight;
shadowView.m_OrthoBottom = flashlightState.m_fOrthoBottom;
#ifdef MAPBASE
shadowView.m_flAspectRatio = 1.0f;
#endif
}
shadowView.m_bDoBloomAndToneMapping = false;