Skip to content

Color correction exclusion mask + top vignette in postprocess_controller - #494

Open
Blixibon wants to merge 4 commits into
mapbase-source:developfrom
Blixibon:mapbase/feature/cc-exclusion-mask-and-vignette
Open

Blixibon wants to merge 4 commits into
mapbase-source:developfrom
Blixibon:mapbase/feature/cc-exclusion-mask-and-vignette

Conversation

@Blixibon

@Blixibon Blixibon commented Feb 18, 2026 •

Copy link
Copy Markdown
Member

This PR adds the ability to selectively exclude certain entities from color correction (or make them exclusively affected by color correction) through a new entity called color_correction_exclude. This is done by writing those entities to the stencil buffer (similar to glow outlines), pushing that to a new RT texture called _rt_ColCorrectMask, and then sending the parameters + RT texture to new code in the SDK_Engine_Post shader.

Additionally, the ability to enable the top vignette texture (which was previously unused and had to be enabled by editing the engine_post VMT) has been added to postprocess_controller, using a keyvalue inspired by L4D2 (or at least as it was presented on the VDC). This means mappers can enable a mostly seamless vignette with a strength from 0-1. This feature is part of this branch because it involves changes to the SDK_Engine_Post shader as well.


New hl2_rendertargets.cpp/.h files containing a new CHL2RenderTargets class are included in this PR, and Mapbase's custom RT camera textures were moved to it. Previously, Mapbase's custom RT textures were done through the Mapbase game system in mapbase_shared.cpp, which were originally created as a workaround for baseclientrendertargets.cpp not defining its RT textures. The TF2 SDK has revealed that games need to individually override its interface in order to use it, and this PR adds a basic, extensible stub class. This is sort of a prerequisite change that's being clumped in due to this feature's requirement of a new render target.


The following file contains the recompiled shader and edited engine_post VMT:
cc-exclusion.zip


PR Checklist

  • My PR follows all guidelines in the CONTRIBUTING.md file
  • My PR targets a develop branch OR targets another branch with a specific goal in mind

@samisalreadytaken samisalreadytaken left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe CColorCorrectionExclude should hold a vector of entities that can be modified with InputAddTarget, InputRemoveTarget, using an edict for this seems wasteful. Though I am noticing that this mimicks point_glow entity, of which I have the same opinion (although that is less useful). Perhaps this could be resolved by also having a vscript interface like CScriptGlowObjectManager.

All the "nodraw network" business could be handled multiple ways. If the client only really needs to know when it was turned off and not when it left PVS, then a simple entity message would suffice.

int CBeam::UpdateTransmitState( void )
{
#ifdef MAPBASE
	EntityMessageBegin( this, true );
		WRITE_BOOL( GetEffects() & EF_NODRAW );
	MessageEnd();
#endif

	// we must call ShouldTransmit() if we have a move parent
	if ( GetMoveParent() )
		return SetTransmitState( FL_EDICT_FULLCHECK );

	return BaseClass::UpdateTransmitState( );
}

#if defined(MAPBASE) && defined(CLIENT_DLL)
void CBeam::ReceiveMessage( int classID, bf_read &msg )
{
	if ( classID != GetClientClass()->m_ClassID )
	{
		BaseClass::ReceiveMessage( classID, msg );
		return;
	}

	bool nodraw = msg.ReadOneBit();
	if ( nodraw )
	{
		AddEffects( EF_NODRAW );
	}
	else
	{
		RemoveEffects( EF_NODRAW );
	}
}
#endif

If PVS needs to also be accounted for, then client can detect it itself. The only downside of this simplicity I can think of is a hypothetical serverside beam which was turned off exclusively on client being automatically turned on when it enters the PVS.

#if defined(MAPBASE) && defined(CLIENT_DLL)
void CBeam::NotifyShouldTransmit( ShouldTransmitState_t state )
{
	BaseClass::NotifyShouldTransmit( state );

	if ( state == SHOULDTRANSMIT_START )
	{
		RemoveEffects( EF_NODRAW );
	}
	else if ( state == SHOULDTRANSMIT_END )
	{
		AddEffects( EF_NODRAW );
	}
}
#endif

I wasn't able to figure out how beams know to not appear in standard rendering

On this point, I think it does it by removing the entity from client leaf system in C_BaseEntity::UpdateVisibility due to IsDormant(). Would checking for dormancy in CBeam::ShouldDraw() fix this issue?

@Blixibon
Blixibon force-pushed the mapbase/feature/cc-exclusion-mask-and-vignette branch from 1801209 to a1734c0 Compare March 9, 2026 19:04
//------------------------------------------------------------------------------
// Color Correction Mask
//------------------------------------------------------------------------------
int CColorCorrectionMgr::RegisterExclusionObject( C_BaseEntity *pEntity, Vector *vecColor, float flAlpha )

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

if two color_correction_excludes target the same entity, disabling one removes both

Comment thread sp/src/game/server/colorcorrection.cpp Resolved

#ifdef MAPBASE
if ( m_pMaterialParam_VignetteEnable )
m_pMaterialParam_VignetteEnable->SetIntValue( s_LocalPostProcessParameters.m_flParameters[ PPPN_TOP_VIGNETTE_STRENGTH ] > 0.0f ? 1 : 0 );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

vignette doesnt work without postprocess controller ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is the intended behavior. I suppose it did technically work without postprocess controller before, although it wasn't documented and I don't think it would've been in use by any mods (please correct me if I'm wrong)

return;
}

m_bDrawingColCorrectExclude = true;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this is set during rendering but read in commit so its a frame behind no ?

continue;

pRenderContext->EnableClipping( ((pOverlay->m_bInSky) ? (false):(bClippingEnabled)) ); //disable clipping in skybox, restore clipping to pre-existing state when not in skybox (it may be off as well)
pOverlay->Draw( true );

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

the viewmodel is in the depth buffer at this point so this will look funny

@Blixibon
Blixibon force-pushed the mapbase/feature/cc-exclusion-mask-and-vignette branch from 46b6165 to a7b1463 Compare November 30, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants