1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2025-01-07 09:43:40 +08:00
hl2sdk/materialsystem/stdshaders/depthwrite_vs20.fxc
Scott Ehlert fdd0bbf277 SDK sync.
2012-07-06 20:35:59 -05:00

146 lines
4.1 KiB
Plaintext

// STATIC: "ONLY_PROJECT_POSITION" "0..1" [XBOX]
// STATIC: "ONLY_PROJECT_POSITION" "0..0" [PC]
// STATIC: "TREESWAY" "0..2"
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
// DYNAMIC: "SKINNING" "0..1"
// DYNAMIC: "MORPHING" "0..1" [vs30] [ = pShaderAPI->IsHWMorphingEnabled() ]
// DYNAMIC: "TESSELLATION" "0..2" [vs30] [PC]
// DYNAMIC: "TESSELLATION" "0..0" [XBOX]
// DYNAMIC: "TESSELLATION" "0..0" [vs20] [PC]
// SKIP: ( $MORPHING || $SKINNING || $COMPRESSED_VERTS ) && $TESSELLATION
#include "common_vs_fxc.h"
static const bool g_bSkinning = SKINNING ? true : false;
#ifdef SHADER_MODEL_VS_3_0
// NOTE: cMorphTargetTextureDim.xy = target dimensions,
// cMorphTargetTextureDim.z = 4tuples/morph
const float3 cMorphTargetTextureDim : register( SHADER_SPECIFIC_CONST_6 );
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
#endif
#if TESSELLATION
#include "tessellation_vs_fxc.h"
const float4 g_SubDControls : register( SHADER_SPECIFIC_CONST_8 );
sampler2D BezierSampler : register( s1 );
sampler2D DispSampler : register( s2 );
// VS_INPUT defined in header
#else // no TESSELLATION
struct VS_INPUT
{
float4 vPos : POSITION;
float2 vTexCoord : TEXCOORD0;
float4 vBoneWeights : BLENDWEIGHT;
float4 vBoneIndices : BLENDINDICES;
// Position delta stream
float3 vPosFlex : POSITION1;
#ifdef SHADER_MODEL_VS_3_0
float vVertexID : POSITION2;
#endif
};
#endif // TESSELLATION
struct VS_OUTPUT
{
float4 projPos : POSITION;
#if (ONLY_PROJECT_POSITION == 0) //360 sometimes runs without the pixel shader component, but has to patch this output if it does.
float2 texCoord : TEXCOORD0;
#endif
};
#include "tree_sway.h"
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o = ( VS_OUTPUT )0;
float3 worldPos;
#if ( TESSELLATION )
{
float2 detailUV, baseUV;
float3 worldNormal, worldTangentS, worldTangentT;
EvaluateSubdivisionSurface( v, g_SubDControls.x, g_SubDControls.y, g_SubDControls.z, BezierSampler, DispSampler, worldNormal, worldPos, baseUV, detailUV );
#if (ONLY_PROJECT_POSITION == 0)
{
o.texCoord = baseUV;
}
#endif
}
#else // not tessellating
{
float4 vPosition = v.vPos;
#if ( !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING )
{
ApplyMorph( v.vPosFlex, vPosition.xyz );
}
#else
{
ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, 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, worldPos );
#if ( ONLY_PROJECT_POSITION == 0 )
{
o.texCoord = v.vTexCoord;
}
#endif
}
#endif
o.projPos = mul( float4( worldPos, 1.0f ), cViewProj );
return o;
}