|
|
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
// STATIC: "PREVIEW" "0..1" // DYNAMIC: "SKINNING" "0..1" // DYNAMIC: "COMPRESSED_VERTS" "0..1" // DYNAMIC: "NUM_LIGHTS" "0..4"
// SKIP: ( ( $PREVIEW == 0 ) && ( $SKINNING == 1 ) ) // SKIP: ( ( $NUM_LIGHTS != 0 ) && ( $PREVIEW == 0 ) )
#include "common_vs_fxc.h"
const float4 g_patternTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1 const float4 g_wearTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_2 ); // 2 & 3 const float4 g_grungeTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_4 ); // 4 & 5
static const bool g_bSkinning = SKINNING ? true : false;
// Structs struct VS_INPUT { float4 vPos : POSITION; float2 vTexCoord : TEXCOORD0; #if ( PREVIEW == 1 ) float4 vNormal : NORMAL; float4 vBoneWeights : BLENDWEIGHT; float4 vBoneIndices : BLENDINDICES; #endif };
struct VS_OUTPUT { float4 vProjPos : POSITION; float4 vBaseUV_PatternUV : TEXCOORD0; float4 vWearUV_GrungeUV : TEXCOORD1; #if ( PREVIEW == 1 ) float4 lightAtten : TEXCOORD2; float3 worldPos : TEXCOORD3; float3 vWorldNormal : TEXCOORD4; #endif };
// Main VS_OUTPUT main( const VS_INPUT i ) { VS_OUTPUT o;
#if ( PREVIEW == 1 ) float4 vPosition, vTangent; float3 vNormal, worldPos, worldNormal, worldTangentS, worldTangentT;
vPosition = i.vPos; DecompressVertex_Normal( i.vNormal, vNormal );
SkinPositionAndNormal( g_bSkinning, vPosition, vNormal, i.vBoneWeights, i.vBoneIndices, worldPos, worldNormal ); o.worldPos = worldPos; o.vProjPos = mul( float4( worldPos, 1.0f ), cViewProj ); o.vWorldNormal = worldNormal;
o.lightAtten.x = GetVertexAttenForLight( worldPos, 0 ); o.lightAtten.y = GetVertexAttenForLight( worldPos, 1 ); o.lightAtten.z = GetVertexAttenForLight( worldPos, 2 ); o.lightAtten.w = GetVertexAttenForLight( worldPos, 3 );
#else o.vProjPos = i.vPos; #endif o.vBaseUV_PatternUV.xy = i.vTexCoord; o.vBaseUV_PatternUV.z = dot ( i.vTexCoord, g_patternTexCoordTransform[0].xy ) + g_patternTexCoordTransform[0].w; o.vBaseUV_PatternUV.w = dot ( i.vTexCoord, g_patternTexCoordTransform[1].xy ) + g_patternTexCoordTransform[1].w; o.vWearUV_GrungeUV.x = dot ( i.vTexCoord, g_wearTexCoordTransform[0].xy ) + g_wearTexCoordTransform[0].w; o.vWearUV_GrungeUV.y = dot ( i.vTexCoord, g_wearTexCoordTransform[1].xy ) + g_wearTexCoordTransform[1].w; o.vWearUV_GrungeUV.z = dot ( i.vTexCoord, g_grungeTexCoordTransform[0].xy ) + g_grungeTexCoordTransform[0].w; o.vWearUV_GrungeUV.w = dot ( i.vTexCoord, g_grungeTexCoordTransform[1].xy ) + g_grungeTexCoordTransform[1].w;
return o; }
|