From c3698265ca3f5439a6d097033d6ea50521c3bde5 Mon Sep 17 00:00:00 2001 From: kitsune Date: Mon, 17 Nov 2025 14:26:02 +0100 Subject: [PATCH] Enable $flashlightnolambert and apply HVS to baseColor in RDCharacter shader - Added support for flashlightnolambert, ensuring proper non-Lambert flashlight behavior. - Reordered shader flow to ensure HVS modifies baseColor at the start, directly affecting the base texture rather than post-processed color adjustments. --- .../stdshaders/character_dx9_helper.cpp | 4 +++- src/materialsystem/stdshaders/character_ps20b.fxc | 14 +++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/materialsystem/stdshaders/character_dx9_helper.cpp b/src/materialsystem/stdshaders/character_dx9_helper.cpp index d8804750f..bf5bfa80a 100644 --- a/src/materialsystem/stdshaders/character_dx9_helper.cpp +++ b/src/materialsystem/stdshaders/character_dx9_helper.cpp @@ -248,6 +248,8 @@ void DrawCharacter_DX9( CBaseVSShader *pShader, IMaterialVar **params, IShaderDy CCharacter_DX9_Context *pContextData = reinterpret_cast< CCharacter_DX9_Context * > ( *pContextDataPtr ); bool bHasFlashlight = pShader->UsingFlashlight( params ); + //bool bNoCull = IS_FLAG_SET( MATERIAL_VAR_NOCULL ); + bool bFlashlightNoLambert = ( info.m_nFlashlightNoLambert != -1 ) && ( params[ info.m_nFlashlightNoLambert ]->GetIntValue() != 0 ); bool bIsDecal = IS_FLAG_SET( MATERIAL_VAR_DECAL ); bool bIsAlphaTested = IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) != 0; BlendType_t nBlendType = pShader->EvaluateBlendRequirements( info.m_nBaseTexture, true ); @@ -844,7 +846,7 @@ void DrawCharacter_DX9( CBaseVSShader *pShader, IMaterialVar **params, IShaderDy state.m_nDepthTweakConstant = PSREG_ENVMAP_TINT__SHADOW_TWEAKS; // NOTE: Reg 43 not available on < ps3.0! state.m_nScreenScaleConstant = PSREG_FLASHLIGHT_SCREEN_SCALE; state.m_nWorldToTextureConstant = PSREG_FLASHLIGHT_TO_WORLD_TEXTURE; - state.m_bFlashlightNoLambert = false; + state.m_bFlashlightNoLambert = bFlashlightNoLambert; state.m_bSinglePassFlashlight = false; pContextData->m_SemiStaticCmdsOut.SetPixelShaderFlashlightState( state ); diff --git a/src/materialsystem/stdshaders/character_ps20b.fxc b/src/materialsystem/stdshaders/character_ps20b.fxc index 55d75d587..eda393fbe 100644 --- a/src/materialsystem/stdshaders/character_ps20b.fxc +++ b/src/materialsystem/stdshaders/character_ps20b.fxc @@ -204,6 +204,13 @@ float4 main( PS_INPUT i ) : COLOR float4 baseColor = tex2Dsrgb( BaseTextureSampler, i.baseTexCoordDetailTexCoord.xy ); +#if HSV + float3 baseColorHSV = rgb2hsv(baseColor.rgb); + baseColorHSV.x = fmod(baseColorHSV.x + g_HsvParams.x, 1.0); + baseColorHSV.yz = clamp(baseColorHSV.yz * g_HsvParams.yz, 0.0, 1.0); + baseColor.xyz = lerp(baseColor.xyz, hsv2rgb(baseColorHSV), saturate(baseColor.a + g_fInverseBlendTintByBaseAlpha)); +#endif + float flWrinkleAmount, flStretchAmount, flTextureAmount; #if ( WRINKLEMAP ) { @@ -379,13 +386,6 @@ float4 main( PS_INPUT i ) : COLOR // Optionally use basealpha to blend in the diffuse modulation (saturated add of g_fInverseBlendTintByBaseAlpha turns this on/off) diffuseLighting *= lerp( float3( 1.0f, 1.0f, 1.0f ), g_DiffuseModulation.rgb, saturate( baseColor.a + g_fInverseBlendTintByBaseAlpha ) ); -#if HSV - float3 albedoHSV = rgb2hsv(albedo.rgb); - albedoHSV.x = fmod(albedoHSV.x + g_HsvParams.x, 1.0); - albedoHSV.yz = clamp(albedoHSV.yz * g_HsvParams.yz, 0.0, 1.0); - albedo.xyz = lerp(albedo.xyz, hsv2rgb(albedoHSV), saturate(baseColor.a + g_fInverseBlendTintByBaseAlpha)); -#endif - float3 diffuseComponent = albedo * diffuseLighting; #if ( SELFILLUM && !FLASHLIGHT )