Skip to content

Commit

Permalink
neo_bloom_controller (#827)
Browse files Browse the repository at this point in the history
* add neo_bloom_controller

* magic number

* int?

* keyvalue input correction

---------

Co-authored-by: brysondev <[email protected]>
Co-authored-by: DESTROYGIRL <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent 0ce4a35 commit f67dac7
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 0 deletions.
1 change: 1 addition & 0 deletions mp/src/game/client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1488,6 +1488,7 @@ target_sources_grouped(
neo/c_neo_te_tocflash.h
neo/neo_fixup_glshaders.cpp
neo/neo_fixup_glshaders.h
neo/c_neo_bloom_controller.cpp
)

target_sources_grouped(
Expand Down
67 changes: 67 additions & 0 deletions mp/src/game/client/neo/c_neo_bloom_controller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Neo Bloom Controller
//
// $NoKeywords: $
//===========================================================================//
#include "cbase.h"

extern bool g_bUseCustomBloomScale;
extern float g_flCustomBloomScale;
extern EHANDLE g_hTonemapControllerInUse;

EHANDLE g_hNeoBloomControllerInUse = NULL;

//-----------------------------------------------------------------------------
// Purpose: neo_bloom_controller entity for mapmakers to control bloom amount in maps
//-----------------------------------------------------------------------------
class C_NeoBloomController : public C_BaseEntity
{
DECLARE_CLASS(C_NeoBloomController, C_BaseEntity);
public:
DECLARE_CLIENTCLASS();

C_NeoBloomController();
~C_NeoBloomController();
virtual void OnDataChanged(DataUpdateType_t updateType);
private:
float m_flBloomAmountSetting;
};

IMPLEMENT_CLIENTCLASS_DT(C_NeoBloomController, DT_NeoBloomController, CNeoBloomController)
RecvPropFloat(RECVINFO(m_flBloomAmountSetting)),
END_RECV_TABLE()

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_NeoBloomController::C_NeoBloomController(void)
{
m_flBloomAmountSetting = 1.0f;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
C_NeoBloomController::~C_NeoBloomController(void)
{
if (g_hNeoBloomControllerInUse == this && g_hTonemapControllerInUse == NULL)
{
g_flCustomBloomScale = 1.0f; // Whatever the default bloom amount value is here
g_bUseCustomBloomScale = false;
}
}

void C_NeoBloomController::OnDataChanged(DataUpdateType_t updateType)
{
BaseClass::OnDataChanged(updateType);

if (g_hTonemapControllerInUse != NULL)
{
return;
}

g_flCustomBloomScale = m_flBloomAmountSetting;
g_bUseCustomBloomScale = true;
g_hNeoBloomControllerInUse = this;
}
14 changes: 14 additions & 0 deletions mp/src/game/client/viewpostprocess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,7 @@ float CLuminanceHistogramSystem::GetTargetTonemapScalar( bool bGetIdealTargetFor
}
}

extern EHANDLE g_hTonemapControllerInUse;
static float GetCurrentBloomScale( void )
{
// Use the appropriate bloom scale settings. Mapmakers's overrides the convar settings.
Expand All @@ -786,6 +787,13 @@ static float GetCurrentBloomScale( void )
{
flCurrentBloomScale = mat_bloomscale.GetFloat();
}
#ifdef NEO
if (!g_pMaterialSystemHardwareConfig->GetHDREnabled())
{
constexpr int BLOOM_MULTIPLIER = 4;
flCurrentBloomScale *= BLOOM_MULTIPLIER; // NEOTOD (Adam) the base values defined in neo_bloom_controller in old maps seem way too small, need to figure out what the right multiplier is for this. 4 seems to be in the right ballpark. The translation from non-hdr to hdr is 0.3 -> 1.0 according to valve developer community, a multiplier of 3.333 could be the right value
}
#endif // NEO
return flCurrentBloomScale;
}

Expand Down Expand Up @@ -1444,6 +1452,12 @@ static float GetBloomAmount( void )

if ( !engine->MapHasHDRLighting() )
bBloomEnabled = false;
#ifdef NEO
if ( g_bUseCustomBloomScale )
{
bBloomEnabled = true;
}
#endif // NEO
if ( mat_force_bloom.GetInt() )
bBloomEnabled = true;
if ( mat_disable_bloom.GetInt() )
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,7 @@ target_sources_grouped(
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_version_info.h
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.cpp
${CMAKE_SOURCE_DIR}/game/shared/neo/neo_misc.h
neo/neo_bloom_controller.cpp
neo/neo_client.cpp
neo/neo_detpack.cpp
neo/neo_detpack.h
Expand Down
69 changes: 69 additions & 0 deletions mp/src/game/server/neo/neo_bloom_controller.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================

#include "cbase.h"
#include "baseentity.h"
#include "entityoutput.h"
#include "convar.h"
// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

//-----------------------------------------------------------------------------
// Purpose: Entity that controls player's tonemap
//-----------------------------------------------------------------------------
class CNeoBloomController : public CPointEntity
{
DECLARE_CLASS( CNeoBloomController, CPointEntity );
public:
DECLARE_DATADESC();
DECLARE_SERVERCLASS();

void Spawn( void );
int UpdateTransmitState( void );

// Inputs
void InputSetBloomScale( inputdata_t &inputdata );

private:
CNetworkVar( float, m_flBloomAmountSetting);
};

LINK_ENTITY_TO_CLASS( neo_bloom_controller, CNeoBloomController );

BEGIN_DATADESC( CNeoBloomController )
DEFINE_KEYFIELD( m_flBloomAmountSetting, FIELD_FLOAT, "bloomamount" ),
DEFINE_INPUTFUNC( FIELD_FLOAT, "SetBloomScale", InputSetBloomScale ),
END_DATADESC()


IMPLEMENT_SERVERCLASS_ST( CNeoBloomController, DT_NeoBloomController )
SendPropFloat( SENDINFO(m_flBloomAmountSetting), 0, SPROP_NOSCALE),
END_SEND_TABLE()

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNeoBloomController::Spawn( void )
{
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NONE );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
int CNeoBloomController::UpdateTransmitState()
{
return SetTransmitState( FL_EDICT_ALWAYS );
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CNeoBloomController::InputSetBloomScale( inputdata_t &inputdata )
{
m_flBloomAmountSetting = inputdata.value.Float();
}

0 comments on commit f67dac7

Please sign in to comment.