diff --git a/sp/src/game/client/baseclientrendertargets.cpp b/sp/src/game/client/baseclientrendertargets.cpp index 3aa642cf0ba..2b929b98033 100644 --- a/sp/src/game/client/baseclientrendertargets.cpp +++ b/sp/src/game/client/baseclientrendertargets.cpp @@ -45,6 +45,30 @@ ITexture* CBaseClientRenderTargets::CreateCameraTexture( IMaterialSystem* pMater CREATERENDERTARGETFLAGS_HDR ); } +#ifdef MAPBASE +ITexture* CBaseClientRenderTargets::CreateCustomCameraTexture( IMaterialSystem* pMaterialSystem, const char *pszTextureName, int iSize ) +{ + return pMaterialSystem->CreateNamedRenderTargetTextureEx2( + pszTextureName, + iSize, iSize, RT_SIZE_DEFAULT, + pMaterialSystem->GetBackBufferFormat(), + MATERIAL_RT_DEPTH_SHARED, + 0, + CREATERENDERTARGETFLAGS_HDR ); +} + +ITexture* CBaseClientRenderTargets::CreateColCorrectMaskTexture( IMaterialSystem* pMaterialSystem, int iSize ) +{ + return pMaterialSystem->CreateNamedRenderTargetTextureEx2( + "_rt_ColCorrectMask", + iSize, iSize, RT_SIZE_PICMIP, + pMaterialSystem->GetBackBufferFormat(), //IMAGE_FORMAT_A8 + MATERIAL_RT_DEPTH_SHARED, + TEXTUREFLAGS_CLAMPS | TEXTUREFLAGS_CLAMPT, + CREATERENDERTARGETFLAGS_HDR ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Called by the engine in material system init and shutdown. // Clients should override this in their inherited version, but the base @@ -60,6 +84,21 @@ void CBaseClientRenderTargets::InitClientRenderTargets( IMaterialSystem* pMateri // Monitors m_CameraTexture.Init( CreateCameraTexture( pMaterialSystem, iCameraTextureSize ) ); + +#ifdef MAPBASE + int iNumCameras = CommandLine()->ParmValue( "-numcameratextures", 3 ); + for ( int i = 0; i < iNumCameras; i++ ) + { + char szName[32]; + Q_snprintf( szName, sizeof(szName), "_rt_Camera%i", i ); + + int iRefIndex = m_CameraTextures.AddToTail(); + m_CameraTextures[iRefIndex].Init( CreateCustomCameraTexture( pMaterialSystem, szName, iCameraTextureSize ) ); + } + + // Miscellaneous + m_ColCorrectMaskTexture.Init( CreateColCorrectMaskTexture( pMaterialSystem ) ); +#endif } //----------------------------------------------------------------------------- @@ -75,4 +114,14 @@ void CBaseClientRenderTargets::ShutdownClientRenderTargets() // Monitors m_CameraTexture.Shutdown(); -} \ No newline at end of file + +#ifdef MAPBASE + for ( int i = 0; i < m_CameraTextures.Count(); i++ ) + { + m_CameraTextures[i].Shutdown(); + } + + // Miscellaneous + m_ColCorrectMaskTexture.Shutdown(); +#endif +} diff --git a/sp/src/game/client/baseclientrendertargets.h b/sp/src/game/client/baseclientrendertargets.h index a4c84d8a87b..01cb9f71033 100644 --- a/sp/src/game/client/baseclientrendertargets.h +++ b/sp/src/game/client/baseclientrendertargets.h @@ -59,6 +59,15 @@ class CBaseClientRenderTargets : public IClientRenderTargets ITexture* CreateWaterRefractionTexture( IMaterialSystem* pMaterialSystem, int iSize = 1024 ); ITexture* CreateCameraTexture( IMaterialSystem* pMaterialSystem, int iSize = 256 ); +#ifdef MAPBASE + // Mapbase render targets + CUtlVector m_CameraTextures; + CTextureReference m_ColCorrectMaskTexture; + + ITexture *CreateCustomCameraTexture( IMaterialSystem *pMaterialSystem, const char *pszTextureName, int iSize = 256 ); + ITexture *CreateColCorrectMaskTexture( IMaterialSystem *pMaterialSystem, int iSize = 1024 ); +#endif + }; #endif // CLIENTRENDERTARTETS_H_ \ No newline at end of file diff --git a/sp/src/game/client/c_baseentity.cpp b/sp/src/game/client/c_baseentity.cpp index 8b13c94ba61..44f199e95a3 100644 --- a/sp/src/game/client/c_baseentity.cpp +++ b/sp/src/game/client/c_baseentity.cpp @@ -3710,7 +3710,9 @@ void C_BaseEntity::ComputeFxBlend( void ) //----------------------------------------------------------------------------- int C_BaseEntity::GetFxBlend( void ) { +#ifndef MAPBASE // Spams the console when drawing beams in stencils, which don't need to update the FX blend Assert( m_nFXComputeFrame == gpGlobals->framecount ); +#endif return m_nRenderFXBlend; } diff --git a/sp/src/game/client/c_colorcorrection.cpp b/sp/src/game/client/c_colorcorrection.cpp index 12e29768e8e..740856daa59 100644 --- a/sp/src/game/client/c_colorcorrection.cpp +++ b/sp/src/game/client/c_colorcorrection.cpp @@ -34,10 +34,14 @@ IMPLEMENT_CLIENTCLASS_DT(C_ColorCorrection, DT_ColorCorrection, CColorCorrection #endif RecvPropString( RECVINFO(m_netLookupFilename) ), RecvPropBool( RECVINFO(m_bEnabled) ), -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- RecvPropBool( RECVINFO(m_bMaster) ), RecvPropBool( RECVINFO(m_bClientSide) ), - RecvPropBool( RECVINFO(m_bExclusive) ) + RecvPropBool( RECVINFO(m_bExclusive) ), + //--------------------------- + RecvPropBool( RECVINFO(m_bMaskEnabled) ), + RecvPropBool( RECVINFO(m_bMaskInvert) ), #endif END_RECV_TABLE() @@ -48,7 +52,8 @@ END_RECV_TABLE() //------------------------------------------------------------------------------ C_ColorCorrection::C_ColorCorrection() { -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- m_minFalloff = -1.0f; m_maxFalloff = -1.0f; m_flFadeInDuration = 0.0f; @@ -59,6 +64,9 @@ C_ColorCorrection::C_ColorCorrection() m_bEnabled = false; m_bMaster = false; m_bExclusive = false; + //--------------------------- + m_bMaskEnabled = false; + m_bMaskInvert = false; #endif m_CCHandle = INVALID_CLIENT_CCHANDLE; @@ -134,7 +142,7 @@ void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale ) if ( mat_colcorrection_disableentities.GetInt() ) { // Allow the colorcorrectionui panel (or user) to turn off color-correction entities - g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive ); + g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive, m_bMaskEnabled, m_bMaskInvert ); return; } @@ -146,7 +154,7 @@ void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale ) if( !m_bEnabled && m_flCurWeight == 0.0f ) { - g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive ); + g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, 0.0f, m_bExclusive, m_bMaskEnabled, m_bMaskInvert ); return; } @@ -161,7 +169,7 @@ void C_ColorCorrection::Update( C_BasePlayer *pPlayer, float ccScale ) if ( weight>1.0f ) weight = 1.0f; } - g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_flCurWeight * ( 1.0 - weight ) * ccScale, m_bExclusive ); + g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, m_flCurWeight * ( 1.0 - weight ) * ccScale, m_bExclusive, m_bMaskEnabled, m_bMaskInvert ); } void C_ColorCorrection::EnableOnClient( bool bEnable, bool bSkipFade ) @@ -214,7 +222,7 @@ float C_ColorCorrection::GetMaxFalloff() void C_ColorCorrection::SetWeight( float fWeight ) { - g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, fWeight, false ); + g_pColorCorrectionMgr->SetColorCorrectionWeight( m_CCHandle, fWeight, false, m_bMaskEnabled, m_bMaskInvert ); } void C_ColorCorrection::StartFade( float flDuration ) @@ -288,7 +296,88 @@ void C_ColorCorrection::ClientThink() } #endif +#ifdef MAPBASE +class C_ColorCorrectionExclude : public C_BaseEntity +{ +public: + DECLARE_CLASS( C_ColorCorrectionExclude, C_BaseEntity ); + DECLARE_CLIENTCLASS(); + + void OnDataChanged( DataUpdateType_t type ); + void UpdateOnRemove( void ); + + void UpdateExclude( void ); + void DestroyExclude( void ); + + EHANDLE m_hExcludeTarget; + color32 m_ExcludeColor; + bool m_bExcludeDisabled; + + int m_nExcludeHandle = -1; +}; + +IMPLEMENT_CLIENTCLASS_DT( C_ColorCorrectionExclude, DT_ColorCorrectionExclude, CColorCorrectionExclude ) + RecvPropEHandle( RECVINFO( m_hExcludeTarget ) ), + RecvPropInt( RECVINFO( m_ExcludeColor ), 0, RecvProxy_IntToColor32 ), + RecvPropBool( RECVINFO( m_bExcludeDisabled ) ), +END_RECV_TABLE() +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_ColorCorrectionExclude::OnDataChanged( DataUpdateType_t updateType ) +{ + BaseClass::OnDataChanged( updateType ); + + UpdateExclude(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_ColorCorrectionExclude::UpdateOnRemove( void ) +{ + DestroyExclude(); + + BaseClass::UpdateOnRemove(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_ColorCorrectionExclude::UpdateExclude( void ) +{ + // destroy the existing effect + DestroyExclude(); + + // create a new effect + if ( m_hExcludeTarget && !m_bExcludeDisabled ) + { + Vector4D vecColor( m_ExcludeColor.r, m_ExcludeColor.g, m_ExcludeColor.b, m_ExcludeColor.a ); + for (int i = 0; i < 4; i++) + { + if (vecColor[i] == 0.0f) + continue; + + vecColor[i] /= 255.0f; + } + + m_nExcludeHandle = g_pColorCorrectionMgr->RegisterExclusionObject( m_hExcludeTarget, &vecColor.AsVector3D(), vecColor.w ); + } +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void C_ColorCorrectionExclude::DestroyExclude( void ) +{ + if ( m_nExcludeHandle != -1 ) + { + g_pColorCorrectionMgr->UnregisterExclusionObject( m_nExcludeHandle ); + m_nExcludeHandle = -1; + } +} +#endif diff --git a/sp/src/game/client/c_colorcorrection.h b/sp/src/game/client/c_colorcorrection.h index 63149a0a02c..4e02ee60fa5 100644 --- a/sp/src/game/client/c_colorcorrection.h +++ b/sp/src/game/client/c_colorcorrection.h @@ -67,7 +67,8 @@ class C_ColorCorrection : public C_BaseEntity bool m_bEnabled; -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- float m_flFadeInDuration; float m_flFadeOutDuration; float m_flMaxWeight; @@ -80,6 +81,10 @@ class C_ColorCorrection : public C_BaseEntity float m_flFadeStartWeight; float m_flFadeStartTime; float m_flFadeDuration; + //--------------------------- + + bool m_bMaskEnabled; + bool m_bMaskInvert; #endif ClientCCHandle_t m_CCHandle; diff --git a/sp/src/game/client/client_mapbase.vpc b/sp/src/game/client/client_mapbase.vpc index 08d38e4e3e6..fbf87c46b7d 100644 --- a/sp/src/game/client/client_mapbase.vpc +++ b/sp/src/game/client/client_mapbase.vpc @@ -74,6 +74,7 @@ $Project $File "mapbase\c_point_glow.cpp" $File "mapbase\c_vgui_text_display.cpp" $File "mapbase\c_weapon_custom_hl2.cpp" + $File "mapbase\colorcorrectionmgr_exclude.cpp" $File "mapbase\mapbase_autocubemap.cpp" $File "mapbase\hud_generic_timer.cpp" } @@ -83,6 +84,9 @@ $Project // Original stunstick files are conditional'd out in the HL2 VPCs $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.cpp" $File "$SRCDIR\game\shared\hl2mp\weapon_stunstick.h" + + $File "hl2\hl2_rendertargets.cpp" + $File "hl2\hl2_rendertargets.h" } $Folder "HL2MP" diff --git a/sp/src/game/client/clientmode_shared.cpp b/sp/src/game/client/clientmode_shared.cpp index f2e6e31dc55..8cd32ecbdc1 100644 --- a/sp/src/game/client/clientmode_shared.cpp +++ b/sp/src/game/client/clientmode_shared.cpp @@ -282,6 +282,22 @@ static void __MsgFunc_VGUIMenu( bf_read &msg ) gViewPortInterface->ShowPanel( viewport, bShow ); } +#ifdef MAPBASE +static void __MsgFunc_NodrawToggle( bf_read &msg ) +{ + C_BaseEntity *pEntity = C_BaseEntity::Instance( msg.ReadShort() ); + bool bEnable = msg.ReadOneBit(); + + if ( pEntity ) + { + if ( bEnable ) + pEntity->AddEffects( EF_NODRAW ); + else + pEntity->RemoveEffects( EF_NODRAW ); + } +} + #endif + //----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- @@ -387,6 +403,9 @@ void ClientModeShared::Init() HOOK_MESSAGE( VGUIMenu ); HOOK_MESSAGE( Rumble ); +#ifdef MAPBASE + HOOK_MESSAGE( NodrawToggle ); +#endif } @@ -835,6 +854,18 @@ bool ClientModeShared::DoPostScreenSpaceEffects( const CViewSetup *pSetup ) return true; } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +bool ClientModeShared::DoPostScreenSpaceEffectsPostViewModel( const CViewSetup *pSetup ) +{ + g_pColorCorrectionMgr->RenderExclusionObjects( pSetup ); + + return true; +} +#endif + //----------------------------------------------------------------------------- // Purpose: // Output : vgui::Panel diff --git a/sp/src/game/client/clientmode_shared.h b/sp/src/game/client/clientmode_shared.h index 20288db8f79..0269faf2209 100644 --- a/sp/src/game/client/clientmode_shared.h +++ b/sp/src/game/client/clientmode_shared.h @@ -139,6 +139,9 @@ class ClientModeShared : public IClientMode, public CGameEventListener //============================================================================= virtual bool DoPostScreenSpaceEffects( const CViewSetup *pSetup ); +#ifdef MAPBASE + virtual bool DoPostScreenSpaceEffectsPostViewModel( const CViewSetup *pSetup ); +#endif virtual void DisplayReplayMessage( const char *pLocalizeName, float flDuration, bool bUrgent, const char *pSound, bool bDlg ); diff --git a/sp/src/game/client/colorcorrectionmgr.cpp b/sp/src/game/client/colorcorrectionmgr.cpp index f04438d6c34..8832857fe44 100644 --- a/sp/src/game/client/colorcorrectionmgr.cpp +++ b/sp/src/game/client/colorcorrectionmgr.cpp @@ -8,8 +8,8 @@ #include "cbase.h" #include "tier0/vprof.h" #include "colorcorrectionmgr.h" -#ifdef MAPBASE // From Alien Swarm SDK -#include "clientmode_shared.h" //"clientmode.h" +#ifdef MAPBASE +#include "clientmode_shared.h" //"clientmode.h" // From Alien Swarm SDK // NOTE: This has to be the last file included! #include "tier0/memdbgon.h" @@ -27,6 +27,8 @@ static ConVar mat_colcorrection_editor( "mat_colcorrection_editor", "0" ); static CUtlVector g_ColorCorrectionList; static CUtlVector g_ColorCorrectionVolumeList; + +extern int g_nColCorrectExcludeMask; #endif @@ -36,6 +38,9 @@ static CUtlVector g_ColorCorrectionVolumeList; CColorCorrectionMgr::CColorCorrectionMgr() { m_nActiveWeightCount = 0; +#ifdef MAPBASE + m_nFirstFreeSlot = ColCorrectExcludeDefinition_t::END_OF_FREE_LIST; +#endif } @@ -115,17 +120,25 @@ void CColorCorrectionMgr::RemoveColorCorrectionVolume( C_ColorCorrectionVolume * // Modify color correction weights //------------------------------------------------------------------------------ #ifdef MAPBASE // From Alien Swarm SDK -void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive ) +ConVar mat_colcorrection_mask( "mat_colcorrection_mask", "1" ); +ConVar mat_colcorrection_mask_always_use( "mat_colcorrection_mask_always_use", "0" ); +ConVar mat_colcorrection_mask_always_invert( "mat_colcorrection_mask_always_invert", "0" ); + +void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive, bool bUseMask, bool bInvertMask ) { if ( h != INVALID_CLIENT_CCHANDLE ) { - SetWeightParams_t params = { h, flWeight, bExclusive }; + if ( mat_colcorrection_mask_always_use.GetBool() ) + bUseMask = true; + else if ( !mat_colcorrection_mask.GetBool() ) + bUseMask = false; + + if ( mat_colcorrection_mask_always_invert.GetBool() ) + bInvertMask = true; + + SetWeightParams_t params = { h, flWeight, bExclusive, bUseMask, bInvertMask }; m_colorCorrectionWeights.AddToTail( params ); - if( bExclusive && m_bHaveExclusiveWeight && ( flWeight != 0.0f ) ) - { - DevWarning( "Found multiple active color_correction entities with exclusive setting enabled. This is invalid.\n" ); - } - if ( bExclusive ) + if ( bExclusive && flWeight > m_flExclusiveWeight ) { m_bHaveExclusiveWeight = true; m_flExclusiveWeight = flWeight; @@ -133,10 +146,34 @@ void CColorCorrectionMgr::SetColorCorrectionWeight( ClientCCHandle_t h, float fl } } +#ifdef MAPBASE +struct CCSortableParams_t +{ + ClientCCHandle_t handle; + float flWeight; +}; + +int CCHandleSort( const CCSortableParams_t *a, const CCSortableParams_t *b ) +{ + // Choose the higher weight + if ( a->flWeight > b->flWeight ) + return -1; + else if ( a->flWeight < b->flWeight ) + return 1; + + return 0; +} +#endif + void CColorCorrectionMgr::CommitColorCorrectionWeights() { CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); +#ifdef MAPBASE + // Need these to be in order so that they can translate to engine_post + CUtlVector< CCSortableParams_t > vecActiveLookups; +#endif + for ( int i = 0; i < m_colorCorrectionWeights.Count(); i++ ) { ColorCorrectionHandle_t ccHandle = reinterpret_cast( m_colorCorrectionWeights[i].handle ); @@ -153,8 +190,56 @@ void CColorCorrectionMgr::CommitColorCorrectionWeights() if ( flWeight != 0.0f ) { ++m_nActiveWeightCount; +#ifdef MAPBASE + if ( m_colorCorrectionWeights[i].bUseMask ) + ++m_nActiveMaskWeightCount; + + int idx = vecActiveLookups.AddToTail(); + vecActiveLookups[idx].flWeight = flWeight; + vecActiveLookups[idx].handle = m_colorCorrectionWeights[i].handle; +#endif } } + +#ifdef MAPBASE + g_nColCorrectExcludeMask = 0; + if ( m_bDrawingColCorrectExclude ) + { + vecActiveLookups.Sort( CCHandleSort ); + + for ( int i = 0; i < m_colorCorrectionWeights.Count(); i++ ) + { + if ( m_colorCorrectionWeights[i].bUseMask ) + { + // engine_post counts from 0 + int j = 0; + for (; j < vecActiveLookups.Count(); j++) + { + if ( vecActiveLookups[j].handle == m_colorCorrectionWeights[i].handle ) + break; + } + + if ( j < vecActiveLookups.Count() ) + { + g_nColCorrectExcludeMask |= (1 << j); + + if ( m_colorCorrectionWeights[i].bInvertMask ) + g_nColCorrectExcludeMask |= (1 << (16 + j)); + } + } + } + + // Clean up any invalid definitions + for ( int i = m_ColCorrectExcludeDefs.Count()-1; i >= 0; i-- ) + { + if ( !m_ColCorrectExcludeDefs[i].m_hEntity || m_ColCorrectExcludeDefs[i].m_hEntity->IsMarkedForDeletion() ) + { + UnregisterExclusionObject( i ); + } + } + } +#endif + m_colorCorrectionWeights.RemoveAll(); } @@ -206,6 +291,8 @@ void CColorCorrectionMgr::ResetColorCorrectionWeights() m_bHaveExclusiveWeight = false; m_flExclusiveWeight = 0.0f; m_colorCorrectionWeights.RemoveAll(); + + m_nActiveMaskWeightCount = 0; #endif } diff --git a/sp/src/game/client/colorcorrectionmgr.h b/sp/src/game/client/colorcorrectionmgr.h index 8492ac204ca..5c8a51bf2b8 100644 --- a/sp/src/game/client/colorcorrectionmgr.h +++ b/sp/src/game/client/colorcorrectionmgr.h @@ -49,7 +49,7 @@ class CColorCorrectionMgr : public CBaseGameSystem // Modify color correction weights #ifdef MAPBASE // From Alien Swarm SDK - void SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive = false ); + void SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight, bool bExclusive = false, bool bUseMask = false, bool bInvertMask = false ); void UpdateColorCorrection(); #else void SetColorCorrectionWeight( ClientCCHandle_t h, float flWeight ); @@ -60,6 +60,15 @@ class CColorCorrectionMgr : public CBaseGameSystem // Is color correction active? bool HasNonZeroColorCorrectionWeights() const; +#ifdef MAPBASE + // Color Correction Mask + int RegisterExclusionObject( C_BaseEntity *pEntity, Vector *vecColor = NULL, float flAlpha = 1.0f ); + void UnregisterExclusionObject( C_BaseEntity *pEntity ); + void UnregisterExclusionObject( int nGlowObjectHandle ); + + void RenderExclusionObjects( const CViewSetup *pSetup ); +#endif + private: int m_nActiveWeightCount; #ifdef MAPBASE // From Alien Swarm SDK @@ -71,6 +80,10 @@ class CColorCorrectionMgr : public CBaseGameSystem ClientCCHandle_t handle; float flWeight; bool bExclusive; + + // Color Correction Mask + bool bUseMask; + bool bInvertMask; }; CUtlVector< SetWeightParams_t > m_colorCorrectionWeights; @@ -79,6 +92,40 @@ class CColorCorrectionMgr : public CBaseGameSystem void LevelShutdownPreEntity(); #endif + +#ifdef MAPBASE + // Color Correction Mask + struct ColCorrectExcludeDefinition_t + { + bool ShouldDraw() const + { + return m_hEntity && m_hEntity->ShouldDraw(); + } + + bool IsUnused() const { return m_nNextFreeSlot != ColCorrectExcludeDefinition_t::ENTRY_IN_USE; } + void DrawModel(); + + EHANDLE m_hEntity; + bool m_bStudio; + Vector m_vecColor; + float m_flAlpha; + + // Linked list of free slots + int m_nNextFreeSlot; + + // Special values for GlowObjectDefinition_t::m_nNextFreeSlot + static const int END_OF_FREE_LIST = -1; + static const int ENTRY_IN_USE = -2; + }; + + void RenderExclusionModels( ITexture *pRenderTarget, const CViewSetup *pSetup, CMatRenderContextPtr &pRenderContext ); + void ApplyColCorrectExclusionObjects( const CViewSetup *pSetup, CMatRenderContextPtr &pRenderContext, int x, int y, int w, int h ); + + CUtlVector< ColCorrectExcludeDefinition_t > m_ColCorrectExcludeDefs; + bool m_bDrawingColCorrectExclude; + int m_nActiveMaskWeightCount; + int m_nFirstFreeSlot; +#endif }; #ifdef MAPBASE // From Alien Swarm SDK diff --git a/sp/src/game/client/hl2/hl2_rendertargets.cpp b/sp/src/game/client/hl2/hl2_rendertargets.cpp new file mode 100644 index 00000000000..92008121053 --- /dev/null +++ b/sp/src/game/client/hl2/hl2_rendertargets.cpp @@ -0,0 +1,41 @@ +//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============// +// +// Purpose: HL2 implementation of CBaseClientRenderTargets for custom RT textures. +// +// (Added by Mapbase for generalized use; most code will act as though +// this is a default feature) +// +// Author: Blixibon +// +//=============================================================================// + +#include "cbase.h" +#include "hl2_rendertargets.h" +#include "materialsystem/imaterialsystemhardwareconfig.h" + +//----------------------------------------------------------------------------- +// Purpose: Called by the engine in material system init and shutdown. +// Clients should override this in their inherited version, but the base +// is to init all standard render targets for use. +// Input : pMaterialSystem - the engine's material system (our singleton is not yet inited at the time this is called) +// pHardwareConfig - the user hardware config, useful for conditional render target setup +//----------------------------------------------------------------------------- +void CHL2RenderTargets::InitClientRenderTargets( IMaterialSystem* pMaterialSystem, IMaterialSystemHardwareConfig* pHardwareConfig ) +{ + BaseClass::InitClientRenderTargets( pMaterialSystem, pHardwareConfig ); +} + +//----------------------------------------------------------------------------- +// Purpose: Shut down each CTextureReference we created in InitClientRenderTargets. +// Called by the engine in material system shutdown. +// Input : - +//----------------------------------------------------------------------------- +void CHL2RenderTargets::ShutdownClientRenderTargets() +{ + BaseClass::ShutdownClientRenderTargets(); +} + +static CHL2RenderTargets g_HL2RenderTargets; +EXPOSE_SINGLE_INTERFACE_GLOBALVAR( CHL2RenderTargets, IClientRenderTargets, + CLIENTRENDERTARGETS_INTERFACE_VERSION, g_HL2RenderTargets ); +CHL2RenderTargets* g_pHL2RenderTargets = &g_HL2RenderTargets; diff --git a/sp/src/game/client/hl2/hl2_rendertargets.h b/sp/src/game/client/hl2/hl2_rendertargets.h new file mode 100644 index 00000000000..b363446cdd3 --- /dev/null +++ b/sp/src/game/client/hl2/hl2_rendertargets.h @@ -0,0 +1,36 @@ +//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============// +// +// Purpose: HL2 implementation of CBaseClientRenderTargets for custom RT textures. +// +// (Added by Mapbase for generalized use; most code will act as though +// this is a default feature) +// +// Author: Blixibon +// +//=============================================================================// +#ifndef HL2_RENDERTARGETS_H +#define HL2_RENDERTARGETS_H +#ifdef _WIN32 +#pragma once +#endif + +#include "baseclientrendertargets.h" + +class CHL2RenderTargets : public CBaseClientRenderTargets +{ + // no networked vars + DECLARE_CLASS_GAMEROOT( CHL2RenderTargets, CBaseClientRenderTargets ); +public: + void InitClientRenderTargets( IMaterialSystem *pMaterialSystem, IMaterialSystemHardwareConfig *pHardwareConfig ); + void ShutdownClientRenderTargets ( void ); + +protected: + + // + // Define custom RT textures below. See baseclientrendertargets.h for examples + // +}; + +extern CHL2RenderTargets *g_pHL2RenderTargets; + +#endif // HL2_RENDERTARGETS_H \ No newline at end of file diff --git a/sp/src/game/client/iclientmode.h b/sp/src/game/client/iclientmode.h index 38b60047aaa..cb87ce072e7 100644 --- a/sp/src/game/client/iclientmode.h +++ b/sp/src/game/client/iclientmode.h @@ -135,6 +135,11 @@ abstract_class IClientMode virtual bool DoPostScreenSpaceEffects( const CViewSetup *pSetup ) = 0; +#ifdef MAPBASE + // For effects that assume the viewmodel has been drawn + virtual bool DoPostScreenSpaceEffectsPostViewModel( const CViewSetup *pSetup ) = 0; +#endif + virtual void DisplayReplayMessage( const char *pLocalizeName, float flDuration, bool bUrgent, const char *pSound, bool bDlg ) = 0; diff --git a/sp/src/game/client/mapbase/colorcorrectionmgr_exclude.cpp b/sp/src/game/client/mapbase/colorcorrectionmgr_exclude.cpp new file mode 100644 index 00000000000..ff8a7d4d0e1 --- /dev/null +++ b/sp/src/game/client/mapbase/colorcorrectionmgr_exclude.cpp @@ -0,0 +1,309 @@ +//========= Mapbase - https://github.com/mapbase-source/source-sdk-2013 ============// +// +// Purpose: Color correction mask rendering +// +// Author: Blixibon +// +//=============================================================================// + +#include "cbase.h" +#include "tier0/vprof.h" +#include "colorcorrectionmgr.h" +#include "view_shared.h" +#include "viewpostprocess.h" +#include "model_types.h" +#include "materialsystem/imaterialvar.h" +#include "materialsystem/itexture.h" + +// NOTE: This has to be the last file included! +#include "tier0/memdbgon.h" + +//------------------------------------------------------------------------------ +// Color Correction Mask +//------------------------------------------------------------------------------ +int CColorCorrectionMgr::RegisterExclusionObject( C_BaseEntity *pEntity, Vector *vecColor, float flAlpha ) +{ + int nIndex = -1; + for ( int i = 0; i < m_ColCorrectExcludeDefs.Count(); i++ ) + { + if ( m_ColCorrectExcludeDefs[i].m_hEntity == pEntity ) + { + nIndex = i; + break; + } + } + + if ( nIndex == -1 ) + { + if (m_nFirstFreeSlot == ColCorrectExcludeDefinition_t::END_OF_FREE_LIST) + { + nIndex = m_ColCorrectExcludeDefs.AddToTail(); + } + else + { + nIndex = m_nFirstFreeSlot; + m_nFirstFreeSlot = m_ColCorrectExcludeDefs[nIndex].m_nNextFreeSlot; + } + } + + m_ColCorrectExcludeDefs[nIndex].m_hEntity = pEntity; + m_ColCorrectExcludeDefs[nIndex].m_bStudio = (modelinfo->GetModelType( pEntity->GetModel() ) == mod_studio); + m_ColCorrectExcludeDefs[nIndex].m_vecColor = vecColor ? *vecColor : Vector( 1.0f, 1.0f, 1.0f ); + m_ColCorrectExcludeDefs[nIndex].m_flAlpha = flAlpha; + m_ColCorrectExcludeDefs[nIndex].m_nNextFreeSlot = ColCorrectExcludeDefinition_t::ENTRY_IN_USE; + + return nIndex; +} + +void CColorCorrectionMgr::UnregisterExclusionObject( C_BaseEntity *pEntity ) +{ + for ( int i = 0; i < m_ColCorrectExcludeDefs.Count(); i++ ) + { + if ( m_ColCorrectExcludeDefs[i].m_hEntity == pEntity ) + { + UnregisterExclusionObject( i ); + break; + } + } +} + +void CColorCorrectionMgr::UnregisterExclusionObject( int nGlowObjectHandle ) +{ + if ( m_ColCorrectExcludeDefs.Count() >= nGlowObjectHandle ) + return; + + Assert( !m_ColCorrectExcludeDefs[nGlowObjectHandle].IsUnused() ); + + m_ColCorrectExcludeDefs[nGlowObjectHandle].m_nNextFreeSlot = m_nFirstFreeSlot; + m_ColCorrectExcludeDefs[nGlowObjectHandle].m_hEntity = NULL; + m_nFirstFreeSlot = nGlowObjectHandle; +} + +// This was copied directly from glow_outline_effect. +// TODO: Generalized stencil functions? +struct CCShaderStencilState_t +{ + bool m_bEnable; + StencilOperation_t m_FailOp; + StencilOperation_t m_ZFailOp; + StencilOperation_t m_PassOp; + StencilComparisonFunction_t m_CompareFunc; + int m_nReferenceValue; + uint32 m_nTestMask; + uint32 m_nWriteMask; + + CCShaderStencilState_t() + { + m_bEnable = false; + m_PassOp = m_FailOp = m_ZFailOp = STENCILOPERATION_KEEP; + m_CompareFunc = STENCILCOMPARISONFUNCTION_ALWAYS; + m_nReferenceValue = 0; + m_nTestMask = m_nWriteMask = 0xFFFFFFFF; + } + + void SetStencilState( CMatRenderContextPtr &pRenderContext ) + { + pRenderContext->SetStencilEnable( m_bEnable ); + pRenderContext->SetStencilFailOperation( m_FailOp ); + pRenderContext->SetStencilZFailOperation( m_ZFailOp ); + pRenderContext->SetStencilPassOperation( m_PassOp ); + pRenderContext->SetStencilCompareFunction( m_CompareFunc ); + pRenderContext->SetStencilReferenceValue( m_nReferenceValue ); + pRenderContext->SetStencilTestMask( m_nTestMask ); + pRenderContext->SetStencilWriteMask( m_nWriteMask ); + } +}; + +extern bool g_bDumpRenderTargets; + +void CColorCorrectionMgr::ColCorrectExcludeDefinition_t::DrawModel() +{ + if ( m_hEntity ) + { + // UNDONE: Figure out a way to draw non-studio models in white + if ( m_bStudio ) + { + m_hEntity->DrawModel( STUDIO_RENDER ); + } + else + { + m_hEntity->DrawModel( STUDIO_RENDER ); + } + + /*if ( m_pRenderable->GetIClientUnknown() && m_pRenderable->GetIClientUnknown()->GetBaseEntity() ) + { + C_BaseEntity *pAttachment = m_pRenderable->GetIClientUnknown()->GetBaseEntity()->FirstMoveChild(); + + while ( pAttachment != NULL ) + { + if ( !g_GlowObjectManager.HasGlowEffect( pAttachment ) && pAttachment->ShouldDraw() && !pAttachment->IgnoresZBuffer() ) + { + pAttachment->DrawModel( STUDIO_RENDER ); + } + pAttachment = pAttachment->NextMovePeer(); + } + }*/ + } +} + +extern ConVar mat_colcorrection_mask; + +void CColorCorrectionMgr::RenderExclusionObjects( const CViewSetup *pSetup ) +{ + if ( m_nActiveMaskWeightCount > 0 && g_pMaterialSystemHardwareConfig->SupportsPixelShaders_2_0() ) + { + if ( mat_colcorrection_mask.GetBool() ) + { + CMatRenderContextPtr pRenderContext( materials ); + + int nX, nY, nWidth, nHeight; + pRenderContext->GetViewport( nX, nY, nWidth, nHeight ); + + PIXEvent _pixEvent( pRenderContext, "ColCorrectExclusionObjects" ); + ApplyColCorrectExclusionObjects( pSetup, pRenderContext, nX, nY, nWidth, nHeight ); + } + } +} + +void CColorCorrectionMgr::RenderExclusionModels( ITexture *pRenderTarget, const CViewSetup *pSetup, CMatRenderContextPtr &pRenderContext ) +{ + //==========================================================================================// + // This renders solid pixels with the correct coloring for each object that needs the glow. // + // After this function returns, this image will then be blurred and added into the frame // + // buffer with the objects stenciled out. // + //==========================================================================================// + ITexture *pRtFullFrame1 = materials->FindTexture( "_rt_FullFrameFB1", TEXTURE_GROUP_RENDER_TARGET ); + pRenderContext->CopyRenderTargetToTexture( pRtFullFrame1 ); + + // Save modulation color and blend + Vector vOrigColor; + render->GetColorModulation( vOrigColor.Base() ); + float flOrigBlend = render->GetBlend(); + + //SetRenderTargetAndViewPort( pRenderTarget ); + + pRenderContext->ClearColor3ub( 0, 0, 0 ); + pRenderContext->ClearBuffers( true, false, false ); + + // Set override material for glow color + IMaterial *pMatGlowColor = NULL; + + pMatGlowColor = materials->FindMaterial( "dev/glow_color", TEXTURE_GROUP_OTHER, true ); + g_pStudioRender->ForcedMaterialOverride( pMatGlowColor ); + + CCShaderStencilState_t stencilState; + stencilState.m_bEnable = false; + stencilState.m_nReferenceValue = 0; + stencilState.m_nTestMask = 0xFF; + stencilState.m_CompareFunc = STENCILCOMPARISONFUNCTION_ALWAYS; + stencilState.m_PassOp = STENCILOPERATION_KEEP; + stencilState.m_FailOp = STENCILOPERATION_KEEP; + stencilState.m_ZFailOp = STENCILOPERATION_KEEP; + + stencilState.SetStencilState( pRenderContext ); + + //==================// + // Draw the objects // + //==================// + for ( int i = 0; i < m_ColCorrectExcludeDefs.Count(); ++ i ) + { + if ( m_ColCorrectExcludeDefs[i].IsUnused() || !m_ColCorrectExcludeDefs[i].ShouldDraw() ) + continue; + + render->SetColorModulation( m_ColCorrectExcludeDefs[i].m_vecColor.Base() ); // This only sets rgb, not alpha + render->SetBlend( m_ColCorrectExcludeDefs[i].m_flAlpha ); + + pRenderContext->OverrideDepthEnable( true, false ); + + m_ColCorrectExcludeDefs[i].DrawModel(); + } + + if ( g_bDumpRenderTargets ) + { + DumpTGAofRenderTarget( pSetup->width, pSetup->height, "ColCorrectMask" ); + } + + g_pStudioRender->ForcedMaterialOverride( NULL ); + render->SetColorModulation( vOrigColor.Base() ); + render->SetBlend( flOrigBlend ); + + CCShaderStencilState_t stencilStateDisable; + stencilStateDisable.m_bEnable = false; + stencilStateDisable.SetStencilState( pRenderContext ); + + // Reset depth override + pRenderContext->OverrideDepthEnable( false, false ); + + // Copy what we just rendered to FullFrame + pRenderContext->CopyRenderTargetToTexture( pRenderTarget ); + + // Restore our backup + pRenderContext->CopyTextureToRenderTargetEx( 0, pRtFullFrame1, NULL ); +} + +void CColorCorrectionMgr::ApplyColCorrectExclusionObjects( const CViewSetup *pSetup, CMatRenderContextPtr &pRenderContext, int x, int y, int w, int h ) +{ + //=======================================================// + // Render objects into stencil buffer // + //=======================================================// + // Set override shader to the same simple shader we use to render the glow models + IMaterial *pMatGlowColor = materials->FindMaterial( "dev/glow_color", TEXTURE_GROUP_OTHER, true ); + g_pStudioRender->ForcedMaterialOverride( pMatGlowColor ); + + CCShaderStencilState_t stencilStateDisable; + stencilStateDisable.m_bEnable = false; + float flSavedBlend = render->GetBlend(); + + // Set alpha to 0 so we don't touch any color pixels + render->SetBlend( 0.0f ); + pRenderContext->OverrideDepthEnable( true, false ); + + int iNumGlowObjects = 0; + + for ( int i = 0; i < m_ColCorrectExcludeDefs.Count(); ++ i ) + { + if ( m_ColCorrectExcludeDefs[i].IsUnused() || !m_ColCorrectExcludeDefs[i].ShouldDraw() ) + continue; + + CCShaderStencilState_t stencilState; + stencilState.m_bEnable = true; + stencilState.m_nReferenceValue = 2; + stencilState.m_nTestMask = 0x1; + stencilState.m_nWriteMask = 0x3; + stencilState.m_CompareFunc = STENCILCOMPARISONFUNCTION_EQUAL; + stencilState.m_PassOp = STENCILOPERATION_INCRSAT; + stencilState.m_FailOp = STENCILOPERATION_KEEP; + stencilState.m_ZFailOp = STENCILOPERATION_KEEP; + + stencilState.SetStencilState( pRenderContext ); + + m_ColCorrectExcludeDefs[i].DrawModel(); + + iNumGlowObjects++; + } + + pRenderContext->OverrideDepthEnable( false, false ); + render->SetBlend( flSavedBlend ); + stencilStateDisable.SetStencilState( pRenderContext ); + g_pStudioRender->ForcedMaterialOverride( NULL ); + + // If there aren't any objects to glow, don't do all this other stuff + // this fixes a bug where if there are glow objects in the list, but none of them are glowing, + // the whole screen blooms. + if ( iNumGlowObjects <= 0 ) + { + m_bDrawingColCorrectExclude = false; + return; + } + + m_bDrawingColCorrectExclude = true; + + //============================================= + // Render the glow colors to _rt_FullFrameFB + //============================================= + { + PIXEvent pixEvent( pRenderContext, "RenderExclusionModels" ); + ITexture *pRenderTarget = materials->FindTexture( "_rt_ColCorrectMask", TEXTURE_GROUP_RENDER_TARGET ); + RenderExclusionModels( pRenderTarget, pSetup, pRenderContext ); + } +} diff --git a/sp/src/game/client/viewdebug.cpp b/sp/src/game/client/viewdebug.cpp index 94988d9f84d..e1fbba41ab3 100644 --- a/sp/src/game/client/viewdebug.cpp +++ b/sp/src/game/client/viewdebug.cpp @@ -31,6 +31,7 @@ static ConVar mat_framebuffercopyoverlaysize( "mat_framebuffercopyoverlaysize", static ConVar mat_showcamerarendertarget( "mat_showcamerarendertarget", "0", FCVAR_CHEAT ); #ifdef MAPBASE static ConVar mat_showcamerarendertarget_all( "mat_showcamerarendertarget_all", "0", FCVAR_CHEAT ); +static ConVar mat_showccmaskrendertarget( "mat_showccmaskrendertarget", "0", FCVAR_CHEAT ); #endif static ConVar mat_camerarendertargetoverlaysize( "mat_camerarendertargetoverlaysize", "256", FCVAR_CHEAT ); static ConVar mat_hsv( "mat_hsv", "0", FCVAR_CHEAT ); @@ -675,6 +676,16 @@ void CDebugViewRender::Draw2DDebuggingInfo( const CViewSetup &view ) } #endif +#ifdef MAPBASE + if ( mat_showccmaskrendertarget.GetBool() ) + { + float w = mat_camerarendertargetoverlaysize.GetFloat(); + float h = mat_camerarendertargetoverlaysize.GetFloat(); + + OverlayCameraRenderTarget( "debug/debugccmaskrendertarget", 0, 0, w, h ); + } +#endif + if ( r_flashlightdrawdepth.GetBool() ) { shadowmgr->DrawFlashlightDepthTexture( ); diff --git a/sp/src/game/client/viewpostprocess.cpp b/sp/src/game/client/viewpostprocess.cpp index e1845d8dd0c..0df5857512f 100644 --- a/sp/src/game/client/viewpostprocess.cpp +++ b/sp/src/game/client/viewpostprocess.cpp @@ -50,6 +50,15 @@ float g_flDOFFarBlurRadius = 10.0f; bool g_bFlashlightIsOn = false; +#ifdef MAPBASE +// Mask marking each color correction table that should be affected by the exclusion texture +// Controlled by CColorCorrectionMgr +int g_nColCorrectExcludeMask = 0; + +float g_flColCorrectExcludeExponent = 0.3f; +static ConVar mat_colcorrection_exclude_exponent( "mat_colcorrection_exclude_exponent", "0.1" ); +#endif + // hdr parameters ConVar mat_bloomscale( "mat_bloomscale", "1" ); ConVar mat_hdr_level( "mat_hdr_level", "2", FCVAR_ARCHIVE ); @@ -1282,12 +1291,20 @@ class CEnginePostMaterialProxy : public CEntityMaterialProxy IMaterialVar *m_pMaterialParam_ColCorrectNumLookups; IMaterialVar *m_pMaterialParam_ColCorrectDefaultWeight; IMaterialVar *m_pMaterialParam_ColCorrectLookupWeights; +#ifdef MAPBASE + IMaterialVar *m_pMaterialParam_ColCorrectExcludeMask; + IMaterialVar *m_pMaterialParam_ColCorrectExcludeExponent; +#endif IMaterialVar *m_pMaterialParam_LocalContrastStrength; IMaterialVar *m_pMaterialParam_LocalContrastEdgeStrength; IMaterialVar *m_pMaterialParam_VignetteStart; IMaterialVar *m_pMaterialParam_VignetteEnd; IMaterialVar *m_pMaterialParam_VignetteBlurEnable; IMaterialVar *m_pMaterialParam_VignetteBlurStrength; +#ifdef MAPBASE + IMaterialVar *m_pMaterialParam_VignetteEnable; + IMaterialVar *m_pMaterialParam_VignetteStrength; +#endif IMaterialVar *m_pMaterialParam_FadeToBlackStrength; IMaterialVar *m_pMaterialParam_DepthBlurFocalDistance; IMaterialVar *m_pMaterialParam_DepthBlurStrength; @@ -1330,12 +1347,20 @@ CEnginePostMaterialProxy::CEnginePostMaterialProxy() m_pMaterialParam_ColCorrectNumLookups = NULL; m_pMaterialParam_ColCorrectDefaultWeight = NULL; m_pMaterialParam_ColCorrectLookupWeights = NULL; +#ifdef MAPBASE + m_pMaterialParam_ColCorrectExcludeMask = NULL; + m_pMaterialParam_ColCorrectExcludeExponent = NULL; +#endif m_pMaterialParam_LocalContrastStrength = NULL; m_pMaterialParam_LocalContrastEdgeStrength = NULL; m_pMaterialParam_VignetteStart = NULL; m_pMaterialParam_VignetteEnd = NULL; m_pMaterialParam_VignetteBlurEnable = NULL; m_pMaterialParam_VignetteBlurStrength = NULL; +#ifdef MAPBASE + m_pMaterialParam_VignetteEnable = NULL; + m_pMaterialParam_VignetteStrength = NULL; +#endif m_pMaterialParam_FadeToBlackStrength = NULL; m_pMaterialParam_DepthBlurFocalDistance = NULL; m_pMaterialParam_DepthBlurStrength = NULL; @@ -1361,12 +1386,20 @@ bool CEnginePostMaterialProxy::Init( IMaterial *pMaterial, KeyValues *pKeyValues m_pMaterialParam_ColCorrectNumLookups = pMaterial->FindVar( "$colCorrect_NumLookups", &bFoundVar, false ); m_pMaterialParam_ColCorrectDefaultWeight = pMaterial->FindVar( "$colCorrect_DefaultWeight", &bFoundVar, false ); m_pMaterialParam_ColCorrectLookupWeights = pMaterial->FindVar( "$colCorrect_LookupWeights", &bFoundVar, false ); +#ifdef MAPBASE + m_pMaterialParam_ColCorrectExcludeMask = pMaterial->FindVar( "$colCorrect_ExcludeMask", &bFoundVar, false ); + m_pMaterialParam_ColCorrectExcludeExponent = pMaterial->FindVar( "$colCorrect_ExcludeExponent", &bFoundVar, false ); +#endif m_pMaterialParam_LocalContrastStrength = pMaterial->FindVar( "$localContrastScale", &bFoundVar, false ); m_pMaterialParam_LocalContrastEdgeStrength = pMaterial->FindVar( "$localContrastEdgeScale", &bFoundVar, false ); m_pMaterialParam_VignetteStart = pMaterial->FindVar( "$localContrastVignetteStart", &bFoundVar, false ); m_pMaterialParam_VignetteEnd = pMaterial->FindVar( "$localContrastVignetteEnd", &bFoundVar, false ); m_pMaterialParam_VignetteBlurEnable = pMaterial->FindVar( "$blurredVignetteEnable", &bFoundVar, false ); m_pMaterialParam_VignetteBlurStrength = pMaterial->FindVar( "$blurredVignetteScale", &bFoundVar, false ); +#ifdef MAPBASE + m_pMaterialParam_VignetteEnable = pMaterial->FindVar( "$vignetteEnable", &bFoundVar, false ); + m_pMaterialParam_VignetteStrength = pMaterial->FindVar( "$vignetteStrength", &bFoundVar, false ); +#endif m_pMaterialParam_FadeToBlackStrength = pMaterial->FindVar( "$fadeToBlackScale", &bFoundVar, false ); m_pMaterialParam_DepthBlurFocalDistance = pMaterial->FindVar( "$depthBlurFocalDistance", &bFoundVar, false ); m_pMaterialParam_DepthBlurStrength = pMaterial->FindVar( "$depthBlurStrength", &bFoundVar, false ); @@ -1416,6 +1449,14 @@ void CEnginePostMaterialProxy::OnBind( C_BaseEntity *pEnt ) if ( m_pMaterialParam_VignetteBlurStrength ) m_pMaterialParam_VignetteBlurStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_VIGNETTE_BLUR_STRENGTH ] ); +#ifdef MAPBASE + if ( m_pMaterialParam_VignetteEnable ) + m_pMaterialParam_VignetteEnable->SetIntValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_TOP_VIGNETTE_STRENGTH ] > 0.0f ? 1 : 0 ); + + if (m_pMaterialParam_VignetteStrength) + m_pMaterialParam_VignetteStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_TOP_VIGNETTE_STRENGTH ] ); +#endif + if ( m_pMaterialParam_FadeToBlackStrength ) m_pMaterialParam_FadeToBlackStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_FADE_TO_BLACK_STRENGTH ] ); @@ -1431,7 +1472,13 @@ void CEnginePostMaterialProxy::OnBind( C_BaseEntity *pEnt ) if ( m_pMaterialParam_FilmGrainStrength ) m_pMaterialParam_FilmGrainStrength->SetFloatValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_FILM_GRAIN_STRENGTH ] ); - +#ifdef MAPBASE + if ( m_pMaterialParam_ColCorrectExcludeMask ) + m_pMaterialParam_ColCorrectExcludeMask->SetIntValue( g_nColCorrectExcludeMask ); + + if ( m_pMaterialParam_ColCorrectExcludeExponent ) + m_pMaterialParam_ColCorrectExcludeExponent->SetFloatValue( g_flColCorrectExcludeExponent ); +#endif if ( m_pMaterialParam_FadeType ) { @@ -1526,6 +1573,13 @@ IMaterial * CEnginePostMaterialProxy::SetupEnginePostMaterial( const Vector4D & SetupEnginePostMaterialAA( bPerformSoftwareAA, flAAStrength ); +#ifdef MAPBASE + if ( bPerformColCorrect ) + { + g_flColCorrectExcludeExponent = mat_colcorrection_exclude_exponent.GetFloat(); + } +#endif + //if ( bPerformSoftwareAA || bPerformColCorrect ) { SetupEnginePostMaterialTextureTransform( fullViewportBloomUVs, fullViewportFBUVs, destTexSize ); diff --git a/sp/src/game/client/viewrender.cpp b/sp/src/game/client/viewrender.cpp index 6bcff8da90e..a847ffcaa30 100644 --- a/sp/src/game/client/viewrender.cpp +++ b/sp/src/game/client/viewrender.cpp @@ -2242,6 +2242,10 @@ void CViewRender::RenderView( const CViewSetup &view, int nClearFlags, int whatT #endif DrawViewModels( view, whatToDraw & RENDERVIEW_DRAWVIEWMODEL ); +#ifdef MAPBASE + GetClientModeNormal()->DoPostScreenSpaceEffectsPostViewModel( &view ); +#endif + DrawUnderwaterOverlay(); PixelVisibility_EndScene(); diff --git a/sp/src/game/server/baseentity.cpp b/sp/src/game/server/baseentity.cpp index 97bf237d13a..ae01a82e071 100644 --- a/sp/src/game/server/baseentity.cpp +++ b/sp/src/game/server/baseentity.cpp @@ -4404,6 +4404,30 @@ void CBaseEntity::SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways ) } +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: If true, this entity will notify clients when EF_NODRAW is set. +// This is mainly a band-aid for when the client paradoxically wants +// to know this. +//----------------------------------------------------------------------------- +void CBaseEntity::OnNodrawToggled() +{ + if ( ShouldNetworkNodraw() ) + { + // MP TODO: Optimize who receives this message? + CRecipientFilter filter; + filter.AddAllPlayers(); + filter.MakeReliable(); + + UserMessageBegin( filter, "NodrawToggle" ); + WRITE_ENTITY( entindex() ); + WRITE_BOOL( IsEffectActive( EF_NODRAW ) ); + MessageEnd(); + } +} +#endif + + //----------------------------------------------------------------------------- // Returns which skybox the entity is in //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/baseentity.h b/sp/src/game/server/baseentity.h index 77b7b46d898..97886837abd 100644 --- a/sp/src/game/server/baseentity.h +++ b/sp/src/game/server/baseentity.h @@ -559,6 +559,13 @@ class CBaseEntity : public IServerEntity void SetSimulatedEveryTick( bool sim ); void SetAnimatedEveryTick( bool anim ); +#ifdef MAPBASE + // If true, this entity will notify clients when EF_NODRAW is set. + // This is mainly a band-aid for when the client paradoxically wants to know this. + virtual bool ShouldNetworkNodraw() { return false; } + void OnNodrawToggled(); +#endif + public: virtual const char *GetTracerType( void ); diff --git a/sp/src/game/server/colorcorrection.cpp b/sp/src/game/server/colorcorrection.cpp index 69e6db85805..c15698feedd 100644 --- a/sp/src/game/server/colorcorrection.cpp +++ b/sp/src/game/server/colorcorrection.cpp @@ -7,6 +7,9 @@ #include "cbase.h" #include "colorcorrection.h" +#ifdef MAPBASE +#include "beam_shared.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" @@ -38,8 +41,10 @@ BEGIN_DATADESC( CColorCorrection ) DEFINE_KEYFIELD( m_bEnabled, FIELD_BOOLEAN, "enabled" ), DEFINE_KEYFIELD( m_bStartDisabled, FIELD_BOOLEAN, "StartDisabled" ), -#ifdef MAPBASE // From Alien Swarm SDK - DEFINE_KEYFIELD( m_bExclusive, FIELD_BOOLEAN, "exclusive" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_bExclusive, FIELD_BOOLEAN, "exclusive" ), // From Alien Swarm SDK + DEFINE_KEYFIELD( m_bMaskEnabled, FIELD_BOOLEAN, "MaskEnabled" ), + DEFINE_KEYFIELD( m_bMaskInvert, FIELD_BOOLEAN, "MaskInvert" ), #endif // DEFINE_ARRAY( m_netlookupFilename, FIELD_CHARACTER, MAX_PATH ), @@ -67,10 +72,14 @@ IMPLEMENT_SERVERCLASS_ST_NOBASE(CColorCorrection, DT_ColorCorrection) #endif SendPropString( SENDINFO(m_netlookupFilename) ), SendPropBool( SENDINFO(m_bEnabled) ), -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- SendPropBool( SENDINFO(m_bMaster) ), SendPropBool( SENDINFO(m_bClientSide) ), SendPropBool( SENDINFO(m_bExclusive) ), + //--------------------------- + SendPropBool( SENDINFO(m_bMaskEnabled) ), + SendPropBool( SENDINFO(m_bMaskInvert) ), #endif END_SEND_TABLE() @@ -90,10 +99,14 @@ CColorCorrection::CColorCorrection() : BaseClass() m_flTimeStartFadeOut = 0.0f; m_netlookupFilename.GetForModify()[0] = 0; m_lookupFilename = NULL_STRING; -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- m_bMaster = false; m_bClientSide = false; m_bExclusive = false; + //--------------------------- + m_bMaskEnabled = false; + m_bMaskInvert = false; #endif } @@ -385,3 +398,159 @@ void CColorCorrectionSystem::LevelInitPostEntity( void ) } } #endif + +#ifdef MAPBASE +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +class CColorCorrectionExclude : public CPointEntity +{ + DECLARE_CLASS( CColorCorrectionExclude, CPointEntity ); +public: + CColorCorrectionExclude(); + + int UpdateTransmitState( void ) { return SetTransmitState( FL_EDICT_ALWAYS ); } + + void Spawn( void ); + + void SetExcludeTarget( CBaseEntity *pTarget ) { m_hExcludeTarget = pTarget; OnChangeExcludeTarget(); } + void SetExcludeTarget( CBaseEntity *pActivator, CBaseEntity *pCaller ) { m_hExcludeTarget = gEntList.FindEntityByName( NULL, m_target, this, pActivator, pCaller ); OnChangeExcludeTarget(); } + + void OnChangeExcludeTarget(); + + // Inputs + void InputSetTarget( inputdata_t &inputdata ) { BaseClass::InputSetTarget( inputdata ); SetExcludeTarget( inputdata.pActivator, inputdata.pCaller ); } + + void InputEnable( inputdata_t &inputdata ) { m_bExcludeDisabled = false; SetExcludeTarget( inputdata.pActivator, inputdata.pCaller ); } + void InputDisable( inputdata_t &inputdata ) { m_bExcludeDisabled = true; } + void InputToggle( inputdata_t &inputdata ) { m_bExcludeDisabled ? InputEnable( inputdata ) : InputDisable( inputdata ); } + + void InputSetExcludeColor( inputdata_t &inputdata ) { m_ExcludeColor = inputdata.value.Color32(); } + + CNetworkHandle( CBaseEntity, m_hExcludeTarget ); + CNetworkColor32( m_ExcludeColor ); + CNetworkVar( bool, m_bExcludeDisabled ); + + EHANDLE m_hOldExcludeTarget; + + DECLARE_DATADESC(); + DECLARE_SERVERCLASS(); +}; + +LINK_ENTITY_TO_CLASS( color_correction_exclude, CColorCorrectionExclude ); + + +BEGIN_DATADESC( CColorCorrectionExclude ) + + // Keys + DEFINE_KEYFIELD( m_ExcludeColor, FIELD_COLOR32, "ExcludeColor" ), + DEFINE_FIELD( m_hExcludeTarget, FIELD_EHANDLE ), + DEFINE_KEYFIELD( m_bExcludeDisabled, FIELD_BOOLEAN, "StartDisabled" ), + DEFINE_FIELD( m_hOldExcludeTarget, FIELD_EHANDLE ), + + // Inputs + DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Disable", InputDisable ), + DEFINE_INPUTFUNC( FIELD_VOID, "Toggle", InputToggle ), + DEFINE_INPUTFUNC( FIELD_COLOR32, "SetExcludeColor", InputSetExcludeColor ), + +END_DATADESC() + +IMPLEMENT_SERVERCLASS_ST( CColorCorrectionExclude, DT_ColorCorrectionExclude ) + SendPropEHandle( SENDINFO( m_hExcludeTarget ) ), + SendPropInt( SENDINFO( m_ExcludeColor ), 32, SPROP_UNSIGNED, SendProxy_Color32ToInt ), + SendPropBool( SENDINFO( m_bExcludeDisabled ) ), +END_SEND_TABLE() + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +CColorCorrectionExclude::CColorCorrectionExclude() +{ + m_ExcludeColor.Init( 255, 255, 255, 255 ); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CColorCorrectionExclude::Spawn() +{ + if ( m_target != NULL_STRING ) + { + m_hExcludeTarget = gEntList.FindEntityByName( NULL, m_target, this ); + OnChangeExcludeTarget(); + } + + BaseClass::Spawn(); +} + +//----------------------------------------------------------------------------- +// Purpose: +//----------------------------------------------------------------------------- +void CColorCorrectionExclude::OnChangeExcludeTarget() +{ + if ( m_hOldExcludeTarget != m_hExcludeTarget ) + { + if ( m_hOldExcludeTarget ) + { + // Beams need to network their nodraw state so that the client knows if they're on or not + CBeam *pBeam = dynamic_cast(m_hOldExcludeTarget.Get()); + if ( pBeam ) + { + pBeam->SetNetworkNodraw( false ); + } + } + + if ( m_hExcludeTarget ) + { + // Beams need to network their nodraw state so that the client knows if they're on or not + CBeam *pBeam = dynamic_cast(m_hExcludeTarget.Get()); + if ( pBeam ) + { + pBeam->SetNetworkNodraw( true ); + } + } + + m_hOldExcludeTarget = m_hExcludeTarget; + } +} + +//----------------------------------------------------------------------------- + +CON_COMMAND_F( colcorrect_force_exclude, "", FCVAR_CHEAT ) +{ + if ( args.ArgC() < 2 ) + return; + + CBasePlayer *pPlayer = UTIL_GetCommandClient(); + + const char *pszTarget = args.Arg( 1 ); + + color32 clrExclude; + if ( args.ArgC() >= 3 ) + { + UTIL_StringToColor32( &clrExclude, args.Arg( 2 ) ); + + if ( clrExclude.a == 0 ) + clrExclude.a = 255; + } + else + { + clrExclude.r = clrExclude.g = clrExclude.b = clrExclude.a = 255; + } + + CBaseEntity *pEnt = gEntList.FindEntityGeneric( NULL, pszTarget, pPlayer ); + for (; pEnt != NULL; pEnt = gEntList.FindEntityGeneric( pEnt, pszTarget, pPlayer ) ) + { + if ( pEnt->IsMarkedForDeletion() ) + continue; + + CColorCorrectionExclude *pExclude = (CColorCorrectionExclude*)CBaseEntity::CreateNoSpawn( "color_correction_exclude", pEnt->GetAbsOrigin(), pEnt->GetAbsAngles() ); + if ( pExclude ) + { + DispatchSpawn( pExclude ); + pExclude->SetExcludeTarget( pEnt ); + } + } +} +#endif diff --git a/sp/src/game/server/colorcorrection.h b/sp/src/game/server/colorcorrection.h index 2e96eb7c56b..18c3e41b4bd 100644 --- a/sp/src/game/server/colorcorrection.h +++ b/sp/src/game/server/colorcorrection.h @@ -96,10 +96,14 @@ class CColorCorrection : public CBaseEntity bool m_bStartDisabled; CNetworkVar( bool, m_bEnabled ); -#ifdef MAPBASE // From Alien Swarm SDK +#ifdef MAPBASE + // -- From Alien Swarm SDK -- CNetworkVar( bool, m_bMaster ); CNetworkVar( bool, m_bClientSide ); CNetworkVar( bool, m_bExclusive ); + //--------------------------- + CNetworkVar( bool, m_bMaskEnabled ); + CNetworkVar( bool, m_bMaskInvert ); #endif CNetworkVar( float, m_MinFalloff ); diff --git a/sp/src/game/server/postprocesscontroller.cpp b/sp/src/game/server/postprocesscontroller.cpp index 3e3fd6b5a13..4f34e4582dc 100644 --- a/sp/src/game/server/postprocesscontroller.cpp +++ b/sp/src/game/server/postprocesscontroller.cpp @@ -42,6 +42,9 @@ BEGIN_DATADESC( CPostProcessController ) DEFINE_KEYFIELD( m_flPostProcessParameters[ PPPN_DEPTH_BLUR_STRENGTH ], FIELD_FLOAT, "depthblurstrength" ), DEFINE_KEYFIELD( m_flPostProcessParameters[ PPPN_SCREEN_BLUR_STRENGTH ], FIELD_FLOAT, "screenblurstrength" ), DEFINE_KEYFIELD( m_flPostProcessParameters[ PPPN_FILM_GRAIN_STRENGTH ], FIELD_FLOAT, "filmgrainstrength" ), +#ifdef MAPBASE + DEFINE_KEYFIELD( m_flPostProcessParameters[ PPPN_TOP_VIGNETTE_STRENGTH ], FIELD_FLOAT, "topvignettestrength" ), +#endif // Inputs DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFadeTime", InputSetFadeTime ), @@ -55,6 +58,9 @@ BEGIN_DATADESC( CPostProcessController ) DEFINE_INPUTFUNC( FIELD_FLOAT, "SetDepthBlurStrength", InputSetDepthBlurStrength ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetScreenBlurStrength", InputSetScreenBlurStrength ), DEFINE_INPUTFUNC( FIELD_FLOAT, "SetFilmGrainStrength", InputSetFilmGrainStrength ), +#ifdef MAPBASE + DEFINE_INPUTFUNC( FIELD_FLOAT, "SetTopVignetteStrength", InputSetTopVignetteStrength ), +#endif END_DATADESC() IMPLEMENT_SERVERCLASS_ST( CPostProcessController, DT_PostProcessController ) @@ -139,6 +145,13 @@ void CPostProcessController::InputSetFilmGrainStrength( inputdata_t &inputdata ) m_flPostProcessParameters.Set( PPPN_FILM_GRAIN_STRENGTH, inputdata.value.Float() ); } +#ifdef MAPBASE +void CPostProcessController::InputSetTopVignetteStrength( inputdata_t &inputdata ) +{ + m_flPostProcessParameters.Set( PPPN_TOP_VIGNETTE_STRENGTH, inputdata.value.Float() ); +} +#endif + //----------------------------------------------------------------------------- // Purpose: Clear out the PostProcess controller. //----------------------------------------------------------------------------- diff --git a/sp/src/game/server/postprocesscontroller.h b/sp/src/game/server/postprocesscontroller.h index 5608394a639..ef76c151139 100644 --- a/sp/src/game/server/postprocesscontroller.h +++ b/sp/src/game/server/postprocesscontroller.h @@ -33,6 +33,9 @@ class CPostProcessController : public CBaseEntity void InputSetDepthBlurStrength(inputdata_t &data); void InputSetScreenBlurStrength(inputdata_t &data); void InputSetFilmGrainStrength(inputdata_t &data); +#ifdef MAPBASE + void InputSetTopVignetteStrength(inputdata_t &data); +#endif void InputTurnOn(inputdata_t &data); void InputTurnOff(inputdata_t &data); diff --git a/sp/src/game/shared/baseentity_shared.cpp b/sp/src/game/shared/baseentity_shared.cpp index 8f5660a2843..557b613f2bc 100644 --- a/sp/src/game/shared/baseentity_shared.cpp +++ b/sp/src/game/shared/baseentity_shared.cpp @@ -224,6 +224,12 @@ void CBaseEntity::SetEffects( int nEffects ) #endif // HL2_EPISODIC #endif // !CLIENT_DLL +#if defined(MAPBASE) && !defined(CLIENT_DLL) + // Nodraw was added or removed + if ( (m_fEffects ^ nEffects) & EF_NODRAW ) + OnNodrawToggled(); +#endif + m_fEffects = nEffects; #ifndef CLIENT_DLL @@ -255,6 +261,9 @@ void CBaseEntity::AddEffects( int nEffects ) { #ifndef CLIENT_DLL DispatchUpdateTransmitState(); +#ifdef MAPBASE + OnNodrawToggled(); +#endif #else UpdateVisibility(); #endif diff --git a/sp/src/game/shared/baseentity_shared.h b/sp/src/game/shared/baseentity_shared.h index 4891b0bc237..0c2af7a9823 100644 --- a/sp/src/game/shared/baseentity_shared.h +++ b/sp/src/game/shared/baseentity_shared.h @@ -216,6 +216,9 @@ inline void CBaseEntity::RemoveEffects( int nEffects ) #ifndef CLIENT_DLL NetworkProp()->MarkPVSInformationDirty(); DispatchUpdateTransmitState(); +#ifdef MAPBASE + OnNodrawToggled(); +#endif #else UpdateVisibility(); #endif diff --git a/sp/src/game/shared/beam_shared.cpp b/sp/src/game/shared/beam_shared.cpp index fcefa3f9652..31d0b8da9a4 100644 --- a/sp/src/game/shared/beam_shared.cpp +++ b/sp/src/game/shared/beam_shared.cpp @@ -278,6 +278,10 @@ BEGIN_DATADESC( CBeam ) DEFINE_KEYFIELD( m_nDissolveType, FIELD_INTEGER, "dissolvetype" ), +#ifdef MAPBASE + DEFINE_FIELD( m_bNetworkNodraw, FIELD_BOOLEAN ), +#endif + #ifdef PORTAL DEFINE_FIELD( m_bDrawInMainRender, FIELD_BOOLEAN ), DEFINE_FIELD( m_bDrawInPortalRender, FIELD_BOOLEAN ), @@ -918,6 +922,16 @@ int CBeam::ShouldTransmit( const CCheckTransmitInfo *pInfo ) return BaseClass::ShouldTransmit( pInfo ); } +#ifdef MAPBASE +bool CBeam::ShouldNetworkNodraw() +{ + if ( m_bNetworkNodraw ) + return true; + + return BaseClass::ShouldNetworkNodraw(); +} +#endif + #endif //----------------------------------------------------------------------------- diff --git a/sp/src/game/shared/beam_shared.h b/sp/src/game/shared/beam_shared.h index b9e2b905454..e2f1af392b7 100644 --- a/sp/src/game/shared/beam_shared.h +++ b/sp/src/game/shared/beam_shared.h @@ -64,6 +64,10 @@ class CBeam : public CBaseEntity void SetTransmit( CCheckTransmitInfo *pInfo, bool bAlways ); int UpdateTransmitState( void ); int ShouldTransmit( const CCheckTransmitInfo *pInfo ); +#ifdef MAPBASE + bool ShouldNetworkNodraw(); + void SetNetworkNodraw( bool bToggle ) { m_bNetworkNodraw = bToggle; } +#endif #endif virtual int DrawDebugTextOverlays(void); @@ -235,6 +239,10 @@ class CBeam : public CBaseEntity #if !defined( CLIENT_DLL ) int m_nDissolveType; + +#ifdef MAPBASE + bool m_bNetworkNodraw; +#endif #endif public: diff --git a/sp/src/game/shared/mapbase/mapbase_shared.cpp b/sp/src/game/shared/mapbase/mapbase_shared.cpp index 2345d9cab85..72ac323b695 100644 --- a/sp/src/game/shared/mapbase/mapbase_shared.cpp +++ b/sp/src/game/shared/mapbase/mapbase_shared.cpp @@ -207,10 +207,6 @@ class CMapbaseSystem : public CAutoGameSystem } gameinfo->deleteThis(); -#ifdef CLIENT_DLL - InitializeRTs(); -#endif - return true; } @@ -371,58 +367,6 @@ class CMapbaseSystem : public CAutoGameSystem return false; } -#ifdef CLIENT_DLL - //----------------------------------------------------------------------------- - // Initialize custom RT textures if necessary - //----------------------------------------------------------------------------- - void InitializeRTs() - { - if (!m_bInitializedRTs) - { - int iNumCameras = CommandLine()->ParmValue( "-numcameratextures", 3 ); - - materials->BeginRenderTargetAllocation(); - - for (int i = 0; i < iNumCameras; i++) - { - char szName[32]; - Q_snprintf( szName, sizeof(szName), "_rt_Camera%i", i ); - - int iRefIndex = m_CameraTextures.AddToTail(); - - //m_CameraTextures[iRefIndex].InitRenderTarget( - // 256, 256, RT_SIZE_DEFAULT, - // g_pMaterialSystem->GetBackBufferFormat(), - // MATERIAL_RT_DEPTH_SHARED, true, szName ); - - m_CameraTextures[iRefIndex].Init( g_pMaterialSystem->CreateNamedRenderTargetTextureEx2( - szName, - 256, 256, RT_SIZE_DEFAULT, - g_pMaterialSystem->GetBackBufferFormat(), - MATERIAL_RT_DEPTH_SHARED, - 0, - CREATERENDERTARGETFLAGS_HDR ) ); - } - - materials->EndRenderTargetAllocation(); - - m_bInitializedRTs = true; - } - } - - void Shutdown() - { - if (m_bInitializedRTs) - { - for (int i = 0; i < m_CameraTextures.Count(); i++) - { - m_CameraTextures[i].Shutdown(); - } - m_bInitializedRTs = false; - } - } -#endif - // Get a generic, hardcoded manifest with hardcoded names. void ParseGenericManifest() { @@ -652,9 +596,6 @@ class CMapbaseSystem : public CAutoGameSystem private: #ifdef CLIENT_DLL - bool m_bInitializedRTs = false; - CUtlVector m_CameraTextures; - CUtlVector m_CloseCaptionFileNames; #endif }; diff --git a/sp/src/game/shared/mapbase/mapbase_usermessages.cpp b/sp/src/game/shared/mapbase/mapbase_usermessages.cpp index f0a71fd410a..5268aafb6f4 100644 --- a/sp/src/game/shared/mapbase/mapbase_usermessages.cpp +++ b/sp/src/game/shared/mapbase/mapbase_usermessages.cpp @@ -22,6 +22,8 @@ void HookMapbaseUserMessages( void ) //HOOK_MESSAGE( ScriptMsg ); // Hooked in CNetMsgScriptHelper //HOOK_MESSAGE( ShowMenuComplex ); // Hooked in CHudMenu + + //HOOK_MESSAGE( NodrawToggle ); // Hooked in ClientModeShared } #endif @@ -31,6 +33,8 @@ void RegisterMapbaseUserMessages( void ) usermessages->Register( "ScriptMsg", -1 ); // CNetMsgScriptHelper usermessages->Register( "ShowMenuComplex", -1 ); // CHudMenu + + usermessages->Register( "NodrawToggle", 3 ); // ClientModeShared #ifdef CLIENT_DLL // TODO: Better placement? diff --git a/sp/src/game/shared/postprocess_shared.h b/sp/src/game/shared/postprocess_shared.h index 9d3c7df003d..77f88efc2a6 100644 --- a/sp/src/game/shared/postprocess_shared.h +++ b/sp/src/game/shared/postprocess_shared.h @@ -24,6 +24,9 @@ enum PostProcessParameterNames_t PPPN_DEPTH_BLUR_STRENGTH, PPPN_SCREEN_BLUR_STRENGTH, PPPN_FILM_GRAIN_STRENGTH, +#ifdef MAPBASE + PPPN_TOP_VIGNETTE_STRENGTH, +#endif POST_PROCESS_PARAMETER_COUNT }; diff --git a/sp/src/materialsystem/stdshaders/SDK_engine_post_ps20b.fxc b/sp/src/materialsystem/stdshaders/SDK_engine_post_ps20b.fxc index e7d53ba0931..6e6d8fd3dac 100644 --- a/sp/src/materialsystem/stdshaders/SDK_engine_post_ps20b.fxc +++ b/sp/src/materialsystem/stdshaders/SDK_engine_post_ps20b.fxc @@ -10,6 +10,7 @@ // DYNAMIC: "AA_ENABLE" "0..1" [XBOX] // DYNAMIC: "COL_CORRECT_NUM_LOOKUPS" "0..3" +// DYNAMIC: "COL_CORRECT_USE_MASK" "0..1" // DYNAMIC: "CONVERT_FROM_LINEAR" "0..1" [ps20b] [ps30] [PC] // DYNAMIC: "CONVERT_TO_LINEAR" "0..1" [ps20b] [ps30] [PC] @@ -29,6 +30,7 @@ // DYNAMIC: "DESATURATEENABLE" "0..1" [ps20b] [PC] // SKIP: ( $TOOL_MODE == 0 ) && $TV_GAMMA // SKIP: ( $TOOL_MODE == 0 ) && $DESATURATEENABLE +// SKIP: ( $COL_CORRECT_NUM_LOOKUPS == 0 ) && $COL_CORRECT_USE_MASK #include "common_ps_fxc.h" @@ -41,6 +43,7 @@ sampler ColorCorrectionVolumeTexture3 : register( s5 ); sampler NoiseSampler : register( s6 ); sampler VignetteSampler : register( s7 ); sampler ScreenEffectSampler : register( s8 ); // used for vomit/paint screen particle effects +sampler ColorCorrectionMask : register( s9 ); float4 psTapOffs_Packed : register( c0 ); // psTapOffs_packed contains 1-pixel offsets: ( +dX, 0, +dY, -dX ) float4 tweakables : register( c1 ); // (x - AA strength/unused) (y - reduction of 1-pixel-line blur) @@ -72,6 +75,7 @@ float4 g_vLocalContrastVignetteParams : register( c9 ); #define g_flLocalContrastVignetteStart g_vLocalContrastVignetteParams.x #define g_flLocalContrastVignetteEnd g_vLocalContrastVignetteParams.y #define g_flLocalContrastEdgeStrength g_vLocalContrastVignetteParams.z +#define g_flVignetteStrength g_vLocalContrastVignetteParams.w float g_flFadeToBlackStrength : register( c10 ); @@ -87,6 +91,9 @@ float2 g_c16 : register( c16 ); #define g_flDesaturation g_c16.x #define g_flFadeMode2 g_c16.y +float4 g_vColCorrectExcludeMask : register( c17 ); +float g_vColCorrectExcludeExponent : register( c18 ); + float Luminance( float3 cColor ) { float3 tmpv = { 0.2125, 0.7154, 0.0721 }; @@ -99,7 +106,7 @@ float4 GetBloomColor( float2 bloomUV ) return tex2D( BaseTextureSampler, bloomUV ); } -float4 PerformColorCorrection( float4 outColor ) +float4 PerformColorCorrection( float4 outColor, float2 baseCoords ) { if (COL_CORRECT_NUM_LOOKUPS > 0) { @@ -108,17 +115,63 @@ float4 PerformColorCorrection( float4 outColor ) // and (1,1,1) to be read from 31.5f/32 float4 offsetOutColor = outColor*(31.0f/32.0f) + (0.5f/32.0f); + float4 addColor = 0; +#if ( COL_CORRECT_USE_MASK == 1 ) + float4 offsetOutColorLast = offsetOutColor; + float3 addWeight = pow( tex2D( ColorCorrectionMask, baseCoords ).rgb, g_vColCorrectExcludeExponent ); +#endif + outColor.rgb = outColor.rgb * ColorCorrectionDefaultWeight; - outColor.rgb += tex3D( ColorCorrectionVolumeTexture0, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.x; + + // Lookup 0 + addColor.rgb = tex3D( ColorCorrectionVolumeTexture0, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.x; +#if ( COL_CORRECT_USE_MASK == 1 ) + if (g_vColCorrectExcludeMask.x == 1.0) + addColor.rgb = lerp( addColor.rgb, offsetOutColor.rgb * ColorCorrectionVolumeWeights.x, addWeight.rgb ); + else if (g_vColCorrectExcludeMask.x == -1.0) + addColor.rgb = lerp( offsetOutColor.rgb * ColorCorrectionVolumeWeights.x, addColor.rgb, addWeight.rgb ); + offsetOutColorLast.rgb = addColor.rgb; +#endif + outColor.rgb += addColor.rgb; + if (COL_CORRECT_NUM_LOOKUPS > 1) { - outColor.rgb += tex3D( ColorCorrectionVolumeTexture1, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.y; + // Lookup 1 + addColor.rgb = tex3D( ColorCorrectionVolumeTexture1, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.y; +#if ( COL_CORRECT_USE_MASK == 1 ) + if (g_vColCorrectExcludeMask.y == 1.0) + addColor.rgb = lerp( addColor.rgb, offsetOutColor.rgb * ColorCorrectionVolumeWeights.y, addWeight.rgb ); + else if (g_vColCorrectExcludeMask.y == -1.0) + addColor.rgb = lerp( offsetOutColor.rgb * ColorCorrectionVolumeWeights.y, addColor.rgb, addWeight.rgb ); + offsetOutColorLast.rgb = addColor.rgb; +#endif + outColor.rgb += addColor.rgb; + if (COL_CORRECT_NUM_LOOKUPS > 2) { - outColor.rgb += tex3D( ColorCorrectionVolumeTexture2, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.z; + // Lookup 2 + addColor.rgb = tex3D( ColorCorrectionVolumeTexture2, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.z; +#if ( COL_CORRECT_USE_MASK == 1 ) + if (g_vColCorrectExcludeMask.z == 1.0) + addColor.rgb = lerp( addColor.rgb, offsetOutColor.rgb * ColorCorrectionVolumeWeights.z, addWeight.rgb ); + else if (g_vColCorrectExcludeMask.z == -1.0) + addColor.rgb = lerp( offsetOutColor.rgb * ColorCorrectionVolumeWeights.z, addColor.rgb, addWeight.rgb ); + offsetOutColorLast.rgb = addColor.rgb; +#endif + outColor.rgb += addColor.rgb; + if (COL_CORRECT_NUM_LOOKUPS > 3) { - outColor.rgb += tex3D( ColorCorrectionVolumeTexture3, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.w; + // Lookup 3 + addColor.rgb = tex3D( ColorCorrectionVolumeTexture3, offsetOutColor.rgb ) * ColorCorrectionVolumeWeights.w; +#if ( COL_CORRECT_USE_MASK == 1 ) + if (g_vColCorrectExcludeMask.w == 1.0) + addColor.rgb = lerp( addColor.rgb, offsetOutColor.rgb * ColorCorrectionVolumeWeights.w, addWeight.rgb ); + else if (g_vColCorrectExcludeMask.w == -1.0) + addColor.rgb = lerp( offsetOutColor.rgb * ColorCorrectionVolumeWeights.w, addColor.rgb, addWeight.rgb ); + offsetOutColorLast.rgb = addColor.rgb; +#endif + outColor.rgb += addColor.rgb; } } } @@ -330,7 +383,7 @@ float4 main( PS_INPUT i ) : COLOR } #else { - outColor = PerformColorCorrection( outColor ); // Color correction + outColor = PerformColorCorrection( outColor, fbTexCoord.xy ); // Color correction } #endif @@ -349,6 +402,8 @@ float4 main( PS_INPUT i ) : COLOR // This tex2D solves the 3 lines of math above flVignette = tex2D( VignetteSampler, vUv.xy ).r; // Red is for the PC flVignette = saturate( flVignette * 0.55 + 0.46 ); + + flVignette = lerp( 1.0, flVignette, g_flVignetteStrength ); outColor.rgb *= flVignette; } diff --git a/sp/src/materialsystem/stdshaders/engine_post_dx9.cpp b/sp/src/materialsystem/stdshaders/engine_post_dx9.cpp index 1c3cdc2b90d..4ec6a1cc862 100644 --- a/sp/src/materialsystem/stdshaders/engine_post_dx9.cpp +++ b/sp/src/materialsystem/stdshaders/engine_post_dx9.cpp @@ -83,6 +83,16 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof SHADER_PARAM( WEIGHT3, SHADER_PARAM_TYPE_FLOAT, "1", "weight3" ) SHADER_PARAM( NUM_LOOKUPS, SHADER_PARAM_TYPE_FLOAT, "0", "num_lookups" ) SHADER_PARAM( TOOLTIME, SHADER_PARAM_TYPE_FLOAT, "0", "tooltime" ) + +#ifdef MAPBASE + // Color correction mask + SHADER_PARAM( COLORCORRECTIONMASK, SHADER_PARAM_TYPE_TEXTURE, "_rt_ColCorrectMask", "" ) + SHADER_PARAM( COLCORRECT_EXCLUDEMASK, SHADER_PARAM_TYPE_INTEGER, "0", "" ) + SHADER_PARAM( COLCORRECT_EXCLUDEEXPONENT, SHADER_PARAM_TYPE_FLOAT, "1.0", "" ) + + // Vignette strength + SHADER_PARAM( VIGNETTESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "1", "" ) +#endif END_SHADER_PARAMS SHADER_INIT_PARAMS() @@ -235,6 +245,12 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof { params[ DESATURATION ]->SetFloatValue( 0.0f ); } +#ifdef MAPBASE + if ( !params[ VIGNETTESTRENGTH ]->IsDefined() ) + { + params[ VIGNETTESTRENGTH ]->SetFloatValue( 1.0f ); + } +#endif SET_FLAGS2( MATERIAL_VAR2_NEEDS_FULL_FRAME_BUFFER_TEXTURE ); } @@ -271,6 +287,13 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof { LoadTexture( INTERNAL_VIGNETTETEXTURE ); } + +#ifdef MAPBASE + if ( params[COLORCORRECTIONMASK]->IsDefined() ) + { + LoadTexture( COLORCORRECTIONMASK ); + } +#endif } SHADER_DRAW @@ -324,6 +347,12 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof pShaderShadow->EnableTexture( SHADER_SAMPLER8, true ); pShaderShadow->EnableSRGBRead( SHADER_SAMPLER8, false ); +#ifdef MAPBASE + // Color correction mask + pShaderShadow->EnableTexture( SHADER_SAMPLER9, true ); + pShaderShadow->EnableSRGBRead( SHADER_SAMPLER9, false ); +#endif + pShaderShadow->EnableSRGBWrite( false ); int format = VERTEX_POSITION; @@ -405,6 +434,43 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof pShaderAPI->BindStandardTexture( (Sampler_t)(SHADER_SAMPLER2 + i), (StandardTextureId_t)(TEXTURE_COLOR_CORRECTION_VOLUME_0 + i) ); } +#ifdef MAPBASE + // TODO: Better terminology. Color correction mask is an alpha channel for the color correction, + // but "exclude mask" refers to the bit mask that controls its behavior + bool bUsingCCMask = false; + if ( ccInfo.m_bIsEnabled ) + { + int nExcludeMask = params[COLCORRECT_EXCLUDEMASK]->GetIntValue(); + if ( nExcludeMask != 0 ) + { + bUsingCCMask = true; + BindTexture( SHADER_SAMPLER9, COLORCORRECTIONMASK ); + + float vCCExcludeMask[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + + // One "flag" for each of the 4 weights + // 0 = don't use mask, 1 = use mask, -1 = inverted mask + for ( int i = 0; i < 4; i++ ) + { + if ( nExcludeMask & (1 << i) ) + { + if ( nExcludeMask & (1 << (16 + i)) ) + vCCExcludeMask[i] = -1.0f; + else + vCCExcludeMask[i] = 1.0f; + } + } + + pShaderAPI->SetPixelShaderConstant( 17, &vCCExcludeMask[0], 4 ); + + // Assign other params + float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; + vPsConst[0] = params[COLCORRECT_EXCLUDEEXPONENT]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 18, vPsConst, 1 ); + } + } +#endif + // Upload 1-pixel X&Y offsets [ (+dX,0,+dY,-dX) is chosen to work with the allowed ps20 swizzles ] // The shader will sample in a cross (up/down/left/right from the current sample), for 5-tap // (quality 0) mode and add another 4 samples in a diagonal cross, for 9-tap (quality 1) mode @@ -547,12 +613,16 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof { vPsConst[2] = mat_local_contrast_edge_scale_override.GetFloat(); } +#ifdef MAPBASE + vPsConst[3] = params[ VIGNETTESTRENGTH ]->GetFloatValue(); +#endif pShaderAPI->SetPixelShaderConstant( 9, vPsConst, 1 ); } // fade to black float vPsConst[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; vPsConst[0] = params[ FADETOBLACKSCALE ]->GetFloatValue(); + pShaderAPI->SetPixelShaderConstant( 10, vPsConst, 1 ); bool bVomitEnable = ( params[ VOMITENABLE ]->GetIntValue() != 0 ); @@ -617,6 +687,7 @@ BEGIN_VS_SHADER_FLAGS( SDK_Engine_Post_dx9, "Engine post-processing effects (sof DECLARE_DYNAMIC_PIXEL_SHADER( sdk_engine_post_ps20b ); SET_DYNAMIC_PIXEL_SHADER_COMBO( AA_ENABLE, aaEnabled ); SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_NUM_LOOKUPS, colCorrectNumLookups ); + SET_DYNAMIC_PIXEL_SHADER_COMBO( COL_CORRECT_USE_MASK, bUsingCCMask ); SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_FROM_LINEAR, bConvertFromLinear ); SET_DYNAMIC_PIXEL_SHADER_COMBO( CONVERT_TO_LINEAR, bConvertToLinear ); SET_DYNAMIC_PIXEL_SHADER_COMBO( NOISE_ENABLE, bNoiseEnable ); diff --git a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_engine_post_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_engine_post_ps20b.inc index 8d65f79af57..1ebbcab8608 100644 --- a/sp/src/materialsystem/stdshaders/fxctmp9/SDK_engine_post_ps20b.inc +++ b/sp/src/materialsystem/stdshaders/fxctmp9/SDK_engine_post_ps20b.inc @@ -63,7 +63,7 @@ public: bool bAllStaticVarsDefined = m_bTOOL_MODE && m_bDEPTH_BLUR_ENABLE; Assert( bAllStaticVarsDefined ); #endif // _DEBUG - return ( 2048 * m_nTOOL_MODE ) + ( 4096 * m_nDEPTH_BLUR_ENABLE ) + 0; + return ( 4096 * m_nTOOL_MODE ) + ( 8192 * m_nDEPTH_BLUR_ENABLE ) + 0; } }; #define shaderStaticTest_sdk_engine_post_ps20b psh_forgot_to_set_static_TOOL_MODE + psh_forgot_to_set_static_DEPTH_BLUR_ENABLE + 0 @@ -111,6 +111,27 @@ public: m_bCOL_CORRECT_NUM_LOOKUPS = true; #endif } +private: + int m_nCOL_CORRECT_USE_MASK; +#ifdef _DEBUG + bool m_bCOL_CORRECT_USE_MASK; +#endif +public: + void SetCOL_CORRECT_USE_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOL_CORRECT_USE_MASK = i; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = true; +#endif + } + void SetCOL_CORRECT_USE_MASK( bool i ) + { + m_nCOL_CORRECT_USE_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = true; +#endif + } private: int m_nCONVERT_FROM_LINEAR; #ifdef _DEBUG @@ -311,6 +332,10 @@ public: m_bCOL_CORRECT_NUM_LOOKUPS = false; #endif // _DEBUG m_nCOL_CORRECT_NUM_LOOKUPS = 0; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = false; +#endif // _DEBUG + m_nCOL_CORRECT_USE_MASK = 0; #ifdef _DEBUG m_bCONVERT_FROM_LINEAR = false; #endif // _DEBUG @@ -353,10 +378,10 @@ public: // Asserts to make sure that we aren't using any skipped combinations. // Asserts to make sure that we are setting all of the combination vars. #ifdef _DEBUG - bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE; + bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCOL_CORRECT_USE_MASK && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE; Assert( bAllDynamicVarsDefined ); #endif // _DEBUG - return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCONVERT_FROM_LINEAR ) + ( 8 * m_nCONVERT_TO_LINEAR ) + ( 16 * m_nNOISE_ENABLE ) + ( 32 * m_nVIGNETTE_ENABLE ) + ( 64 * m_nLOCAL_CONTRAST_ENABLE ) + ( 128 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 256 * m_nVOMIT_ENABLE ) + ( 512 * m_nTV_GAMMA ) + ( 1024 * m_nDESATURATEENABLE ) + 0; + return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCOL_CORRECT_USE_MASK ) + ( 8 * m_nCONVERT_FROM_LINEAR ) + ( 16 * m_nCONVERT_TO_LINEAR ) + ( 32 * m_nNOISE_ENABLE ) + ( 64 * m_nVIGNETTE_ENABLE ) + ( 128 * m_nLOCAL_CONTRAST_ENABLE ) + ( 256 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 512 * m_nVOMIT_ENABLE ) + ( 1024 * m_nTV_GAMMA ) + ( 2048 * m_nDESATURATEENABLE ) + 0; } }; -#define shaderDynamicTest_sdk_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0 +#define shaderDynamicTest_sdk_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_COL_CORRECT_USE_MASK + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0 diff --git a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_engine_post_ps20b.inc b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_engine_post_ps20b.inc index 8d65f79af57..1ebbcab8608 100644 --- a/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_engine_post_ps20b.inc +++ b/sp/src/materialsystem/stdshaders/fxctmp9_tmp/SDK_engine_post_ps20b.inc @@ -63,7 +63,7 @@ public: bool bAllStaticVarsDefined = m_bTOOL_MODE && m_bDEPTH_BLUR_ENABLE; Assert( bAllStaticVarsDefined ); #endif // _DEBUG - return ( 2048 * m_nTOOL_MODE ) + ( 4096 * m_nDEPTH_BLUR_ENABLE ) + 0; + return ( 4096 * m_nTOOL_MODE ) + ( 8192 * m_nDEPTH_BLUR_ENABLE ) + 0; } }; #define shaderStaticTest_sdk_engine_post_ps20b psh_forgot_to_set_static_TOOL_MODE + psh_forgot_to_set_static_DEPTH_BLUR_ENABLE + 0 @@ -111,6 +111,27 @@ public: m_bCOL_CORRECT_NUM_LOOKUPS = true; #endif } +private: + int m_nCOL_CORRECT_USE_MASK; +#ifdef _DEBUG + bool m_bCOL_CORRECT_USE_MASK; +#endif +public: + void SetCOL_CORRECT_USE_MASK( int i ) + { + Assert( i >= 0 && i <= 1 ); + m_nCOL_CORRECT_USE_MASK = i; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = true; +#endif + } + void SetCOL_CORRECT_USE_MASK( bool i ) + { + m_nCOL_CORRECT_USE_MASK = i ? 1 : 0; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = true; +#endif + } private: int m_nCONVERT_FROM_LINEAR; #ifdef _DEBUG @@ -311,6 +332,10 @@ public: m_bCOL_CORRECT_NUM_LOOKUPS = false; #endif // _DEBUG m_nCOL_CORRECT_NUM_LOOKUPS = 0; +#ifdef _DEBUG + m_bCOL_CORRECT_USE_MASK = false; +#endif // _DEBUG + m_nCOL_CORRECT_USE_MASK = 0; #ifdef _DEBUG m_bCONVERT_FROM_LINEAR = false; #endif // _DEBUG @@ -353,10 +378,10 @@ public: // Asserts to make sure that we aren't using any skipped combinations. // Asserts to make sure that we are setting all of the combination vars. #ifdef _DEBUG - bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE; + bool bAllDynamicVarsDefined = m_bAA_ENABLE && m_bCOL_CORRECT_NUM_LOOKUPS && m_bCOL_CORRECT_USE_MASK && m_bCONVERT_FROM_LINEAR && m_bCONVERT_TO_LINEAR && m_bNOISE_ENABLE && m_bVIGNETTE_ENABLE && m_bLOCAL_CONTRAST_ENABLE && m_bBLURRED_VIGNETTE_ENABLE && m_bVOMIT_ENABLE && m_bTV_GAMMA && m_bDESATURATEENABLE; Assert( bAllDynamicVarsDefined ); #endif // _DEBUG - return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCONVERT_FROM_LINEAR ) + ( 8 * m_nCONVERT_TO_LINEAR ) + ( 16 * m_nNOISE_ENABLE ) + ( 32 * m_nVIGNETTE_ENABLE ) + ( 64 * m_nLOCAL_CONTRAST_ENABLE ) + ( 128 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 256 * m_nVOMIT_ENABLE ) + ( 512 * m_nTV_GAMMA ) + ( 1024 * m_nDESATURATEENABLE ) + 0; + return ( 1 * m_nAA_ENABLE ) + ( 1 * m_nCOL_CORRECT_NUM_LOOKUPS ) + ( 4 * m_nCOL_CORRECT_USE_MASK ) + ( 8 * m_nCONVERT_FROM_LINEAR ) + ( 16 * m_nCONVERT_TO_LINEAR ) + ( 32 * m_nNOISE_ENABLE ) + ( 64 * m_nVIGNETTE_ENABLE ) + ( 128 * m_nLOCAL_CONTRAST_ENABLE ) + ( 256 * m_nBLURRED_VIGNETTE_ENABLE ) + ( 512 * m_nVOMIT_ENABLE ) + ( 1024 * m_nTV_GAMMA ) + ( 2048 * m_nDESATURATEENABLE ) + 0; } }; -#define shaderDynamicTest_sdk_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0 +#define shaderDynamicTest_sdk_engine_post_ps20b psh_forgot_to_set_dynamic_AA_ENABLE + psh_forgot_to_set_dynamic_COL_CORRECT_NUM_LOOKUPS + psh_forgot_to_set_dynamic_COL_CORRECT_USE_MASK + psh_forgot_to_set_dynamic_CONVERT_FROM_LINEAR + psh_forgot_to_set_dynamic_CONVERT_TO_LINEAR + psh_forgot_to_set_dynamic_NOISE_ENABLE + psh_forgot_to_set_dynamic_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_LOCAL_CONTRAST_ENABLE + psh_forgot_to_set_dynamic_BLURRED_VIGNETTE_ENABLE + psh_forgot_to_set_dynamic_VOMIT_ENABLE + psh_forgot_to_set_dynamic_TV_GAMMA + psh_forgot_to_set_dynamic_DESATURATEENABLE + 0