Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion sp/src/game/client/baseclientrendertargets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

//-----------------------------------------------------------------------------
Expand All @@ -75,4 +114,14 @@ void CBaseClientRenderTargets::ShutdownClientRenderTargets()

// Monitors
m_CameraTexture.Shutdown();
}

#ifdef MAPBASE
for ( int i = 0; i < m_CameraTextures.Count(); i++ )
{
m_CameraTextures[i].Shutdown();
}

// Miscellaneous
m_ColCorrectMaskTexture.Shutdown();
#endif
}
9 changes: 9 additions & 0 deletions sp/src/game/client/baseclientrendertargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<CTextureReference> 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_
2 changes: 2 additions & 0 deletions sp/src/game/client/c_baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
103 changes: 96 additions & 7 deletions sp/src/game/client/c_colorcorrection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand All @@ -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 )
Expand Down Expand Up @@ -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 )
Expand Down Expand Up @@ -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;
}
Comment on lines +357 to +363

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I imagine 0 test branching is not faster than 4 float divisions which can be vectorised by the compiler.


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



Expand Down
7 changes: 6 additions & 1 deletion sp/src/game/client/c_colorcorrection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions sp/src/game/client/client_mapbase.vpc
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
Expand Down
31 changes: 31 additions & 0 deletions sp/src/game/client/clientmode_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -387,6 +403,9 @@ void ClientModeShared::Init()

HOOK_MESSAGE( VGUIMenu );
HOOK_MESSAGE( Rumble );
#ifdef MAPBASE
HOOK_MESSAGE( NodrawToggle );
#endif
}


Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions sp/src/game/client/clientmode_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
Loading