Updated the SDK with the latest code from the TF and HL2 branches.
This commit is contained in:
@@ -458,6 +458,21 @@ void CBaseVSShader::SetPixelShaderTextureScaledTransform( int pixelReg, int tran
|
||||
//-----------------------------------------------------------------------------
|
||||
// Moves a matrix into vertex shader constants
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseVSShader::SetVertexShaderMatrix2x4( int vertexReg, int matrixVar )
|
||||
{
|
||||
IMaterialVar* pTranslationVar = s_ppParams[ matrixVar ];
|
||||
if ( pTranslationVar )
|
||||
{
|
||||
s_pShaderAPI->SetVertexShaderConstant( vertexReg, &pTranslationVar->GetMatrixValue()[ 0 ][ 0 ], 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
VMatrix matrix;
|
||||
MatrixSetIdentity( matrix );
|
||||
s_pShaderAPI->SetVertexShaderConstant( vertexReg, &matrix[ 0 ][ 0 ], 2 );
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseVSShader::SetVertexShaderMatrix3x4( int vertexReg, int matrixVar )
|
||||
{
|
||||
IMaterialVar* pTranslationVar = s_ppParams[matrixVar];
|
||||
|
||||
@@ -118,6 +118,7 @@ public:
|
||||
int transformVar, int scaleVar );
|
||||
|
||||
// Moves a matrix into vertex shader constants
|
||||
void SetVertexShaderMatrix2x4( int vertexReg, int matrixVar );
|
||||
void SetVertexShaderMatrix3x4( int vertexReg, int matrixVar );
|
||||
void SetVertexShaderMatrix4x4( int vertexReg, int matrixVar );
|
||||
|
||||
|
||||
@@ -19,7 +19,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
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
float fValue = params[info.m_nPhongExponent]->GetFloatValue();
|
||||
if ( fValue > 0.f )
|
||||
vEyePos_SpecExponent[3] = flPhongExponentFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@
|
||||
// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1" [ps30]
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps20b]
|
||||
// DYNAMIC: "FLASHLIGHTSHADOWS" "0..1" [ps30]
|
||||
// DYNAMIC: "PHONG_USE_EXPONENT_FACTOR" "0..0" [ps20]
|
||||
// DYNAMIC: "PHONG_USE_EXPONENT_FACTOR" "0..1" [ps20b] [ps30] [PC]
|
||||
|
||||
|
||||
// SKIP: ($PIXELFOGTYPE == 0) && ($WRITEWATERFOGTODESTALPHA != 0)
|
||||
@@ -76,7 +78,9 @@ const float4 g_EyePos_SpecExponent : register( PSREG_EYEPOS_SPEC_EXPONENT );
|
||||
const float4 g_FogParams : register( PSREG_FOG_PARAMS );
|
||||
const float4 g_FlashlightAttenuationFactors_RimMask : register( PSREG_FLASHLIGHT_ATTENUATION ); // On non-flashlight pass, x has rim mask control
|
||||
const float4 g_FlashlightPos_RimBoost : register( PSREG_FLASHLIGHT_POSITION_RIM_BOOST );
|
||||
const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
|
||||
#if FLASHLIGHT
|
||||
const float4x4 g_FlashlightWorldToTexture : register( PSREG_FLASHLIGHT_TO_WORLD_TEXTURE );
|
||||
#endif
|
||||
const float4 g_FresnelSpecParams : register( PSREG_FRESNEL_SPEC_PARAMS ); // xyz are fresnel, w is specular boost
|
||||
const float4 g_SpecularRimParams : register( PSREG_SPEC_RIM_PARAMS ); // xyz are specular tint color, w is rim power
|
||||
PixelShaderLightInfo cLightInfo[3] : register( PSREG_LIGHT_INFO_ARRAY ); // 2 registers each - 6 registers total (4th light spread across w's)
|
||||
@@ -96,6 +100,7 @@ const float4 g_ShaderControls : register( PSREG_CONSTANT_27 ); // x is
|
||||
#define g_fTintReplacementControl g_ShaderControls.z
|
||||
#define g_fInvertPhongMask g_ShaderControls.w
|
||||
|
||||
|
||||
sampler BaseTextureSampler : register( s0 ); // Base map, selfillum in alpha
|
||||
sampler SpecularWarpSampler : register( s1 ); // Specular warp sampler (for iridescence etc)
|
||||
sampler DiffuseWarpSampler : register( s2 ); // Lighting warp sampler (1D texture for diffuse lighting modification)
|
||||
@@ -119,7 +124,6 @@ sampler DetailSampler : register( s13 ); // detail texture
|
||||
|
||||
sampler SelfIllumMaskSampler : register( s14 ); // selfillummask
|
||||
|
||||
|
||||
struct PS_INPUT
|
||||
{
|
||||
float4 baseTexCoordDetailTexCoord : TEXCOORD0; // xy=base zw=detail
|
||||
@@ -258,7 +262,11 @@ float4 main( PS_INPUT i ) : COLOR
|
||||
[flatten]
|
||||
#endif
|
||||
|
||||
#if ( PHONG_USE_EXPONENT_FACTOR )
|
||||
fSpecExp = ( 1.0f + g_EyePos_SpecExponent.w * vSpecExpMap.r );
|
||||
#else
|
||||
fSpecExp = (g_EyePos_SpecExponent.w >= 0.0) ? g_EyePos_SpecExponent.w : (1.0f + 149.0f * vSpecExpMap.r);
|
||||
#endif
|
||||
|
||||
// If constant tint is negative, tint with albedo, based upon scalar tint map
|
||||
#if defined( _X360 )
|
||||
@@ -286,15 +294,17 @@ float4 main( PS_INPUT i ) : COLOR
|
||||
}
|
||||
else
|
||||
{
|
||||
float4 flashlightSpacePosition = mul( float4( vWorldPos, 1.0f ), g_FlashlightWorldToTexture );
|
||||
#if FLASHLIGHT
|
||||
float4 flashlightSpacePosition = mul( float4( vWorldPos, 1.0f ), g_FlashlightWorldToTexture );
|
||||
|
||||
DoSpecularFlashlight( g_FlashlightPos, vWorldPos, flashlightSpacePosition, worldSpaceNormal,
|
||||
g_FlashlightAttenuationFactors.xyz, g_FlashlightAttenuationFactors.w,
|
||||
FlashlightSampler, ShadowDepthSampler, NormalizeRandRotSampler, FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true, vProjPos.xy / vProjPos.z,
|
||||
fSpecExp, vEyeDir, bDoSpecularWarp, SpecularWarpSampler, fFresnelRanges, g_EnvmapTint_ShadowTweaks,
|
||||
DoSpecularFlashlight( g_FlashlightPos, vWorldPos, flashlightSpacePosition, worldSpaceNormal,
|
||||
g_FlashlightAttenuationFactors.xyz, g_FlashlightAttenuationFactors.w,
|
||||
FlashlightSampler, ShadowDepthSampler, NormalizeRandRotSampler, FLASHLIGHTDEPTHFILTERMODE, FLASHLIGHTSHADOWS, true, vProjPos.xy / vProjPos.z,
|
||||
fSpecExp, vEyeDir, bDoSpecularWarp, SpecularWarpSampler, fFresnelRanges, g_EnvmapTint_ShadowTweaks,
|
||||
|
||||
// These two values are output
|
||||
diffuseLighting, specularLighting );
|
||||
// These two values are output
|
||||
diffuseLighting, specularLighting );
|
||||
#endif
|
||||
}
|
||||
|
||||
// If we didn't already apply Fresnel to specular warp, modulate the specular
|
||||
|
||||
@@ -358,8 +358,8 @@ float4 main( PS_INPUT i ) : COLOR
|
||||
diffuseLighting = f3LightmapColor;
|
||||
#endif
|
||||
|
||||
|
||||
float3 albedo = baseColor;
|
||||
|
||||
if (bBlendTintByBaseAlpha)
|
||||
{
|
||||
float3 tintedColor = albedo * g_DiffuseModulation.rgb;
|
||||
|
||||
@@ -54,6 +54,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" )
|
||||
SHADER_PARAM( PHONGFRESNELRANGES, SHADER_PARAM_TYPE_VEC3, "[0 0.5 1]", "Parameters for remapping fresnel output" )
|
||||
SHADER_PARAM( PHONGBOOST, SHADER_PARAM_TYPE_FLOAT, "1.0", "Phong overbrightening factor (specular mask channel should be authored to account for this)" )
|
||||
SHADER_PARAM( PHONGEXPONENTTEXTURE, SHADER_PARAM_TYPE_TEXTURE, "shadertest/BaseTexture", "Phong Exponent map" )
|
||||
SHADER_PARAM( PHONGEXPONENTFACTOR, SHADER_PARAM_TYPE_FLOAT, "0.0", "When using a phong exponent texture, this will be multiplied by the 0..1 that comes out of the texture." )
|
||||
SHADER_PARAM( PHONG, SHADER_PARAM_TYPE_BOOL, "0", "enables phong lighting" )
|
||||
SHADER_PARAM( BASEMAPALPHAPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "indicates that there is no normal map and that the phong mask is in base alpha" )
|
||||
SHADER_PARAM( INVERTPHONGMASK, SHADER_PARAM_TYPE_INTEGER, "0", "invert the phong mask (0=full phong, 1=no phong)" )
|
||||
@@ -180,6 +181,7 @@ BEGIN_VS_SHADER( VertexLitGeneric, "Help for VertexLitGeneric" )
|
||||
info.m_nDiffuseWarpTexture = LIGHTWARPTEXTURE;
|
||||
info.m_nPhongWarpTexture = PHONGWARPTEXTURE;
|
||||
info.m_nPhongBoost = PHONGBOOST;
|
||||
info.m_nPhongExponentFactor = PHONGEXPONENTFACTOR;
|
||||
info.m_nPhongFresnelRanges = PHONGFRESNELRANGES;
|
||||
info.m_nPhong = PHONG;
|
||||
info.m_nBaseMapAlphaPhongMask = BASEMAPALPHAPHONGMASK;
|
||||
|
||||
@@ -433,7 +433,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
bool bHasVertexAlpha = bVertexLitGeneric ? false : IS_FLAG_SET( MATERIAL_VAR_VERTEXALPHA );
|
||||
/*^*/ // printf("\t\t[%d] bHasVertexColor\n",(int)bHasVertexColor);
|
||||
/*^*/ // printf("\t\t[%d] bHasVertexAlpha\n",(int)bHasVertexAlpha);
|
||||
|
||||
|
||||
if ( pShader->IsSnapshotting() || (! pContextData ) || ( pContextData->m_bMaterialVarsChanged ) )
|
||||
{
|
||||
/*^*/ // printf("\t\t[1] snapshotting=%d pContextData=%08x pContextData->m_bMaterialVarsChanged=%d \n",(int)pShader->IsSnapshotting(), (int)pContextData, pContextData ? (int)pContextData->m_bMaterialVarsChanged : -1 );
|
||||
@@ -1221,7 +1221,6 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MaterialFogMode_t fogType = pShaderAPI->GetSceneFogMode();
|
||||
int fogIndex = ( fogType == MATERIAL_FOG_LINEAR_BELOW_FOG_Z ) ? 1 : 0;
|
||||
int numBones = pShaderAPI->GetCurrentNumBones();
|
||||
|
||||
@@ -68,6 +68,7 @@ struct VertexLitGeneric_DX9_Vars_t
|
||||
int m_nPhongWarpTexture;
|
||||
int m_nPhongBoost;
|
||||
int m_nPhongFresnelRanges;
|
||||
int m_nPhongExponentFactor;
|
||||
int m_nSelfIllumEnvMapMask_Alpha;
|
||||
int m_nAmbientOnly;
|
||||
int m_nHDRColorScale;
|
||||
@@ -131,7 +132,6 @@ struct VertexLitGeneric_DX9_Vars_t
|
||||
int m_nBlendTintByBaseAlpha;
|
||||
|
||||
int m_nTintReplacesBaseColor;
|
||||
|
||||
};
|
||||
|
||||
void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info );
|
||||
|
||||
Reference in New Issue
Block a user