Skip to content

Commit fae978f

Browse files
committed
Enable and apply HVS to baseColor in RDCharacter shader
- Added support for , ensuring proper non-Lambert flashlight behavior. - Reordered shader flow so HVS is applied at the start as a modifier of baseColor, affecting the base texture rather than post-processed colors. - PBR shader still requires adjustments due to different flashlight implementation.
1 parent d77f6c3 commit fae978f

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/materialsystem/stdshaders/character_dx9_helper.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ void DrawCharacter_DX9( CBaseVSShader *pShader, IMaterialVar **params, IShaderDy
248248
CCharacter_DX9_Context *pContextData = reinterpret_cast< CCharacter_DX9_Context * > ( *pContextDataPtr );
249249

250250
bool bHasFlashlight = pShader->UsingFlashlight( params );
251+
//bool bNoCull = IS_FLAG_SET( MATERIAL_VAR_NOCULL );
252+
bool bFlashlightNoLambert = ( info.m_nFlashlightNoLambert != -1 ) && ( params[ info.m_nFlashlightNoLambert ]->GetIntValue() != 0 );
251253
bool bIsDecal = IS_FLAG_SET( MATERIAL_VAR_DECAL );
252254
bool bIsAlphaTested = IS_FLAG_SET( MATERIAL_VAR_ALPHATEST ) != 0;
253255
BlendType_t nBlendType = pShader->EvaluateBlendRequirements( info.m_nBaseTexture, true );
@@ -844,7 +846,7 @@ void DrawCharacter_DX9( CBaseVSShader *pShader, IMaterialVar **params, IShaderDy
844846
state.m_nDepthTweakConstant = PSREG_ENVMAP_TINT__SHADOW_TWEAKS; // NOTE: Reg 43 not available on < ps3.0!
845847
state.m_nScreenScaleConstant = PSREG_FLASHLIGHT_SCREEN_SCALE;
846848
state.m_nWorldToTextureConstant = PSREG_FLASHLIGHT_TO_WORLD_TEXTURE;
847-
state.m_bFlashlightNoLambert = false;
849+
state.m_bFlashlightNoLambert = bFlashlightNoLambert;
848850
state.m_bSinglePassFlashlight = false;
849851
pContextData->m_SemiStaticCmdsOut.SetPixelShaderFlashlightState( state );
850852

src/materialsystem/stdshaders/character_ps20b.fxc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,13 @@ float4 main( PS_INPUT i ) : COLOR
204204

205205
float4 baseColor = tex2Dsrgb( BaseTextureSampler, i.baseTexCoordDetailTexCoord.xy );
206206

207+
#if HSV
208+
float3 baseColorHSV = rgb2hsv(baseColor.rgb);
209+
baseColorHSV.x = fmod(baseColorHSV.x + g_HsvParams.x, 1.0);
210+
baseColorHSV.yz = clamp(baseColorHSV.yz * g_HsvParams.yz, 0.0, 1.0);
211+
baseColor.xyz = lerp(baseColor.xyz, hsv2rgb(baseColorHSV), saturate(baseColor.a + g_fInverseBlendTintByBaseAlpha));
212+
#endif
213+
207214
float flWrinkleAmount, flStretchAmount, flTextureAmount;
208215
#if ( WRINKLEMAP )
209216
{
@@ -379,13 +386,6 @@ float4 main( PS_INPUT i ) : COLOR
379386
// Optionally use basealpha to blend in the diffuse modulation (saturated add of g_fInverseBlendTintByBaseAlpha turns this on/off)
380387
diffuseLighting *= lerp( float3( 1.0f, 1.0f, 1.0f ), g_DiffuseModulation.rgb, saturate( baseColor.a + g_fInverseBlendTintByBaseAlpha ) );
381388

382-
#if HSV
383-
float3 albedoHSV = rgb2hsv(albedo.rgb);
384-
albedoHSV.x = fmod(albedoHSV.x + g_HsvParams.x, 1.0);
385-
albedoHSV.yz = clamp(albedoHSV.yz * g_HsvParams.yz, 0.0, 1.0);
386-
albedo.xyz = lerp(albedo.xyz, hsv2rgb(albedoHSV), saturate(baseColor.a + g_fInverseBlendTintByBaseAlpha));
387-
#endif
388-
389389
float3 diffuseComponent = albedo * diffuseLighting;
390390

391391
#if ( SELFILLUM && !FLASHLIGHT )

0 commit comments

Comments
 (0)