|
|
// STATIC: "ONLY_PROJECT_POSITION" "0..1" [XBOX] // STATIC: "ONLY_PROJECT_POSITION" "0..0" [PC] // STATIC: "ONLY_PROJECT_POSITION" "0..0" [SONYPS3] // STATIC: "TREESWAY" "0..2" // STATIC: "COLOR_DEPTH" "0..1"
// DYNAMIC: "COMPRESSED_VERTS" "0..1" // DYNAMIC: "SKINNING" "0..1"
// DYNAMIC: "MORPHING" "0..0" [ = false ] // DYNAMIC: "TESSELLATION" "0..0" [vs30] [PC] // DYNAMIC: "TESSELLATION" "0..0" [CONSOLE] // DYNAMIC: "TESSELLATION" "0..0" [vs20] [PC]
// SKIP: ( $MORPHING || $SKINNING || $COMPRESSED_VERTS ) && $TESSELLATION
// Disabling morphing in CS:GO, otherwise this shader causes an Internal Driver Error on the first Present() under Windows XP ATI X1650. #if MORPHING #undef MORPHING #define MORPHING 0 #endif
#include "common_vs_fxc.h"
static const bool g_bSkinning = SKINNING ? true : false;
#if defined( SHADER_MODEL_VS_3_0 ) && MORPHING // 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( 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; #if defined( SHADER_MODEL_VS_3_0 ) && MORPHING float vVertexID : POSITION2; #endif };
#endif // TESSELLATION
struct VS_OUTPUT { float4 vProjPos : 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
#if COLOR_DEPTH float4 vWorldPos_projPosZ : TEXCOORD1; #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
float4 vProjPos = mul( float4( worldPos, 1.0f ), cViewProj );
o.vProjPos = vProjPos;
#if ( COLOR_DEPTH && !ONLY_PROJECT_POSITION ) o.vWorldPos_projPosZ.z = vProjPos.z; o.vWorldPos_projPosZ.w = vProjPos.w; #endif #ifdef _PS3 // Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1] o.projPos.y = -o.projPos.y; o.projPos.z = 2.0f * o.projPos.z - o.projPos.w; #endif // _PS3
return o; }
|