mirror of
https://github.com/mapbase-source/source-sdk-2013.git
synced 2024-12-27 07:15:31 +03:00
Mapbase v4.1
- Exposed CAmmoDef to VScript and changed ammo type functions accordingly - Added TakeHealth and IsAlive to CBaseEntity - Added $treeSway - Added several inputs to control env_wind keyvalues + a new $treeSway scale keyvalue - Added "Expanded name fixup" keyvalue to point_template which allows name fixup to fix up output parameters - Fixed the rope on rappelling NPCs causing graphical issues - Fixed prop_vehicle_prisoner_pod missing "EnterVehicle", "EnterVehicleImmediate", and "ExitVehicle" inputs - Fixed hostile citizens not damaging player - Fixed an uncommon npc_metropolice crash from when it's not in a squad - Made SetTarget input update target handling on NPCs - Changed ammo type functions to be more organized, added AmmoDef singleton - Added more precache functions - Added various misc. entity functions, like GetAllWeapons or AddOutput - Added more utility functions
This commit is contained in:
parent
5b2547a6ff
commit
418a9dcccc
@ -1210,6 +1210,7 @@ BEGIN_RECV_TABLE_NOBASE(CEnvWindShared, DT_EnvWindShared)
|
||||
RecvPropFloat (RECVINFO(m_windRadius)),
|
||||
RecvPropFloat (RECVINFO(m_windRadiusInner)),
|
||||
RecvPropVector (RECVINFO(m_location)),
|
||||
RecvPropFloat (RECVINFO(m_flTreeSwayScale)),
|
||||
#endif
|
||||
END_RECV_TABLE()
|
||||
|
||||
|
@ -159,6 +159,70 @@ string_t Templates_FindByTargetName(const char *pszName)
|
||||
return NULL_STRING;
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A new version of name fixup which targets all instances of a name
|
||||
// in a keyvalue, including output parameters.
|
||||
//-----------------------------------------------------------------------------
|
||||
void Templates_NewNameFixup( CUtlVector< grouptemplate_t > &GroupTemplates, int i, int iCount, CEntityMapData *mapData, CUtlDict< int, int > &KeyInstanceCount, char *keyName, char *value )
|
||||
{
|
||||
do
|
||||
{
|
||||
// Ignore targetnames
|
||||
if ( !stricmp( keyName, "targetname" ) )
|
||||
continue;
|
||||
|
||||
// Add to the count for this
|
||||
int idx = KeyInstanceCount.Find( keyName );
|
||||
if ( idx == KeyInstanceCount.InvalidIndex() )
|
||||
{
|
||||
idx = KeyInstanceCount.Insert( keyName, 0 );
|
||||
}
|
||||
KeyInstanceCount[idx]++;
|
||||
|
||||
// Loop through our group templates
|
||||
for ( int iTName = 0; iTName < iCount; iTName++ )
|
||||
{
|
||||
char *pName = GroupTemplates[iTName].pszName;
|
||||
if (strstr( value, pName ) == NULL)
|
||||
continue;
|
||||
|
||||
if ( template_debug.GetInt() )
|
||||
{
|
||||
Msg("Template Connection Found: Key %s (\"%s\") in entity named \"%s\"(%d) matches entity %d's targetname\n", keyName, value, GroupTemplates[i].pszName, i, iTName );
|
||||
}
|
||||
|
||||
char newvalue[MAPKEY_MAXLENGTH];
|
||||
char fixedup[MAPKEY_MAXLENGTH];
|
||||
Q_strncpy( fixedup, pName, MAPKEY_MAXLENGTH );
|
||||
Q_strncat( fixedup, ENTITYIO_FIXUP_STRING, sizeof( fixedup ), COPY_ALL_CHARACTERS );
|
||||
|
||||
// Get the current key instance. (-1 because it's this one we're changing)
|
||||
int nKeyInstance = KeyInstanceCount[idx] - 1;
|
||||
|
||||
// Add our IO value to the targetname
|
||||
V_StrSubst( value, pName, fixedup, newvalue, MAPKEY_MAXLENGTH );
|
||||
|
||||
if ( template_debug.GetInt() )
|
||||
{
|
||||
Msg(" Fixed up value: Key %s with \"%s\" in entity named \"%s\"(%d) has become \"%s\"\n", keyName, value, GroupTemplates[i].pszName, i, newvalue );
|
||||
}
|
||||
|
||||
mapData->SetValue( keyName, newvalue, nKeyInstance );
|
||||
Q_strncpy( value, newvalue, MAPKEY_MAXLENGTH );
|
||||
|
||||
// Remember we changed this targetname
|
||||
GroupTemplates[iTName].bChangeTargetname = true;
|
||||
|
||||
// Set both entity's flags telling them their template needs fixup when it's spawned
|
||||
g_Templates[ GroupTemplates[i].iIndex ]->bNeedsEntityIOFixup = true;
|
||||
g_Templates[ GroupTemplates[iTName].iIndex ]->bNeedsEntityIOFixup = true;
|
||||
}
|
||||
}
|
||||
while ( mapData->GetNextKey(keyName, value) );
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: A CPointTemplate has asked us to reconnect all the entity I/O links
|
||||
// inside it's templates. Go through the keys and add look for values
|
||||
@ -208,6 +272,14 @@ void Templates_ReconnectIOForGroup( CPointTemplate *pGroup )
|
||||
if ( !mapData->GetFirstKey(keyName, value) )
|
||||
continue;
|
||||
|
||||
#ifdef MAPBASE
|
||||
if ( pGroup->NameFixupExpanded() )
|
||||
{
|
||||
Templates_NewNameFixup( GroupTemplates, i, iCount, mapData, KeyInstanceCount, keyName, value );
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
// Ignore targetnames
|
||||
|
@ -2041,6 +2041,29 @@ void CAI_BaseNPC::InputSetDistTooFar( inputdata_t &inputdata )
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//------------------------------------------------------------------------------
|
||||
void CAI_BaseNPC::InputSetTarget( inputdata_t &inputdata )
|
||||
{
|
||||
m_target = inputdata.value.StringID();
|
||||
|
||||
if ( m_target != NULL_STRING )// this npc has a target
|
||||
{
|
||||
// Find the npc's initial target entity, stash it
|
||||
SetGoalEnt( gEntList.FindEntityByName( NULL, m_target ) );
|
||||
|
||||
if ( !GetGoalEnt() )
|
||||
{
|
||||
Warning( "ReadyNPC()--%s couldn't find target %s\n", GetClassname(), STRING(m_target));
|
||||
}
|
||||
else
|
||||
{
|
||||
StartTargetHandling( GetGoalEnt() );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//---------------------------------------------------------
|
||||
|
@ -1117,6 +1117,9 @@ public:
|
||||
CBaseEntity *GetEnemyOccluder(void);
|
||||
|
||||
virtual void StartTargetHandling( CBaseEntity *pTargetEnt );
|
||||
#ifdef MAPBASE
|
||||
void InputSetTarget( inputdata_t &inputdata );
|
||||
#endif
|
||||
|
||||
//---------------------------------
|
||||
|
||||
|
@ -125,6 +125,9 @@ bool CAI_RappelBehavior::KeyValue( const char *szKeyName, const char *szValue )
|
||||
|
||||
void CAI_RappelBehavior::Precache()
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
CBaseEntity::PrecacheModel( "cable/cable_rappel.vmt" );
|
||||
#endif
|
||||
CBaseEntity::PrecacheModel( "cable/cable.vmt" );
|
||||
}
|
||||
|
||||
@ -386,7 +389,11 @@ void CAI_RappelBehavior::CreateZipline()
|
||||
if( attachment > 0 )
|
||||
{
|
||||
CBeam *pBeam;
|
||||
#ifdef MAPBASE
|
||||
pBeam = CBeam::BeamCreate( "cable/cable_rappel.vmt", 1 );
|
||||
#else
|
||||
pBeam = CBeam::BeamCreate( "cable/cable.vmt", 1 );
|
||||
#endif
|
||||
pBeam->SetColor( 150, 150, 150 );
|
||||
pBeam->SetWidth( 0.3 );
|
||||
pBeam->SetEndWidth( 0.3 );
|
||||
|
@ -157,6 +157,7 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatCharacter, CBaseFlex, "The base class shared by
|
||||
DEFINE_SCRIPTFUNC( WeaponCount, "Get the number of weapons a character possesses." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptWeaponIndex, "GetWeapon", "Get a specific weapon in the character's inventory." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptWeaponByType, "FindWeapon", "Find a specific weapon in the character's inventory by its classname." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( GetScriptAllWeapons, "GetAllWeapons", "Get the character's weapon inventory." )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( Weapon_ShootPosition, "ShootPosition", "Get the character's shoot position." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( Weapon_DropAll, "DropAllWeapons", "Make the character drop all of its weapons." )
|
||||
@ -4377,6 +4378,19 @@ HSCRIPT CBaseCombatCharacter::GetScriptWeaponByType( const char *pszWeapon, int
|
||||
return ToHScript( Weapon_OwnsThisType( pszWeapon, iSubType ) );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseCombatCharacter::GetScriptAllWeapons( HSCRIPT hTable )
|
||||
{
|
||||
for (int i=0;i<MAX_WEAPONS;i++)
|
||||
{
|
||||
if (m_hMyWeapons[i])
|
||||
{
|
||||
g_pScriptVM->SetValue( hTable, m_hMyWeapons[i]->GetClassname(), ToHScript( m_hMyWeapons[i] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
void CBaseCombatCharacter::ScriptEquipWeapon( HSCRIPT hWeapon )
|
||||
|
@ -414,6 +414,7 @@ public:
|
||||
HSCRIPT GetScriptActiveWeapon();
|
||||
HSCRIPT GetScriptWeaponIndex( int i );
|
||||
HSCRIPT GetScriptWeaponByType( const char *pszWeapon, int iSubType = 0 );
|
||||
void GetScriptAllWeapons( HSCRIPT hTable );
|
||||
|
||||
void ScriptEquipWeapon( HSCRIPT hWeapon );
|
||||
|
||||
|
@ -2210,11 +2210,15 @@ BEGIN_ENT_SCRIPTDESC_ROOT( CBaseEntity, "Root class of all server-side entities"
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptTakeDamage, "TakeDamage", "Apply damage to this entity with a given info handle" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptFireBullets, "FireBullets", "Fire bullets from entity with a given info handle" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( TakeHealth, "Give this entity health" )
|
||||
DEFINE_SCRIPTFUNC( IsAlive, "Return true if this entity is alive" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetContext, "GetContext", "Get a response context value" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptAddContext, "AddContext", "Add a response context value" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptClassify, "Classify", "Get Class_T class ID" )
|
||||
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptAddOutput, "AddOutput", "Add an output" )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetKeyValue, "GetKeyValue", "Get a keyvalue" )
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSpawnFlags, "Get spawnflags" )
|
||||
@ -9605,6 +9609,14 @@ int CBaseEntity::ScriptClassify( void )
|
||||
return (int)Classify();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CBaseEntity::ScriptAddOutput( const char *pszOutputName, const char *pszTarget, const char *pszAction, const char *pszParameter, float flDelay, int iMaxTimes )
|
||||
{
|
||||
const char *pszValue = UTIL_VarArgs("%s,%s,%s,%f,%i", pszTarget, pszAction, pszParameter, flDelay, iMaxTimes);
|
||||
return KeyValue( pszOutputName, pszValue );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBaseEntity::ScriptGetKeyValue( const char *pszKeyName )
|
||||
|
@ -2018,6 +2018,7 @@ public:
|
||||
|
||||
int ScriptClassify(void);
|
||||
|
||||
bool ScriptAddOutput( const char *pszOutputName, const char *pszTarget, const char *pszAction, const char *pszParameter, float flDelay, int iMaxTimes );
|
||||
const char *ScriptGetKeyValue( const char *pszKeyName );
|
||||
#endif
|
||||
|
||||
|
@ -1594,6 +1594,7 @@ BEGIN_DATADESC( CEnvWind )
|
||||
#ifdef MAPBASE
|
||||
DEFINE_KEYFIELD( m_EnvWindShared.m_windRadius, FIELD_FLOAT, "windradius" ),
|
||||
DEFINE_KEYFIELD( m_EnvWindShared.m_windRadiusInner, FIELD_FLOAT, "windradiusinner" ),
|
||||
DEFINE_KEYFIELD( m_EnvWindShared.m_flTreeSwayScale, FIELD_FLOAT, "treeswayscale" ),
|
||||
#endif
|
||||
|
||||
// Just here to quiet down classcheck
|
||||
@ -1602,6 +1603,20 @@ BEGIN_DATADESC( CEnvWind )
|
||||
DEFINE_FIELD( m_EnvWindShared.m_iWindDir, FIELD_INTEGER ),
|
||||
DEFINE_FIELD( m_EnvWindShared.m_flWindSpeed, FIELD_FLOAT ),
|
||||
|
||||
#ifdef MAPBASE
|
||||
DEFINE_INPUT( m_EnvWindShared.m_iMinWind, FIELD_INTEGER, "SetMinWind" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_iMaxWind, FIELD_INTEGER, "SetMaxWind" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_iMinGust, FIELD_INTEGER, "SetMinGust" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_iMaxGust, FIELD_INTEGER, "SetMaxGust" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_flMinGustDelay, FIELD_FLOAT, "SetMinGustDelay" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_flMaxGustDelay, FIELD_FLOAT, "SetMaxGustDelay" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_iGustDirChange, FIELD_INTEGER, "SetGustDirChange" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_flGustDuration, FIELD_FLOAT, "SetGustDuration" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_windRadius, FIELD_FLOAT, "SetWindRadius" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_windRadiusInner, FIELD_FLOAT, "SetWindRadiusInner" ),
|
||||
DEFINE_INPUT( m_EnvWindShared.m_flTreeSwayScale, FIELD_FLOAT, "SetTreeSwayScale" ),
|
||||
#endif
|
||||
|
||||
DEFINE_OUTPUT( m_EnvWindShared.m_OnGustStart, "OnGustStart" ),
|
||||
DEFINE_OUTPUT( m_EnvWindShared.m_OnGustEnd, "OnGustEnd" ),
|
||||
|
||||
@ -1634,6 +1649,7 @@ BEGIN_SEND_TABLE_NOBASE(CEnvWindShared, DT_EnvWindShared)
|
||||
SendPropFloat (SENDINFO(m_windRadius), 0, SPROP_NOSCALE),
|
||||
SendPropFloat (SENDINFO(m_windRadiusInner), 0, SPROP_NOSCALE),
|
||||
SendPropVector (SENDINFO(m_location), -1, SPROP_COORD),
|
||||
SendPropFloat (SENDINFO(m_flTreeSwayScale), 0, SPROP_NOSCALE),
|
||||
#endif
|
||||
END_SEND_TABLE()
|
||||
|
||||
|
@ -1055,7 +1055,12 @@ void CNPC_MetroPolice::SpeakSentence( int nSentenceType )
|
||||
{
|
||||
if ( SpeakIfAllowed( TLK_COP_PLAYERHIT, SENTENCE_PRIORITY_HIGH ) )
|
||||
{
|
||||
#ifdef MAPBASE
|
||||
if (GetSquad())
|
||||
GetSquad()->SquadRemember(bits_MEMORY_PLAYER_HURT);
|
||||
#else
|
||||
m_pSquad->SquadRemember(bits_MEMORY_PLAYER_HURT);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,10 +115,8 @@ public:
|
||||
void HandleAnimEvent( animevent_t *pEvent );
|
||||
|
||||
// Inputs
|
||||
#ifndef MAPBASE
|
||||
void InputEnterVehicleImmediate( inputdata_t &inputdata );
|
||||
void InputEnterVehicle( inputdata_t &inputdata );
|
||||
#endif
|
||||
void InputExitVehicle( inputdata_t &inputdata );
|
||||
void InputLock( inputdata_t &inputdata );
|
||||
void InputUnlock( inputdata_t &inputdata );
|
||||
@ -190,10 +188,8 @@ BEGIN_DATADESC( CPropVehiclePrisonerPod )
|
||||
// Inputs
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "Lock", InputLock ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "Unlock", InputUnlock ),
|
||||
#ifndef MAPBASE
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicle", InputEnterVehicle ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "EnterVehicleImmediate", InputEnterVehicleImmediate ),
|
||||
#endif
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "ExitVehicle", InputExitVehicle ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "Open", InputOpen ),
|
||||
DEFINE_INPUTFUNC( FIELD_VOID, "Close", InputClose ),
|
||||
@ -587,7 +583,6 @@ void CPropVehiclePrisonerPod::InputUnlock( inputdata_t &inputdata )
|
||||
}
|
||||
|
||||
|
||||
#ifndef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Force the player to enter the vehicle.
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -650,7 +645,6 @@ void CPropVehiclePrisonerPod::InputEnterVehicleImmediate( inputdata_t &inputdata
|
||||
Assert( 0 );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Force the player to exit the vehicle.
|
||||
|
@ -980,7 +980,7 @@ void CBasePlayer::TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &v
|
||||
// --------------------------------------------------
|
||||
CAI_BaseNPC *pNPC = info.GetAttacker()->MyNPCPointer();
|
||||
#ifdef MAPBASE
|
||||
if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) <= D_FR )
|
||||
if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) > D_FR )
|
||||
#else
|
||||
if ( pNPC && (pNPC->CapabilitiesGet() & bits_CAP_NO_HIT_PLAYER) && pNPC->IRelationType( this ) != D_HT )
|
||||
#endif
|
||||
|
@ -55,6 +55,9 @@ BEGIN_DATADESC( CPointTemplate )
|
||||
DEFINE_KEYFIELD( m_iszTemplateEntityNames[14], FIELD_STRING, "Template15"),
|
||||
DEFINE_KEYFIELD( m_iszTemplateEntityNames[15], FIELD_STRING, "Template16"),
|
||||
DEFINE_UTLVECTOR( m_hTemplateEntities, FIELD_CLASSPTR ),
|
||||
#ifdef MAPBASE
|
||||
DEFINE_KEYFIELD( m_bFixupExpanded, FIELD_BOOLEAN, "FixupMode" ),
|
||||
#endif
|
||||
|
||||
DEFINE_UTLVECTOR( m_hTemplates, FIELD_EMBEDDED ),
|
||||
|
||||
|
@ -46,6 +46,9 @@ public:
|
||||
void AddTemplate( CBaseEntity *pEntity, const char *pszMapData, int nLen );
|
||||
bool ShouldRemoveTemplateEntities( void );
|
||||
bool AllowNameFixup();
|
||||
#ifdef MAPBASE
|
||||
bool NameFixupExpanded() { return m_bFixupExpanded; }
|
||||
#endif
|
||||
|
||||
// Templates accessors
|
||||
int GetNumTemplates( void );
|
||||
@ -74,6 +77,12 @@ private:
|
||||
// code removes all the entities in it once it finishes turning them into templates.
|
||||
CUtlVector< CBaseEntity * > m_hTemplateEntities;
|
||||
|
||||
#ifdef MAPBASE
|
||||
// Allows name fixup to target all instances of a name in a keyvalue, including output parameters.
|
||||
// TODO: Support for multiple fixup modes?
|
||||
bool m_bFixupExpanded;
|
||||
#endif
|
||||
|
||||
// List of templates, generated from our template entities.
|
||||
CUtlVector< template_t > m_hTemplates;
|
||||
|
||||
|
@ -24,6 +24,21 @@ Ammo_t *CAmmoDef::GetAmmoOfIndex(int nAmmoIndex)
|
||||
return &m_AmmoType[ nAmmoIndex ];
|
||||
}
|
||||
|
||||
#ifdef MAPBASE
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
// Output :
|
||||
//-----------------------------------------------------------------------------
|
||||
const char* CAmmoDef::Name(int nAmmoIndex)
|
||||
{
|
||||
if ( nAmmoIndex < 1 || nAmmoIndex >= m_nAmmoIndex )
|
||||
return NULL;
|
||||
|
||||
return m_AmmoType[nAmmoIndex].pName;
|
||||
}
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
// Input :
|
||||
@ -292,4 +307,22 @@ CAmmoDef::~CAmmoDef( void )
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
BEGIN_SCRIPTDESC_ROOT( CAmmoDef, SCRIPT_SINGLETON "The ammo type definition manager." )
|
||||
|
||||
DEFINE_SCRIPTFUNC( Name, "Gets the name of the specified ammo type index." )
|
||||
DEFINE_SCRIPTFUNC( Index, "Gets the index of the specified ammo type name." )
|
||||
DEFINE_SCRIPTFUNC( PlrDamage, "Gets the damage players deal for the specified ammo type." )
|
||||
DEFINE_SCRIPTFUNC( NPCDamage, "Gets the damage NPCs deal for the specified ammo type." )
|
||||
DEFINE_SCRIPTFUNC( MaxCarry, "Gets the maximum amount of this ammo type which players should be able to carry." )
|
||||
DEFINE_SCRIPTFUNC( DamageType, "Gets the type of damage this ammo type deals." )
|
||||
DEFINE_SCRIPTFUNC( TracerType, "Gets the type of tracer this ammo type uses." )
|
||||
DEFINE_SCRIPTFUNC( DamageForce, "Gets the amount of force this ammo type deals." )
|
||||
DEFINE_SCRIPTFUNC( MinSplashSize, "Gets the minimum size of water splashes caused by impacts from this ammo type." )
|
||||
DEFINE_SCRIPTFUNC( MaxSplashSize, "Gets the maximum size of water splashes caused by impacts from this ammo type." )
|
||||
DEFINE_SCRIPTFUNC( Flags, "Gets the flags this ammo type uses." )
|
||||
|
||||
END_SCRIPTDESC();
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -72,6 +72,9 @@ public:
|
||||
Ammo_t m_AmmoType[MAX_AMMO_TYPES];
|
||||
|
||||
Ammo_t *GetAmmoOfIndex(int nAmmoIndex);
|
||||
#ifdef MAPBASE
|
||||
const char* Name(int nAmmoIndex);
|
||||
#endif
|
||||
int Index(const char *psz);
|
||||
int PlrDamage(int nAmmoIndex);
|
||||
int NPCDamage(int nAmmoIndex);
|
||||
|
@ -1801,22 +1801,6 @@ void CBaseCombatWeapon::InputHideWeapon( inputdata_t &inputdata )
|
||||
SetWeaponVisible( false );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBaseCombatWeapon::ScriptGetPrimaryAmmoType()
|
||||
{
|
||||
return GetPrimaryAmmoType() <= GetAmmoDef()->m_nAmmoIndex ? GetAmmoDef()->m_AmmoType[GetPrimaryAmmoType()].pName : NULL;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------
|
||||
const char *CBaseCombatWeapon::ScriptGetSecondaryAmmoType()
|
||||
{
|
||||
return GetSecondaryAmmoType() <= GetAmmoDef()->m_nAmmoIndex ? GetAmmoDef()->m_AmmoType[GetSecondaryAmmoType()].pName : NULL;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2910,8 +2894,8 @@ BEGIN_ENT_SCRIPTDESC( CBaseCombatWeapon, CBaseAnimating, "The base class for all
|
||||
DEFINE_SCRIPTFUNC( UsesClipsForAmmo2, "Check if the weapon uses clips for secondary ammo." )
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetPrimaryAmmoType, "GetPrimaryAmmoType", "Get the weapon's primary ammo type." )
|
||||
DEFINE_SCRIPTFUNC_NAMED( ScriptGetSecondaryAmmoType, "GetSecondaryAmmoType", "Get the weapon's secondary ammo type." )
|
||||
DEFINE_SCRIPTFUNC( GetPrimaryAmmoType, "Get the weapon's primary ammo type." )
|
||||
DEFINE_SCRIPTFUNC( GetSecondaryAmmoType, "Get the weapon's secondary ammo type." )
|
||||
#endif
|
||||
|
||||
DEFINE_SCRIPTFUNC( GetSubType, "Get the weapon's subtype." )
|
||||
|
@ -519,11 +519,6 @@ public:
|
||||
|
||||
virtual CDmgAccumulator *GetDmgAccumulator( void ) { return NULL; }
|
||||
|
||||
#ifdef MAPBASE_VSCRIPT
|
||||
const char* ScriptGetPrimaryAmmoType();
|
||||
const char* ScriptGetSecondaryAmmoType();
|
||||
#endif
|
||||
|
||||
// Client only methods
|
||||
#else
|
||||
|
||||
|
@ -70,6 +70,9 @@
|
||||
#include "IEffects.h"
|
||||
#include "engine/IEngineSound.h"
|
||||
#include "sharedInterface.h"
|
||||
#ifdef CLIENT_DLL
|
||||
#include "renderparm.h"
|
||||
#endif
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
@ -89,6 +92,7 @@ CEnvWindShared::CEnvWindShared() : m_WindAveQueue(10), m_WindVariationQueue(10)
|
||||
#ifdef MAPBASE
|
||||
s_windControllers.AddToTail( this );
|
||||
m_windRadius = -1.0f;
|
||||
m_flTreeSwayScale = 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -180,6 +184,31 @@ void CEnvWindShared::UpdateWindSound( float flTotalWindSpeed )
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAPBASE
|
||||
#define TREE_SWAY_UPDATE_TIME 2.0f
|
||||
|
||||
void CEnvWindShared::UpdateTreeSway( float flTime )
|
||||
{
|
||||
#ifdef CLIENT_DLL
|
||||
while( flTime >= m_flSwayTime )
|
||||
{
|
||||
// Since the wind is constantly changing, but we need smooth values, we cache them off here.
|
||||
m_PrevSwayVector = m_CurrentSwayVector;
|
||||
m_CurrentSwayVector = m_flTreeSwayScale != 1.0f ? (m_currentWindVector * m_flTreeSwayScale) : m_currentWindVector;
|
||||
m_flSwayTime += TREE_SWAY_UPDATE_TIME;
|
||||
}
|
||||
|
||||
// Update vertex shader
|
||||
float flPercentage = ( 1 - ( ( m_flSwayTime - flTime ) / TREE_SWAY_UPDATE_TIME ) );
|
||||
CMatRenderContextPtr pRenderContext( g_pMaterialSystem );
|
||||
// Dividing by 2 helps the numbers the shader is expecting stay in line with other expected game values.
|
||||
Vector vecWind = Lerp( flPercentage, m_PrevSwayVector, m_CurrentSwayVector ) / 25.f;
|
||||
pRenderContext->SetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION, vecWind );
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Updates the wind speed
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -196,6 +225,14 @@ float CEnvWindShared::WindThink( float flTime )
|
||||
|
||||
ComputeWindVariation( flTime );
|
||||
|
||||
#if defined(MAPBASE) && defined(CLIENT_DLL)
|
||||
if (m_flTreeSwayScale != 0.0f)
|
||||
{
|
||||
// Update Tree Sway
|
||||
UpdateTreeSway( flTime );
|
||||
}
|
||||
#endif
|
||||
|
||||
while (true)
|
||||
{
|
||||
// First, simulate up to the next switch time...
|
||||
|
@ -183,6 +183,10 @@ public:
|
||||
|
||||
#ifdef MAPBASE
|
||||
Vector m_currentWindVector; // For all the talk of proper prediction, we ended up just storing and returning through a static vector. Now we can have multiple env_wind, so we need this in here.
|
||||
Vector m_CurrentSwayVector;
|
||||
Vector m_PrevSwayVector;
|
||||
|
||||
CNetworkVar( float, m_flTreeSwayScale );
|
||||
#endif
|
||||
|
||||
CNetworkVar( int, m_iInitialWindDir );
|
||||
@ -211,7 +215,12 @@ private:
|
||||
// Updates the wind sound
|
||||
void UpdateWindSound( float flTotalWindSpeed );
|
||||
|
||||
#ifdef MAPBASE
|
||||
void UpdateTreeSway( float flTime );
|
||||
#endif
|
||||
|
||||
float m_flVariationTime;
|
||||
float m_flSwayTime;
|
||||
float m_flSimTime; // What's the time I last simulated up to?
|
||||
float m_flSwitchTime; // when do I actually switch from gust to not gust
|
||||
float m_flAveWindSpeed; // the average wind speed
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "cbase.h"
|
||||
#include "matchers.h"
|
||||
#include "takedamageinfo.h"
|
||||
#include "ammodef.h"
|
||||
|
||||
#ifndef CLIENT_DLL
|
||||
#include "globalstate.h"
|
||||
@ -752,6 +753,19 @@ FireBulletsInfo_t *GetFireBulletsInfoFromInfo( HSCRIPT hBulletsInfo )
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
static int ScriptPrecacheModel( const char *modelname )
|
||||
{
|
||||
return CBaseEntity::PrecacheModel( modelname );
|
||||
}
|
||||
|
||||
static void ScriptPrecacheOther( const char *classname )
|
||||
{
|
||||
UTIL_PrecacheOther( classname );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
static void ScriptEntitiesInBox( HSCRIPT hTable, int listMax, const Vector &hullMin, const Vector &hullMax, int iMask )
|
||||
{
|
||||
CBaseEntity *list[1024];
|
||||
@ -785,6 +799,14 @@ static void ScriptEntitiesInSphere( HSCRIPT hTable, int listMax, const Vector &c
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void ScriptDecalTrace( HSCRIPT hTrace, const char *decalName )
|
||||
{
|
||||
CTraceInfoAccessor *traceInfo = HScriptToClass<CTraceInfoAccessor>(hTrace);
|
||||
UTIL_DecalTrace( &traceInfo->GetTrace(), decalName );
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
//=============================================================================
|
||||
|
||||
@ -813,6 +835,8 @@ void RegisterSharedScriptFunctions()
|
||||
ScriptRegisterFunction( g_pScriptVM, SpawnEntityFromTable, "Native function for entity spawning." );
|
||||
#endif
|
||||
|
||||
g_pScriptVM->RegisterInstance( GetAmmoDef(), "AmmoDef" );
|
||||
|
||||
g_pScriptVM->RegisterInstance( &g_ScriptConvarLookup, "Convars" );
|
||||
g_pScriptVM->RegisterInstance( &g_ScriptNetPropManager, "NetProps" );
|
||||
|
||||
@ -839,10 +863,23 @@ void RegisterSharedScriptFunctions()
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceLineComplex, "TraceLineComplex", "Complex version of TraceLine which takes 2 points, an ent to ignore, a trace mask, and a collision group. Returns a handle which can access all trace info." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptTraceHullComplex, "TraceHullComplex", "Takes 2 points, min/max hull bounds, an ent to ignore, a trace mask, and a collision group to trace to a point using a hull. Returns a handle which can access all trace info." );
|
||||
|
||||
//
|
||||
// Precaching
|
||||
//
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptPrecacheModel, "PrecacheModel", "Precaches a model for later usage." );
|
||||
ScriptRegisterFunction( g_pScriptVM, PrecacheMaterial, "Precaches a material for later usage." );
|
||||
ScriptRegisterFunction( g_pScriptVM, PrecacheParticleSystem, "Precaches a particle system for later usage." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptPrecacheOther, "PrecacheOther", "Precaches an entity class for later usage." );
|
||||
|
||||
//
|
||||
// Misc. Utility
|
||||
//
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesInBox, "EntitiesInBox", "Gets all entities which are within a worldspace box." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesAtPoint, "EntitiesAtPoint", "Gets all entities which are intersecting a point in space." );
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptEntitiesInSphere, "EntitiesInSphere", "Gets all entities which are within a sphere." );
|
||||
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptDecalTrace, "DecalTrace", "Creates a dynamic decal based on the given trace info. The trace information can be generated by TraceLineComplex() and the decal name must be from decals_subrect.txt." );
|
||||
|
||||
ScriptRegisterFunctionNamed( g_pScriptVM, ScriptMatcherMatch, "Matcher_Match", "Compares a string to a query using Mapbase's matcher system, supporting wildcards, RS matchers, etc." );
|
||||
ScriptRegisterFunction( g_pScriptVM, Matcher_NamesMatch, "Compares a string to a query using Mapbase's matcher system using wildcards only." );
|
||||
ScriptRegisterFunction( g_pScriptVM, AppearsToBeANumber, "Checks if the given string appears to be a number." );
|
||||
|
@ -1,6 +1,7 @@
|
||||
// STATIC: "ONLY_PROJECT_POSITION" "0..1" [XBOX]
|
||||
// STATIC: "ONLY_PROJECT_POSITION" "0..0" [PC]
|
||||
// STATIC: "COLOR_DEPTH" "0..1"
|
||||
// STATIC: "TREESWAY" "0..2"
|
||||
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "SKINNING" "0..1"
|
||||
@ -19,6 +20,37 @@ const float4 cMorphSubrect : register( SHADER_SPECIFIC_CONST_7 );
|
||||
sampler2D morphSampler : register( D3DVERTEXTEXTURESAMPLER0, s0 );
|
||||
#endif
|
||||
|
||||
#if ( TREESWAY )
|
||||
const float4 g_vTreeSwayParams0 : register( SHADER_SPECIFIC_CONST_2 );
|
||||
const float4 g_vTreeSwayParams1 : register( SHADER_SPECIFIC_CONST_3 );
|
||||
const float4 g_vTreeSwayParams2 : register( SHADER_SPECIFIC_CONST_4 );
|
||||
const float4 g_vTreeSwayParams3 : register( SHADER_SPECIFIC_CONST_5 );
|
||||
const float4 g_vTreeSwayParams4 : register( SHADER_SPECIFIC_CONST_9 );
|
||||
|
||||
#define g_flTime g_vTreeSwayParams0.x
|
||||
#define g_vWindDir g_vTreeSwayParams0.yz
|
||||
|
||||
#define g_flScrumbleFalloffCurve g_vTreeSwayParams1.x
|
||||
#define g_flSwayFalloffCurve g_vTreeSwayParams1.y
|
||||
#define g_flScrumbleSpeed g_vTreeSwayParams1.z
|
||||
#define g_flFastSwaySpeedScale g_vTreeSwayParams1.w
|
||||
|
||||
|
||||
#define g_flHeight g_vTreeSwayParams2.x
|
||||
#define g_flStartHeight g_vTreeSwayParams2.y
|
||||
#define g_flRadius g_vTreeSwayParams2.z
|
||||
#define g_flStartRadius g_vTreeSwayParams2.w
|
||||
|
||||
#define g_flSwaySpeed g_vTreeSwayParams3.x
|
||||
#define g_flSwayIntensity g_vTreeSwayParams3.y
|
||||
#define g_flScrumbleWaveCount g_vTreeSwayParams3.z
|
||||
#define g_flScrumbleIntensity g_vTreeSwayParams3.w
|
||||
|
||||
#define g_flWindSpeedLerpStart g_vTreeSwayParams4.x
|
||||
#define g_flWindSpeedLerpEnd g_vTreeSwayParams4.y
|
||||
|
||||
#include "tree_sway.h"
|
||||
#endif
|
||||
|
||||
struct VS_INPUT
|
||||
{
|
||||
@ -62,6 +94,12 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
v.vVertexID, float3(0, 0, 0), vPosition.xyz );
|
||||
#endif
|
||||
|
||||
#if ( TREESWAY )
|
||||
{
|
||||
vPosition.xyz = ComputeTreeSway( vPosition.xyz, g_flTime );
|
||||
}
|
||||
#endif
|
||||
|
||||
SkinPosition( g_bSkinning, vPosition, v.vBoneWeights, v.vBoneIndices, vWorldPos );
|
||||
|
||||
float4 vProjPos = mul( float4( vWorldPos, 1.0f ), cViewProj );
|
||||
|
@ -11,6 +11,7 @@
|
||||
// STATIC: "SM30_VERTEXID" "0..1" [vs30]
|
||||
// STATIC: "USE_STATIC_CONTROL_FLOW" "0..1" [vs20]
|
||||
// STATIC: "DONT_GAMMA_CONVERT_VERTEX_COLOR" "0..1"
|
||||
// STATIC: "TREESWAY" "0..2"
|
||||
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
||||
// DYNAMIC: "DYNAMIC_LIGHT" "0..1"
|
||||
// DYNAMIC: "STATIC_LIGHT" "0..1"
|
||||
@ -25,6 +26,7 @@
|
||||
// SKIP: $USE_STATIC_CONTROL_FLOW && ( $NUM_LIGHTS > 0 ) [vs20]
|
||||
// SKIP: ($SEPARATE_DETAIL_UVS) && ($SEAMLESS_DETAIL)
|
||||
// SKIP: ($DONT_GAMMA_CONVERT_VERTEX_COLOR && ( ! $VERTEXCOLOR ) )
|
||||
// SKIP: ( $TREESWAY ) && ( $SEAMLESS_DETAIL || $SEAMLESS_BASE )
|
||||
#include "common_vs_fxc.h"
|
||||
|
||||
static const bool g_bSkinning = SKINNING ? true : false;
|
||||
@ -51,6 +53,34 @@ const float4 cDetailTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 );
|
||||
const float4x4 g_FlashlightWorldToTexture : register( SHADER_SPECIFIC_CONST_6 ); // 6, 7, 8, 9
|
||||
#endif
|
||||
|
||||
#if ( TREESWAY )
|
||||
const float4 g_vMiscParams1 : register( SHADER_SPECIFIC_CONST_6 );
|
||||
const float4 g_vMiscParams2 : register( SHADER_SPECIFIC_CONST_7 );
|
||||
const float4 g_vMiscParams3 : register( SHADER_SPECIFIC_CONST_8 );
|
||||
const float4 g_vMiscParams4 : register( SHADER_SPECIFIC_CONST_9 );
|
||||
#define g_flTime g_vMiscParams2.y
|
||||
#define g_vWindDir g_vMiscParams2.zw
|
||||
|
||||
#define g_flFastSwaySpeedScale g_vMiscParams1.x
|
||||
#define g_flScrumbleFalloffCurve g_vMiscParams1.y
|
||||
#define g_flSwayFalloffCurve g_vMiscParams1.z
|
||||
#define g_flScrumbleSpeed g_vMiscParams1.w
|
||||
|
||||
#define g_flHeight g_vMiscParams3.x
|
||||
#define g_flStartHeight g_vMiscParams3.y
|
||||
#define g_flRadius g_vMiscParams3.z
|
||||
#define g_flStartRadius g_vMiscParams3.w
|
||||
|
||||
#define g_flSwaySpeed g_vMiscParams4.x
|
||||
#define g_flSwayIntensity g_vMiscParams4.y
|
||||
#define g_flScrumbleWaveCount g_vMiscParams4.z
|
||||
#define g_flScrumbleIntensity g_vMiscParams4.w
|
||||
|
||||
#define g_flWindSpeedLerpStart cDetailTexCoordTransform[0].x
|
||||
#define g_flWindSpeedLerpEnd cDetailTexCoordTransform[0].y
|
||||
#include "tree_sway.h"
|
||||
#endif
|
||||
|
||||
#if defined( SHADER_MODEL_VS_3_0 ) && SM30_VERTEXID
|
||||
// NOTE: cMorphTargetTextureDim.xy = target dimensions,
|
||||
// cMorphTargetTextureDim.z = 4tuples/morph
|
||||
@ -150,6 +180,10 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
v.vVertexID, v.vTexCoord2, vPosition.xyz, vNormal );
|
||||
#endif
|
||||
|
||||
#if ( TREESWAY )
|
||||
vPosition.xyz = ComputeTreeSway( vPosition.xyz, g_flTime );
|
||||
#endif
|
||||
|
||||
// Perform skinning
|
||||
float3 worldNormal, worldPos;
|
||||
SkinPositionAndNormal(
|
||||
@ -225,10 +259,18 @@ VS_OUTPUT main( const VS_INPUT v )
|
||||
// that scale works. More smartness could allow 3d xform.
|
||||
o.SeamlessDetailTexCoord.xyz = (SEAMLESS_SCALE*cDetailTexCoordTransform[0].x) * v.vPos.xyz;
|
||||
#else
|
||||
#if ( TREESWAY )
|
||||
{
|
||||
o.detailTexCoord.xy = v.vTexCoord0;
|
||||
}
|
||||
#else
|
||||
{
|
||||
// Detail texture coordinates
|
||||
// FIXME: This shouldn't have to be computed all the time.
|
||||
o.detailTexCoord.x = dot( v.vTexCoord0, cDetailTexCoordTransform[0] );
|
||||
o.detailTexCoord.y = dot( v.vTexCoord0, cDetailTexCoordTransform[1] );
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if SEPARATE_DETAIL_UVS
|
||||
|
@ -22,6 +22,25 @@ BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITAB
|
||||
BEGIN_SHADER_PARAMS
|
||||
SHADER_PARAM( ALPHATESTREFERENCE, SHADER_PARAM_TYPE_FLOAT, "", "Alpha reference value" )
|
||||
SHADER_PARAM( COLOR_DEPTH, SHADER_PARAM_TYPE_BOOL, "0", "Write depth as color")
|
||||
|
||||
// vertexlitgeneric tree sway animation control
|
||||
SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTHEIGHT, SHADER_PARAM_TYPE_FLOAT, "0.2", "" )
|
||||
SHADER_PARAM( TREESWAYRADIUS, SHADER_PARAM_TYPE_FLOAT, "300", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTRADIUS, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEED, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDHIGHWINDMULTIPLIER, SHADER_PARAM_TYPE_FLOAT, "2", "" )
|
||||
SHADER_PARAM( TREESWAYSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "10", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESPEED, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFREQUENCY, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.5", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" )
|
||||
SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
@ -46,6 +65,7 @@ BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITAB
|
||||
{
|
||||
bool bAlphaClip = IS_FLAG_SET( MATERIAL_VAR_ALPHATEST );
|
||||
int nColorDepth = GetIntParam( COLOR_DEPTH, params, 0 );
|
||||
int nTreeSwayMode = clamp( GetIntParam( TREESWAY, params, 0 ), 0, 2 );
|
||||
|
||||
SHADOW_STATE
|
||||
{
|
||||
@ -79,6 +99,7 @@ BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITAB
|
||||
DECLARE_STATIC_VERTEX_SHADER( sdk_depthwrite_vs20 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( ONLY_PROJECT_POSITION, !bAlphaClip && IsX360() && !nColorDepth ); //360 needs to know if it *shouldn't* output texture coordinates to avoid shader patches
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( COLOR_DEPTH, nColorDepth );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, nTreeSwayMode );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_depthwrite_vs20 );
|
||||
|
||||
if ( bAlphaClip || g_pHardwareConfig->PlatformRequiresNonNullPixelShaders() || nColorDepth )
|
||||
@ -111,6 +132,7 @@ BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITAB
|
||||
DECLARE_STATIC_VERTEX_SHADER( sdk_depthwrite_vs30 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( ONLY_PROJECT_POSITION, 0 ); //360 only combo, and this is a PC path
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( COLOR_DEPTH, nColorDepth );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, nTreeSwayMode );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_depthwrite_vs30 );
|
||||
|
||||
pShaderShadow->EnableTexture( SHADER_SAMPLER0, true );
|
||||
@ -190,6 +212,50 @@ BEGIN_VS_SHADER_FLAGS( SDK_DepthWrite, "Help for Depth Write", SHADER_NOT_EDITAB
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( nTreeSwayMode != 0 )
|
||||
{
|
||||
float flParams[4];
|
||||
|
||||
flParams[0] = pShaderAPI->CurrentTime();
|
||||
if (params[TREESWAYSTATIC]->GetIntValue() == 0)
|
||||
{
|
||||
const Vector& windDir = pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION );
|
||||
flParams[1] = windDir.x;
|
||||
flParams[2] = windDir.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use a static value instead of the env_wind value.
|
||||
params[TREESWAYSTATICVALUES]->GetVecValue( flParams + 1, 2 );
|
||||
}
|
||||
flParams[3] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_2, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( TREESWAYSCRUMBLEFALLOFFEXP, params, 1.0f );
|
||||
flParams[1] = GetFloatParam( TREESWAYFALLOFFEXP, params, 1.0f );
|
||||
flParams[2] = GetFloatParam( TREESWAYSCRUMBLESPEED, params, 3.0f );
|
||||
flParams[3] = GetFloatParam( TREESWAYSPEEDHIGHWINDMULTIPLIER, params, 2.0f );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_3, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( TREESWAYHEIGHT, params, 1000.0f );
|
||||
flParams[1] = GetFloatParam( TREESWAYSTARTHEIGHT, params, 0.1f );
|
||||
flParams[2] = GetFloatParam( TREESWAYRADIUS, params, 300.0f );
|
||||
flParams[3] = GetFloatParam( TREESWAYSTARTRADIUS, params, 0.2f );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( TREESWAYSPEED, params, 1.0f );
|
||||
flParams[1] = GetFloatParam( TREESWAYSTRENGTH, params, 10.0f );
|
||||
flParams[2] = GetFloatParam( TREESWAYSCRUMBLEFREQUENCY, params, 12.0f );
|
||||
flParams[3] = GetFloatParam( TREESWAYSCRUMBLESTRENGTH, params, 10.0f );
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_5, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( TREESWAYSPEEDLERPSTART, params, 3.0f );
|
||||
flParams[1] = GetFloatParam( TREESWAYSPEEDLERPEND, params, 6.0f );
|
||||
flParams[2] = 0.0f;
|
||||
flParams[3] = 0.0f;
|
||||
pShaderAPI->SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_9, flParams );
|
||||
}
|
||||
|
||||
Vector4D vParms;
|
||||
|
||||
// set up arbitrary far planes, as the real ones are too far ( 30,000 )
|
||||
|
@ -43,6 +43,27 @@ public:
|
||||
m_bCOLOR_DEPTH = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_depthwrite_vs20_Static_Index( )
|
||||
{
|
||||
@ -54,19 +75,23 @@ public:
|
||||
m_bCOLOR_DEPTH = false;
|
||||
#endif // _DEBUG
|
||||
m_nCOLOR_DEPTH = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH;
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + 0;
|
||||
return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + ( 8 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0
|
||||
#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_depthwrite_vs20_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -43,6 +43,27 @@ public:
|
||||
m_bCOLOR_DEPTH = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_depthwrite_vs30_Static_Index( )
|
||||
{
|
||||
@ -54,19 +75,23 @@ public:
|
||||
m_bCOLOR_DEPTH = false;
|
||||
#endif // _DEBUG
|
||||
m_nCOLOR_DEPTH = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH;
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + 0;
|
||||
return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + ( 16 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0
|
||||
#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_depthwrite_vs30_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -190,6 +190,27 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_vertexlit_and_unlit_generic_vs20_Static_Index( )
|
||||
{
|
||||
@ -229,19 +250,23 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false;
|
||||
#endif // _DEBUG
|
||||
m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR;
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0;
|
||||
return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + ( 98304 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -211,6 +211,27 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_vertexlit_and_unlit_generic_vs30_Static_Index( )
|
||||
{
|
||||
@ -254,19 +275,23 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false;
|
||||
#endif // _DEBUG
|
||||
m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR;
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0;
|
||||
return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + ( 131072 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -43,6 +43,27 @@ public:
|
||||
m_bCOLOR_DEPTH = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_depthwrite_vs20_Static_Index( )
|
||||
{
|
||||
@ -54,19 +75,23 @@ public:
|
||||
m_bCOLOR_DEPTH = false;
|
||||
#endif // _DEBUG
|
||||
m_nCOLOR_DEPTH = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH;
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + 0;
|
||||
return ( 4 * m_nONLY_PROJECT_POSITION ) + ( 4 * m_nCOLOR_DEPTH ) + ( 8 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0
|
||||
#define shaderStaticTest_sdk_depthwrite_vs20 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_depthwrite_vs20_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -43,6 +43,27 @@ public:
|
||||
m_bCOLOR_DEPTH = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_depthwrite_vs30_Static_Index( )
|
||||
{
|
||||
@ -54,19 +75,23 @@ public:
|
||||
m_bCOLOR_DEPTH = false;
|
||||
#endif // _DEBUG
|
||||
m_nCOLOR_DEPTH = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH;
|
||||
bool bAllStaticVarsDefined = m_bONLY_PROJECT_POSITION && m_bCOLOR_DEPTH && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + 0;
|
||||
return ( 8 * m_nONLY_PROJECT_POSITION ) + ( 8 * m_nCOLOR_DEPTH ) + ( 16 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + 0
|
||||
#define shaderStaticTest_sdk_depthwrite_vs30 vsh_forgot_to_set_static_ONLY_PROJECT_POSITION + vsh_forgot_to_set_static_COLOR_DEPTH + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_depthwrite_vs30_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -190,6 +190,27 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_vertexlit_and_unlit_generic_vs20_Static_Index( )
|
||||
{
|
||||
@ -229,19 +250,23 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false;
|
||||
#endif // _DEBUG
|
||||
m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR;
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bUSE_STATIC_CONTROL_FLOW && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0;
|
||||
return ( 192 * m_nVERTEXCOLOR ) + ( 384 * m_nCUBEMAP ) + ( 768 * m_nHALFLAMBERT ) + ( 1536 * m_nFLASHLIGHT ) + ( 3072 * m_nSEAMLESS_BASE ) + ( 6144 * m_nSEAMLESS_DETAIL ) + ( 12288 * m_nSEPARATE_DETAIL_UVS ) + ( 24576 * m_nUSE_STATIC_CONTROL_FLOW ) + ( 49152 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + ( 98304 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs20 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_USE_STATIC_CONTROL_FLOW + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_vertexlit_and_unlit_generic_vs20_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
@ -211,6 +211,27 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = true;
|
||||
#endif
|
||||
}
|
||||
private:
|
||||
int m_nTREESWAY;
|
||||
#ifdef _DEBUG
|
||||
bool m_bTREESWAY;
|
||||
#endif
|
||||
public:
|
||||
void SetTREESWAY( int i )
|
||||
{
|
||||
Assert( i >= 0 && i <= 2 );
|
||||
m_nTREESWAY = i;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
void SetTREESWAY( bool i )
|
||||
{
|
||||
m_nTREESWAY = i ? 1 : 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = true;
|
||||
#endif
|
||||
}
|
||||
public:
|
||||
sdk_vertexlit_and_unlit_generic_vs30_Static_Index( )
|
||||
{
|
||||
@ -254,19 +275,23 @@ public:
|
||||
m_bDONT_GAMMA_CONVERT_VERTEX_COLOR = false;
|
||||
#endif // _DEBUG
|
||||
m_nDONT_GAMMA_CONVERT_VERTEX_COLOR = 0;
|
||||
#ifdef _DEBUG
|
||||
m_bTREESWAY = false;
|
||||
#endif // _DEBUG
|
||||
m_nTREESWAY = 0;
|
||||
}
|
||||
int GetIndex()
|
||||
{
|
||||
// Asserts to make sure that we aren't using any skipped combinations.
|
||||
// Asserts to make sure that we are setting all of the combination vars.
|
||||
#ifdef _DEBUG
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR;
|
||||
bool bAllStaticVarsDefined = m_bVERTEXCOLOR && m_bCUBEMAP && m_bHALFLAMBERT && m_bFLASHLIGHT && m_bSEAMLESS_BASE && m_bSEAMLESS_DETAIL && m_bSEPARATE_DETAIL_UVS && m_bDECAL && m_bSM30_VERTEXID && m_bDONT_GAMMA_CONVERT_VERTEX_COLOR && m_bTREESWAY;
|
||||
Assert( bAllStaticVarsDefined );
|
||||
#endif // _DEBUG
|
||||
return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + 0;
|
||||
return ( 128 * m_nVERTEXCOLOR ) + ( 256 * m_nCUBEMAP ) + ( 512 * m_nHALFLAMBERT ) + ( 1024 * m_nFLASHLIGHT ) + ( 2048 * m_nSEAMLESS_BASE ) + ( 4096 * m_nSEAMLESS_DETAIL ) + ( 8192 * m_nSEPARATE_DETAIL_UVS ) + ( 16384 * m_nDECAL ) + ( 32768 * m_nSM30_VERTEXID ) + ( 65536 * m_nDONT_GAMMA_CONVERT_VERTEX_COLOR ) + ( 131072 * m_nTREESWAY ) + 0;
|
||||
}
|
||||
};
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + 0
|
||||
#define shaderStaticTest_sdk_vertexlit_and_unlit_generic_vs30 vsh_forgot_to_set_static_VERTEXCOLOR + vsh_forgot_to_set_static_CUBEMAP + vsh_forgot_to_set_static_HALFLAMBERT + vsh_forgot_to_set_static_FLASHLIGHT + vsh_forgot_to_set_static_SEAMLESS_BASE + vsh_forgot_to_set_static_SEAMLESS_DETAIL + vsh_forgot_to_set_static_SEPARATE_DETAIL_UVS + vsh_forgot_to_set_static_DECAL + vsh_forgot_to_set_static_SM30_VERTEXID + vsh_forgot_to_set_static_DONT_GAMMA_CONVERT_VERTEX_COLOR + vsh_forgot_to_set_static_TREESWAY + 0
|
||||
class sdk_vertexlit_and_unlit_generic_vs30_Dynamic_Index
|
||||
{
|
||||
private:
|
||||
|
89
sp/src/materialsystem/stdshaders/tree_sway.h
Normal file
89
sp/src/materialsystem/stdshaders/tree_sway.h
Normal file
@ -0,0 +1,89 @@
|
||||
//============ Copyright (c) Valve Corporation, All rights reserved. ============
|
||||
|
||||
#ifndef _TREE_SWAY_H
|
||||
#define _TREE_SWAY_H
|
||||
|
||||
// Tree sway vertex animation function. Requires a number of global variables to be defined. See vertexlit_and_unlit_generic_vs20.fxc or depthwrite_vs20.fxc for details.
|
||||
|
||||
// Tree sway mode 2:
|
||||
// Hacks to use tree sway code on rectangular sheets of plastic/tarp attached at the four corners.
|
||||
// Inverts the sway scale radius to be 1 at (0,0,0) in model space and fall off radially towards the edges of the model.
|
||||
// The model is expected to be build lying in the xy plane in model space, with its center at the origin.
|
||||
// Treeswaystrength should be 0 in the vmt.
|
||||
|
||||
#if ( TREESWAY )
|
||||
float3 ComputeTreeSway( float3 vPositionOS, float flTime )
|
||||
{
|
||||
static const float g_flWindOffsetScale = 19;
|
||||
|
||||
float flWindIntensity = length( g_vWindDir );
|
||||
|
||||
// Model root position is the translation component of the model to world matrix
|
||||
float3 vModelRoot = float3( cModel[0][3].x, cModel[0][3].y, cModel[0][3].z );
|
||||
|
||||
// Transform the wind direction into model space
|
||||
float3 vWindDirAndIntensityOS = mul( ( float3x3 )cModel[0], float3( g_vWindDir, 0 ) );
|
||||
|
||||
float flSwayScaleHeight = saturate( ( vPositionOS.z - g_flHeight * g_flStartHeight ) /
|
||||
( ( 1.0 - g_flStartHeight ) * g_flHeight ) );
|
||||
|
||||
float flSwayScaleRadius = saturate( length( ( vPositionOS.xy ) - g_flRadius * g_flStartRadius ) /
|
||||
( ( 1.0 - g_flStartRadius ) * g_flRadius ) );
|
||||
|
||||
// Used to turn off branch sway and scrumble below the minimum sway height
|
||||
float flHeightThreshold = step( 0, vPositionOS.z - g_flHeight * g_flStartHeight );
|
||||
|
||||
#if ( TREESWAY == 2 )
|
||||
{
|
||||
// Works better for hanging vines
|
||||
flHeightThreshold = step( vPositionOS.z - g_flHeight * g_flStartHeight, 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
// Scale branch motion based on how orthogonal they are
|
||||
// This is what I want to compute:
|
||||
// float flOrthoBranchScale = 1.0 - abs( dot( normalize( vWindDirAndIntensityOS.xyz ), float3( normalize( vPositionOS.xy ), 0 ) ) );
|
||||
// Some NV hardware (7800) will do bad things when normalizing a 0 length vector. Instead, I'm doing the dot product unnormalized
|
||||
// and divide by the length of the vectors, making sure to avoid divide by 0.
|
||||
float flOrthoBranchScale = abs( dot( vWindDirAndIntensityOS.xyz, float3( vPositionOS.xy, 0 ) ) );
|
||||
flOrthoBranchScale = 1.0 - saturate( flOrthoBranchScale / ( max( length( vWindDirAndIntensityOS.xyz ), 0.0001 ) * max( length( vPositionOS.xy ), 0.0001 ) ) );
|
||||
|
||||
float flSwayScaleTrunk = g_flSwayIntensity * pow( flSwayScaleHeight, g_flSwayFalloffCurve );
|
||||
float flSwayScaleBranches = g_flSwayIntensity * flOrthoBranchScale * flSwayScaleRadius * flHeightThreshold;
|
||||
#if ( TREESWAY == 2 )
|
||||
{
|
||||
// Looks stupid on vines
|
||||
flSwayScaleBranches = 0.0;
|
||||
}
|
||||
#endif
|
||||
float flWindTimeOffset = dot( vModelRoot.xyz, float3( 1, 1, 1 ) ) * g_flWindOffsetScale;
|
||||
float flSlowSwayTime = ( flTime + flWindTimeOffset ) * g_flSwaySpeed;
|
||||
|
||||
float3 vSwayPosOS = normalize( vPositionOS.xyz );
|
||||
float3 vScrumblePosOS = vSwayPosOS * g_flScrumbleWaveCount;
|
||||
float flScrumbleScale = pow( flSwayScaleRadius, g_flScrumbleFalloffCurve ) * g_flScrumbleIntensity * flHeightThreshold;
|
||||
|
||||
float3 vPositionOffset = float3( 0, 0, 0 );
|
||||
|
||||
// lerp between slow and fast sines based on wind speed
|
||||
float flSpeedLerp = smoothstep( g_flWindSpeedLerpStart, g_flWindSpeedLerpEnd, flWindIntensity );
|
||||
float4 vABunchOfSines = sin( float4( 1.0, 2.31, g_flFastSwaySpeedScale, 2.14 * g_flFastSwaySpeedScale ) * flSlowSwayTime.xxxx );
|
||||
vABunchOfSines.xy = lerp( vABunchOfSines.xy, vABunchOfSines.zw, flSpeedLerp );
|
||||
|
||||
vPositionOffset.xyz = vWindDirAndIntensityOS * flSwayScaleTrunk * ( vABunchOfSines.x + 0.1 );
|
||||
vPositionOffset.xyz += vWindDirAndIntensityOS * flSwayScaleBranches * ( vABunchOfSines.y + 0.4 );
|
||||
|
||||
float3 vScrumbleScale = flScrumbleScale.xxx;
|
||||
#if ( TREESWAY == 2 )
|
||||
{
|
||||
vScrumbleScale *= float3( 0.5, 0.5, 1.0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
vPositionOffset.xyz += flWindIntensity * ( vScrumbleScale.xyz * sin( g_flScrumbleSpeed * flTime.xxx + vScrumblePosOS.yzx + flWindTimeOffset.xxx ) );
|
||||
|
||||
return vPositionOS.xyz + vPositionOffset.xyz;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // _TREE_SWAY_H
|
@ -78,6 +78,25 @@ BEGIN_VS_SHADER( SDK_UnlitGeneric, "Help for SDK_UnlitGeneric" )
|
||||
SHADER_PARAM( DEPTHBLENDSCALE, SHADER_PARAM_TYPE_FLOAT, "50.0", "Amplify or reduce DEPTHBLEND fading. Lower values make harder edges." )
|
||||
SHADER_PARAM( RECEIVEFLASHLIGHT, SHADER_PARAM_TYPE_INTEGER, "0", "Forces this material to receive flashlights." )
|
||||
|
||||
// vertexlitgeneric tree sway animation control (on unlitgeneric)
|
||||
SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTHEIGHT, SHADER_PARAM_TYPE_FLOAT, "0.2", "" )
|
||||
SHADER_PARAM( TREESWAYRADIUS, SHADER_PARAM_TYPE_FLOAT, "300", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTRADIUS, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEED, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDHIGHWINDMULTIPLIER, SHADER_PARAM_TYPE_FLOAT, "2", "" )
|
||||
SHADER_PARAM( TREESWAYSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "10", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESPEED, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFREQUENCY, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.5", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" )
|
||||
SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" )
|
||||
|
||||
END_SHADER_PARAMS
|
||||
|
||||
void SetupVars( VertexLitGeneric_DX9_Vars_t& info )
|
||||
@ -157,6 +176,24 @@ BEGIN_VS_SHADER( SDK_UnlitGeneric, "Help for SDK_UnlitGeneric" )
|
||||
info.m_nDepthBlend = DEPTHBLEND;
|
||||
info.m_nDepthBlendScale = DEPTHBLENDSCALE;
|
||||
info.m_nReceiveFlashlight = RECEIVEFLASHLIGHT;
|
||||
|
||||
info.m_nTreeSway = TREESWAY;
|
||||
info.m_nTreeSwayHeight = TREESWAYHEIGHT;
|
||||
info.m_nTreeSwayStartHeight = TREESWAYSTARTHEIGHT;
|
||||
info.m_nTreeSwayRadius = TREESWAYRADIUS;
|
||||
info.m_nTreeSwayStartRadius = TREESWAYSTARTRADIUS;
|
||||
info.m_nTreeSwaySpeed = TREESWAYSPEED;
|
||||
info.m_nTreeSwaySpeedHighWindMultiplier = TREESWAYSPEEDHIGHWINDMULTIPLIER;
|
||||
info.m_nTreeSwayStrength = TREESWAYSTRENGTH;
|
||||
info.m_nTreeSwayScrumbleSpeed = TREESWAYSCRUMBLESPEED;
|
||||
info.m_nTreeSwayScrumbleStrength = TREESWAYSCRUMBLESTRENGTH;
|
||||
info.m_nTreeSwayScrumbleFrequency = TREESWAYSCRUMBLEFREQUENCY;
|
||||
info.m_nTreeSwayFalloffExp = TREESWAYFALLOFFEXP;
|
||||
info.m_nTreeSwayScrumbleFalloffExp = TREESWAYSCRUMBLEFALLOFFEXP;
|
||||
info.m_nTreeSwaySpeedLerpStart = TREESWAYSPEEDLERPSTART;
|
||||
info.m_nTreeSwaySpeedLerpEnd = TREESWAYSPEEDLERPEND;
|
||||
info.m_nTreeSwayStatic = TREESWAYSTATIC;
|
||||
info.m_nTreeSwayStaticValues = TREESWAYSTATICVALUES;
|
||||
}
|
||||
|
||||
SHADER_INIT_PARAMS()
|
||||
|
@ -143,6 +143,25 @@ BEGIN_VS_SHADER( SDK_VertexLitGeneric, "Help for SDK_VertexLitGeneric" )
|
||||
#ifdef MAPBASE
|
||||
SHADER_PARAM( PHONGDISABLEHALFLAMBERT, SHADER_PARAM_TYPE_BOOL, "0", "Disable half lambert for phong" )
|
||||
#endif
|
||||
|
||||
// vertexlitgeneric tree sway animation control
|
||||
SHADER_PARAM( TREESWAY, SHADER_PARAM_TYPE_INTEGER, "0", "" )
|
||||
SHADER_PARAM( TREESWAYHEIGHT, SHADER_PARAM_TYPE_FLOAT, "1000", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTHEIGHT, SHADER_PARAM_TYPE_FLOAT, "0.2", "" )
|
||||
SHADER_PARAM( TREESWAYRADIUS, SHADER_PARAM_TYPE_FLOAT, "300", "" )
|
||||
SHADER_PARAM( TREESWAYSTARTRADIUS, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEED, SHADER_PARAM_TYPE_FLOAT, "1", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDHIGHWINDMULTIPLIER, SHADER_PARAM_TYPE_FLOAT, "2", "" )
|
||||
SHADER_PARAM( TREESWAYSTRENGTH, SHADER_PARAM_TYPE_FLOAT, "10", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESPEED, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLESTRENGTH, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFREQUENCY, SHADER_PARAM_TYPE_FLOAT, "0.1", "" )
|
||||
SHADER_PARAM( TREESWAYFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.5", "" )
|
||||
SHADER_PARAM( TREESWAYSCRUMBLEFALLOFFEXP, SHADER_PARAM_TYPE_FLOAT, "1.0", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPSTART, SHADER_PARAM_TYPE_FLOAT, "3", "" )
|
||||
SHADER_PARAM( TREESWAYSPEEDLERPEND, SHADER_PARAM_TYPE_FLOAT, "6", "" )
|
||||
SHADER_PARAM( TREESWAYSTATIC, SHADER_PARAM_TYPE_BOOL, "0", "" )
|
||||
SHADER_PARAM( TREESWAYSTATICVALUES, SHADER_PARAM_TYPE_VEC2, "[0.5 0.5]", "" )
|
||||
END_SHADER_PARAMS
|
||||
|
||||
void SetupVars( VertexLitGeneric_DX9_Vars_t& info )
|
||||
@ -222,6 +241,24 @@ BEGIN_VS_SHADER( SDK_VertexLitGeneric, "Help for SDK_VertexLitGeneric" )
|
||||
#ifdef MAPBASE
|
||||
info.m_nPhongDisableHalfLambert = PHONGDISABLEHALFLAMBERT;
|
||||
#endif
|
||||
|
||||
info.m_nTreeSway = TREESWAY;
|
||||
info.m_nTreeSwayHeight = TREESWAYHEIGHT;
|
||||
info.m_nTreeSwayStartHeight = TREESWAYSTARTHEIGHT;
|
||||
info.m_nTreeSwayRadius = TREESWAYRADIUS;
|
||||
info.m_nTreeSwayStartRadius = TREESWAYSTARTRADIUS;
|
||||
info.m_nTreeSwaySpeed = TREESWAYSPEED;
|
||||
info.m_nTreeSwaySpeedHighWindMultiplier = TREESWAYSPEEDHIGHWINDMULTIPLIER;
|
||||
info.m_nTreeSwayStrength = TREESWAYSTRENGTH;
|
||||
info.m_nTreeSwayScrumbleSpeed = TREESWAYSCRUMBLESPEED;
|
||||
info.m_nTreeSwayScrumbleStrength = TREESWAYSCRUMBLESTRENGTH;
|
||||
info.m_nTreeSwayScrumbleFrequency = TREESWAYSCRUMBLEFREQUENCY;
|
||||
info.m_nTreeSwayFalloffExp = TREESWAYFALLOFFEXP;
|
||||
info.m_nTreeSwayScrumbleFalloffExp = TREESWAYSCRUMBLEFALLOFFEXP;
|
||||
info.m_nTreeSwaySpeedLerpStart = TREESWAYSPEEDLERPSTART;
|
||||
info.m_nTreeSwaySpeedLerpEnd = TREESWAYSPEEDLERPEND;
|
||||
info.m_nTreeSwayStatic = TREESWAYSTATIC;
|
||||
info.m_nTreeSwayStaticValues = TREESWAYSTATICVALUES;
|
||||
}
|
||||
|
||||
// Cloak Pass
|
||||
|
@ -223,6 +223,22 @@ void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** para
|
||||
|
||||
InitIntParam( info.m_nDepthBlend, params, 0 );
|
||||
InitFloatParam( info.m_nDepthBlendScale, params, 50.0f );
|
||||
|
||||
InitIntParam( info.m_nTreeSway, params, 0 );
|
||||
InitFloatParam( info.m_nTreeSwayHeight, params, 1000.0f );
|
||||
InitFloatParam( info.m_nTreeSwayStartHeight, params, 0.1f );
|
||||
InitFloatParam( info.m_nTreeSwayRadius, params, 300.0f );
|
||||
InitFloatParam( info.m_nTreeSwayStartRadius, params, 0.2f );
|
||||
InitFloatParam( info.m_nTreeSwaySpeed, params, 1.0f );
|
||||
InitFloatParam( info.m_nTreeSwaySpeedHighWindMultiplier, params, 2.0f );
|
||||
InitFloatParam( info.m_nTreeSwayStrength, params, 10.0f );
|
||||
InitFloatParam( info.m_nTreeSwayScrumbleSpeed, params, 5.0f );
|
||||
InitFloatParam( info.m_nTreeSwayScrumbleStrength, params, 10.0f );
|
||||
InitFloatParam( info.m_nTreeSwayScrumbleFrequency, params, 12.0f );
|
||||
InitFloatParam( info.m_nTreeSwayFalloffExp, params, 1.5f );
|
||||
InitFloatParam( info.m_nTreeSwayScrumbleFalloffExp, params, 1.0f );
|
||||
InitFloatParam( info.m_nTreeSwaySpeedLerpStart, params, 3.0f );
|
||||
InitFloatParam( info.m_nTreeSwaySpeedLerpEnd, params, 6.0f );
|
||||
}
|
||||
|
||||
|
||||
@ -391,6 +407,8 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
bFlashlightNoLambert = true;
|
||||
}
|
||||
|
||||
int nTreeSwayMode = clamp( GetIntParam( info.m_nTreeSway, params, 0 ), 0, 2 );
|
||||
bool bTreeSway = nTreeSwayMode != 0;
|
||||
bool bAmbientOnly = IsBoolSet( info.m_nAmbientOnly, params );
|
||||
|
||||
float fBlendFactor = GetFloatParam( info.m_nDetailTextureBlendFactor, params, 1.0 );
|
||||
@ -429,14 +447,11 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
|
||||
bool bHasVertexColor = bVertexLitGeneric ? false : IS_FLAG_SET( MATERIAL_VAR_VERTEXCOLOR );
|
||||
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 );
|
||||
bool bSeamlessBase = IsBoolSet( info.m_nSeamlessBase, params );
|
||||
bool bSeamlessDetail = IsBoolSet( info.m_nSeamlessDetail, params );
|
||||
bool bSeamlessBase = IsBoolSet( info.m_nSeamlessBase, params ) && !bTreeSway;
|
||||
bool bSeamlessDetail = IsBoolSet( info.m_nSeamlessDetail, params ) && !bTreeSway;
|
||||
bool bDistanceAlpha = IsBoolSet( info.m_nDistanceAlpha, params );
|
||||
bool bHasSelfIllum = (!bHasFlashlight || IsX360() ) && IS_FLAG_SET( MATERIAL_VAR_SELFILLUM );
|
||||
bool bHasEnvmapMask = (!bHasFlashlight || IsX360() ) && info.m_nEnvmapMask != -1 && params[info.m_nEnvmapMask]->IsTexture();
|
||||
@ -778,6 +793,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( SEPARATE_DETAIL_UVS, IsBoolSet( info.m_nSeparateDetailUVs, params ) );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( USE_STATIC_CONTROL_FLOW, bUseStaticControlFlow );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, (! bSRGBWrite ) && bHasVertexColor );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, bTreeSway ? nTreeSwayMode : 0 );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs20 );
|
||||
|
||||
//if ( g_pHardwareConfig->SupportsPixelShaders_2_b() || g_pHardwareConfig->ShouldAlwaysUseShaderModel2bShaders() ) // Always send Gl this way
|
||||
@ -852,6 +868,7 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( DECAL, bIsDecal );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( SM30_VERTEXID, bFastVertexTextures );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( DONT_GAMMA_CONVERT_VERTEX_COLOR, bSRGBWrite ? 0 : 1 );
|
||||
SET_STATIC_VERTEX_SHADER_COMBO( TREESWAY, bTreeSway ? nTreeSwayMode : 0 );
|
||||
SET_STATIC_VERTEX_SHADER( sdk_vertexlit_and_unlit_generic_vs30 );
|
||||
|
||||
DECLARE_STATIC_PIXEL_SHADER( sdk_vertexlit_and_unlit_generic_ps30 );
|
||||
@ -956,11 +973,14 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
|
||||
|
||||
if ( bHasDetailTexture )
|
||||
{
|
||||
if ( !bTreeSway )
|
||||
{
|
||||
if ( IS_PARAM_DEFINED( info.m_nDetailTextureTransform ) )
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureScaledTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nDetailTextureTransform, info.m_nDetailScale );
|
||||
else
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderTextureScaledTransform( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, info.m_nBaseTextureTransform, info.m_nDetailScale );
|
||||
}
|
||||
//Assert( !bHasBump );
|
||||
if ( info.m_nDetailTint != -1 )
|
||||
pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstantGammaToLinear( 10, info.m_nDetailTint );
|
||||
@ -1173,6 +1193,36 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
}
|
||||
pContextData->m_SemiStaticCmdsOut.SetPixelShaderConstant_W( 4, info.m_nSelfIllumTint, fBlendFactor );
|
||||
pContextData->m_SemiStaticCmdsOut.SetAmbientCubeDynamicStateVertexShader();
|
||||
|
||||
if ( bTreeSway )
|
||||
{
|
||||
float flParams[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
flParams[0] = GetFloatParam( info.m_nTreeSwaySpeedHighWindMultiplier, params, 2.0f );
|
||||
flParams[1] = GetFloatParam( info.m_nTreeSwayScrumbleFalloffExp, params, 1.0f );
|
||||
flParams[2] = GetFloatParam( info.m_nTreeSwayFalloffExp, params, 1.0f );
|
||||
flParams[3] = GetFloatParam( info.m_nTreeSwayScrumbleSpeed, params, 3.0f );
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_6, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( info.m_nTreeSwaySpeedLerpStart, params, 3.0f );
|
||||
flParams[1] = GetFloatParam( info.m_nTreeSwaySpeedLerpEnd, params, 6.0f );
|
||||
flParams[2] = 0;
|
||||
flParams[3] = 0;
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_4, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( info.m_nTreeSwayHeight, params, 1000.0f );
|
||||
flParams[1] = GetFloatParam( info.m_nTreeSwayStartHeight, params, 0.1f );
|
||||
flParams[2] = GetFloatParam( info.m_nTreeSwayRadius, params, 300.0f );
|
||||
flParams[3] = GetFloatParam( info.m_nTreeSwayStartRadius, params, 0.2f );
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_8, flParams );
|
||||
|
||||
flParams[0] = GetFloatParam( info.m_nTreeSwaySpeed, params, 1.0f );
|
||||
flParams[1] = GetFloatParam( info.m_nTreeSwayStrength, params, 10.0f );
|
||||
flParams[2] = GetFloatParam( info.m_nTreeSwayScrumbleFrequency, params, 12.0f );
|
||||
flParams[3] = GetFloatParam( info.m_nTreeSwayScrumbleStrength, params, 10.0f );
|
||||
pContextData->m_SemiStaticCmdsOut.SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_9, flParams );
|
||||
}
|
||||
|
||||
pContextData->m_SemiStaticCmdsOut.End();
|
||||
}
|
||||
}
|
||||
@ -1435,6 +1485,25 @@ static void DrawVertexLitGeneric_DX9_Internal( CBaseVSShader *pShader, IMaterial
|
||||
|
||||
DynamicCmdsOut.SetPixelShaderConstant( 24, worldToTexture.Base(), 4 );
|
||||
}
|
||||
|
||||
if ( bTreeSway )
|
||||
{
|
||||
float fTempConst[4];
|
||||
fTempConst[1] = pShaderAPI->CurrentTime();
|
||||
if ( params[info.m_nTreeSwayStatic]->GetIntValue() == 0 )
|
||||
{
|
||||
const Vector& windDir = pShaderAPI->GetVectorRenderingParameter( VECTOR_RENDERPARM_WIND_DIRECTION );
|
||||
fTempConst[2] = windDir.x;
|
||||
fTempConst[3] = windDir.y;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Use a static value instead of the env_wind value.
|
||||
params[info.m_nTreeSwayStaticValues]->GetVecValue( fTempConst+2, 2 );
|
||||
}
|
||||
DynamicCmdsOut.SetVertexShaderConstant( VERTEX_SHADER_SHADER_SPECIFIC_CONST_7, fTempConst );
|
||||
}
|
||||
|
||||
DynamicCmdsOut.End();
|
||||
pShaderAPI->ExecuteCommandBuffer( DynamicCmdsOut.Base() );
|
||||
}
|
||||
|
@ -136,6 +136,23 @@ struct VertexLitGeneric_DX9_Vars_t
|
||||
int m_nPhongDisableHalfLambert;
|
||||
#endif
|
||||
|
||||
int m_nTreeSway;
|
||||
int m_nTreeSwayHeight;
|
||||
int m_nTreeSwayStartHeight;
|
||||
int m_nTreeSwayRadius;
|
||||
int m_nTreeSwayStartRadius;
|
||||
int m_nTreeSwaySpeed;
|
||||
int m_nTreeSwaySpeedHighWindMultiplier;
|
||||
int m_nTreeSwayStrength;
|
||||
int m_nTreeSwayScrumbleSpeed;
|
||||
int m_nTreeSwayScrumbleStrength;
|
||||
int m_nTreeSwayScrumbleFrequency;
|
||||
int m_nTreeSwayFalloffExp;
|
||||
int m_nTreeSwayScrumbleFalloffExp;
|
||||
int m_nTreeSwaySpeedLerpStart;
|
||||
int m_nTreeSwaySpeedLerpEnd;
|
||||
int m_nTreeSwayStatic;
|
||||
int m_nTreeSwayStaticValues;
|
||||
};
|
||||
|
||||
void InitParamsVertexLitGeneric_DX9( CBaseVSShader *pShader, IMaterialVar** params, const char *pMaterialName, bool bVertexLitGeneric, VertexLitGeneric_DX9_Vars_t &info );
|
||||
|
@ -28,6 +28,8 @@ enum RenderParamVector_t
|
||||
VECTOR_RENDERPARM_HMDWARP_ASPECT,
|
||||
INT_RENDERPARM_DISTORTION_TYPE,
|
||||
|
||||
VECTOR_RENDERPARM_WIND_DIRECTION,
|
||||
|
||||
MAX_VECTOR_RENDER_PARMS = 20
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user