diff --git a/src/game/client/glow_outline_effect.cpp b/src/game/client/glow_outline_effect.cpp index 7f50e19e4..5b68d827b 100644 --- a/src/game/client/glow_outline_effect.cpp +++ b/src/game/client/glow_outline_effect.cpp @@ -32,6 +32,7 @@ ConVar glow_outline_effect_enable("glow_outline_effect_enable", "1", FCVAR_ARCHI } ); ConVar glow_outline_effect_width( "glow_outline_effect_width", "1.f", FCVAR_ARCHIVE, "Width of glow outline effect.", true, 0.f, false, 0.f); +ConVar glow_outline_effect_alpha( "glow_outline_effect_alpha", "0.5f", FCVAR_ARCHIVE, "Alpha of glow outline effect.", true, 0.f, true, 1.f); ConVar glow_outline_effect_center_alpha("glow_outline_effect_center_alpha", "0.1f", FCVAR_ARCHIVE, "Opacity of the part of the glow effect drawn on top of the player model when obstructed", true, 0.f, true, 1.f); ConVar glow_outline_effect_textured_center_alpha("glow_outline_effect_textured_center_alpha", "0.2f", FCVAR_ARCHIVE, "Opacity of the part of the glow effect drawn on top of the player model when cloaked", true, 0.f, true, 1.f); #else @@ -371,10 +372,13 @@ void CGlowObjectManager::ApplyEntityGlowEffects( const CViewSetup *pSetup, int n // Draw quad #ifdef NEO const float outlineWidth = glow_outline_effect_width.GetFloat(); - if (outlineWidth) + const float outlineAlpha = glow_outline_effect_alpha.GetFloat(); + if (outlineWidth && outlineAlpha) { IMaterialVar* pOutlineVar = pMatHaloAddToScreenOutline->FindVar("$C0_X", NULL); pOutlineVar->SetFloatValue(outlineWidth); + IMaterialVar* pAlphaVar = pMatHaloAddToScreenOutline->FindVar("$C0_Y", NULL); + pAlphaVar->SetFloatValue(outlineAlpha); pRenderContext->DrawScreenSpaceRectangle(pMatHaloAddToScreenOutline, 0, 0, nViewportWidth+1, nViewportHeight+1, 0, 0, pRtQuarterSize1->GetActualWidth(), pRtQuarterSize1->GetActualHeight(), pRtQuarterSize1->GetActualWidth(), diff --git a/src/game/client/neo/ui/neo_root_settings.cpp b/src/game/client/neo/ui/neo_root_settings.cpp index 3eabb33b2..6bd3b82ef 100644 --- a/src/game/client/neo/ui/neo_root_settings.cpp +++ b/src/game/client/neo/ui/neo_root_settings.cpp @@ -669,6 +669,7 @@ void NeoSettingsRestore(NeoSettings *ns, const NeoSettings::Keys::Flags flagsKey pHUD->bEnableXray = cvr->glow_outline_effect_enable.GetBool(); pHUD->flOutlineWidth = cvr->glow_outline_effect_width.GetFloat(); + pHUD->flOutlineAlpha = cvr->glow_outline_effect_alpha.GetFloat(); pHUD->flCenterOpacity = cvr->glow_outline_effect_center_alpha.GetFloat(); pHUD->flTexturedOpacity = cvr->glow_outline_effect_textured_center_alpha.GetFloat(); #endif // GLOWS_ENABLE @@ -903,6 +904,7 @@ void NeoSettingsSave(const NeoSettings *ns) cvr->glow_outline_effect_enable.SetValue(pHUD->bEnableXray); cvr->glow_outline_effect_width.SetValue(pHUD->flOutlineWidth); + cvr->glow_outline_effect_alpha.SetValue(pHUD->flOutlineAlpha); cvr->glow_outline_effect_center_alpha.SetValue(pHUD->flCenterOpacity); cvr->glow_outline_effect_textured_center_alpha.SetValue(pHUD->flTexturedOpacity); #endif // GLOWS_ENABLE @@ -1432,6 +1434,7 @@ void NeoSettings_HUD(NeoSettings* ns) NeoUI::Divider(L"XRAY"); NeoUI::RingBoxBool(L"Enable Xray", &pHud->bEnableXray); NeoUI::Slider(L"Outline Width", &pHud->flOutlineWidth, 0, 2, 2, 0.25f); + NeoUI::Slider(L"Outline Opacity", &pHud->flOutlineAlpha, 0, 1, 2, 0.1f); NeoUI::Slider(L"Center Opacity", &pHud->flCenterOpacity, 0, 1, 2, 0.1f); NeoUI::Slider(L"Texture Opacity (Cloak highlight)", &pHud->flTexturedOpacity, 0, 1, 2, 0.1f); #endif // GLOWS_ENABLE diff --git a/src/game/client/neo/ui/neo_root_settings.h b/src/game/client/neo/ui/neo_root_settings.h index e89143992..5608d8b8f 100644 --- a/src/game/client/neo/ui/neo_root_settings.h +++ b/src/game/client/neo/ui/neo_root_settings.h @@ -208,6 +208,7 @@ struct NeoSettings // Player Xray bool bEnableXray; float flOutlineWidth; + float flOutlineAlpha; float flCenterOpacity; float flTexturedOpacity; #endif // GLOWS_ENABLE @@ -332,6 +333,7 @@ struct NeoSettings // Xray CONVARREF_DEF(glow_outline_effect_enable); CONVARREF_DEF(glow_outline_effect_width); + CONVARREF_DEF(glow_outline_effect_alpha); CONVARREF_DEF(glow_outline_effect_center_alpha); CONVARREF_DEF(glow_outline_effect_textured_center_alpha); #endif // GLOWS_ENABLE diff --git a/src/materialsystem/stdshaders/neo_haloaddoutline_ps2x.fxc b/src/materialsystem/stdshaders/neo_haloaddoutline_ps2x.fxc index d5614d896..fe34ee644 100644 --- a/src/materialsystem/stdshaders/neo_haloaddoutline_ps2x.fxc +++ b/src/materialsystem/stdshaders/neo_haloaddoutline_ps2x.fxc @@ -7,8 +7,10 @@ sampler TexRed : register( s1 ); sampler TexGreen : register( s2 ); sampler TexBlue : register( s3 ); -float g_flOutlineWidth : register( c0 ); -float2 g_vPixelSize : register( c4 ); +const float2 g_flOutlineProperties : register(c0); +#define g_flOutlineWidth g_flOutlineProperties.x +#define g_flDimValue g_flOutlineProperties.y +const float2 g_vPixelSize : register(c4); struct PS_INPUT { @@ -19,12 +21,20 @@ float4 main( PS_INPUT i ) : COLOR { float2 vOffset = g_flOutlineWidth * g_vPixelSize.xy; - // Take the max of 4 offset texture samples + // Take the max of 4(8?) offset texture samples float4 result; result.rgba = tex2D( TexSampler, i.baseTexCoord.xy + float2( vOffset.x, vOffset.y ) ); result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( vOffset.x, -vOffset.y ) ) ); result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( -vOffset.x, vOffset.y ) ) ); result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( -vOffset.x, -vOffset.y ) ) ); + // Far objects or slim objects have holes in the outline unless we check all 8 surrounding neighbors, is the improved outline worth the extra cost? + result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( -vOffset.x, 0 ) ) ); + result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( vOffset.x, 0 ) ) ); + result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( 0, -vOffset.y ) ) ); + result.rgba = max( result.rgba, tex2D( TexSampler, i.baseTexCoord.xy + float2( 0, vOffset.y ) ) ); + + // Scale by dim value before computing luminance below + result.rgb *= saturate( g_flDimValue ); // Store max color component in alpha for alpha blend of one/invSrcAlpha float flLuminance = max( result.r, max( result.g, result.b ) );