Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.0 KiB

//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
// DYNAMIC: "SKINNING" "0..1"
// DYNAMIC: "MORPHING" "0..0" [ = false ]
// Includes
#include "common_vs_fxc.h"
// Globals
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( s0 );
#endif
// Structs
struct VS_INPUT
{
float4 vPos : POSITION; // Position
float4 vBoneWeights : BLENDWEIGHT; // Skin weights
float4 vBoneIndices : BLENDINDICES; // Skin indices
float4 vTexCoord0 : TEXCOORD0; // Base texture coordinates
float3 vPosFlex : POSITION1; // Delta positions for flexing
#ifdef SHADER_MODEL_VS_3_0
float vVertexID : POSITION2;
#endif
};
struct VS_OUTPUT
{
float4 vProjPosition : POSITION; // Projection-space position
float2 vTexCoord0 : TEXCOORD0;
};
// Main
VS_OUTPUT main( const VS_INPUT i )
{
VS_OUTPUT o;
float4 vObjPosition = i.vPos;
#if !defined( SHADER_MODEL_VS_3_0 ) || !MORPHING
ApplyMorph( i.vPosFlex, vObjPosition.xyz );
#else
ApplyMorph( morphSampler, cMorphTargetTextureDim, cMorphSubrect, i.vVertexID, float3( 0, 0, 0 ), vObjPosition.xyz );
#endif
// Transform the position
float3 vWorldPosition = { 0.0f, 0.0f, 0.0f };
SkinPosition( g_bSkinning, vObjPosition, i.vBoneWeights, i.vBoneIndices, vWorldPosition );
// Transform into projection space
float4 vProjPosition = mul( float4( vWorldPosition, 1.0f ), cViewProj );
o.vProjPosition = vProjPosition;
#ifdef _PS3
// Account for OpenGL's flipped y coordinate and expanded z range [-1,1] instead of [0,1]
o.vProjPosition.y = -o.vProjPosition.y;
o.vProjPosition.z = 2.0f * o.vProjPosition.z - o.vProjPosition.w;
#endif // _PS3
// Pass through tex coords
o.vTexCoord0.xy = i.vTexCoord0.xy;
return o;
}