aboutsummaryrefslogtreecommitdiff
path: root/mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp
diff options
context:
space:
mode:
authorJohn Schoenick <[email protected]>2015-09-09 18:35:41 -0700
committerJohn Schoenick <[email protected]>2015-09-09 18:35:41 -0700
commit0d8dceea4310fde5706b3ce1c70609d72a38efdf (patch)
treec831ef32c2c801a5c5a80401736b52c7b5a528ec /mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp
parentUpdated the SDK with the latest code from the TF and HL2 branches. (diff)
downloadsource-sdk-2013-master.tar.xz
source-sdk-2013-master.zip
Updated the SDK with the latest code from the TF and HL2 branches.HEADmaster
Diffstat (limited to 'mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp')
-rw-r--r--mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp b/mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp
index 1e2d30f3..cc999788 100644
--- a/mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp
+++ b/mp/src/materialsystem/stdshaders/skin_dx9_helper.cpp
@@ -23,7 +23,7 @@
static ConVar mat_fullbright( "mat_fullbright", "0", FCVAR_CHEAT );
static ConVar r_lightwarpidentity( "r_lightwarpidentity", "0", FCVAR_CHEAT );
-static ConVar r_rimlight( "r_rimlight", "1", FCVAR_CHEAT );
+static ConVar r_rimlight( "r_rimlight", "1", FCVAR_NONE );
// Textures may be bound to the following samplers:
// SHADER_SAMPLER0 Base (Albedo) / Gloss in alpha
@@ -270,6 +270,9 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad
float flTintReplacementAmount = GetFloatParam( info.m_nTintReplacesBaseColor, params );
+ float flPhongExponentFactor = ( info.m_nPhongExponentFactor != -1 ) ? GetFloatParam( info.m_nPhongExponentFactor, params ) : 0.0f;
+ const bool bHasPhongExponentFactor = flPhongExponentFactor != 0.0f;
+
BlendType_t nBlendType= pShader->EvaluateBlendRequirements( bBlendTintByBaseAlpha ? -1 : info.m_nBaseTexture, true );
bool bFullyOpaque = (nBlendType != BT_BLENDADD) && (nBlendType != BT_BLEND) && !bIsAlphaTested && !bHasFlashlight; //dest alpha is free for special use
@@ -676,6 +679,7 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha );
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows );
+ SET_DYNAMIC_PIXEL_SHADER_COMBO( PHONG_USE_EXPONENT_FACTOR, bHasPhongExponentFactor );
SET_DYNAMIC_PIXEL_SHADER( skin_ps20b );
}
#ifndef _X360
@@ -697,6 +701,7 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad
SET_DYNAMIC_PIXEL_SHADER_COMBO( WRITE_DEPTH_TO_DESTALPHA, bWriteDepthToAlpha );
SET_DYNAMIC_PIXEL_SHADER_COMBO( PIXELFOGTYPE, pShaderAPI->GetPixelFogCombo() );
SET_DYNAMIC_PIXEL_SHADER_COMBO( FLASHLIGHTSHADOWS, bFlashlightShadows );
+ SET_DYNAMIC_PIXEL_SHADER_COMBO( PHONG_USE_EXPONENT_FACTOR, bHasPhongExponentFactor );
SET_DYNAMIC_PIXEL_SHADER( skin_ps30 );
bool bUnusedTexCoords[3] = { false, false, !pShaderAPI->IsHWMorphingEnabled() || !bIsDecal };
@@ -806,15 +811,23 @@ void DrawSkin_DX9_Internal( CBaseVSShader *pShader, IMaterialVar** params, IShad
float vSpecularTint[4] = {1, 1, 1, 4};
pShaderAPI->GetWorldSpaceCameraPosition( vEyePos_SpecExponent );
- // Use the alpha channel of the normal map for the exponent by default
- vEyePos_SpecExponent[3] = -1.f;
- if ( (info.m_nPhongExponent != -1) && params[info.m_nPhongExponent]->IsDefined() )
+ // If we have a phong exponent factor, then use that as a multiplier against the texture.
+ if ( bHasPhongExponentFactor )
+ {
+ vEyePos_SpecExponent[3] = flPhongExponentFactor;
+ }
+ else
{
- float fValue = params[info.m_nPhongExponent]->GetFloatValue();
- if ( fValue > 0.f )
+ // Use the alpha channel of the normal map for the exponent by default
+ vEyePos_SpecExponent[3] = -1.f;
+ if ( (info.m_nPhongExponent != -1) && params[info.m_nPhongExponent]->IsDefined() )
{
- // Nonzero value in material overrides map channel
- vEyePos_SpecExponent[3] = fValue;
+ float fValue = params[info.m_nPhongExponent]->GetFloatValue();
+ if ( fValue > 0.f )
+ {
+ // Nonzero value in material overrides map channel
+ vEyePos_SpecExponent[3] = fValue;
+ }
}
}