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.
81 lines
2.8 KiB
81 lines
2.8 KiB
//========== Copyright (c) Valve Corporation, All rights reserved. ==========//
|
|
|
|
// DYNAMIC: "SKINNING" "0..1"
|
|
// DYNAMIC: "COMPRESSED_VERTS" "0..1"
|
|
|
|
#include "common_vs_fxc.h"
|
|
|
|
const float4 g_baseTextureTransform[2] : register( SHADER_SPECIFIC_CONST_0 ); // 0 & 1
|
|
|
|
static const bool g_bSkinning = SKINNING ? true : false;
|
|
|
|
struct VS_INPUT
|
|
{
|
|
float4 vPos : POSITION;
|
|
float2 vTexCoord : TEXCOORD0;
|
|
|
|
float4 vNormal : NORMAL;
|
|
float4 vTangent : TANGENT;
|
|
float4 vBoneWeights : BLENDWEIGHT;
|
|
float4 vBoneIndices : BLENDINDICES;
|
|
};
|
|
|
|
struct VS_OUTPUT
|
|
{
|
|
float4 vProjPos_POSITION : POSITION;
|
|
|
|
//float4 lightAtten : TEXCOORD2;
|
|
|
|
float3 worldPos : TEXCOORD3;
|
|
float3x3 tangentSpaceTranspose : TEXCOORD4;
|
|
// second row : TEXCOORD5;
|
|
// third row : TEXCOORD6;
|
|
float4 vProjPos : TEXCOORD7;
|
|
};
|
|
|
|
// Main
|
|
VS_OUTPUT main( const VS_INPUT i )
|
|
{
|
|
VS_OUTPUT o;
|
|
|
|
float4 vPosition, vTangent;
|
|
float3 vNormal, worldPos, worldNormal, worldTangentS, worldTangentT;
|
|
|
|
vPosition = i.vPos;
|
|
|
|
// Perform skinning
|
|
DecompressVertex_NormalTangent( i.vNormal, i.vTangent, vNormal, vTangent );
|
|
SkinPositionNormalAndTangentSpace( g_bSkinning, vPosition, vNormal, vTangent,
|
|
i.vBoneWeights, i.vBoneIndices, worldPos,
|
|
worldNormal, worldTangentS, worldTangentT );
|
|
worldTangentS = normalize( worldTangentS );
|
|
worldTangentT = normalize( worldTangentT );
|
|
worldNormal = normalize( worldNormal );
|
|
|
|
// Tangent space transform
|
|
o.tangentSpaceTranspose[0].xyz = float3( worldTangentS.x, worldTangentT.x, worldNormal.x );
|
|
o.tangentSpaceTranspose[1].xyz = float3( worldTangentS.y, worldTangentT.y, worldNormal.y );
|
|
o.tangentSpaceTranspose[2].xyz = float3( worldTangentS.z, worldTangentT.z, worldNormal.z );
|
|
|
|
o.worldPos = worldPos;
|
|
o.vProjPos = o.vProjPos_POSITION = mul( float4( worldPos, 1.0f ), cViewProj );
|
|
|
|
//o.lightAtten.x = GetVertexAttenForLight( worldPos, 0, false );
|
|
//o.lightAtten.y = GetVertexAttenForLight( worldPos, 1, false );
|
|
//o.lightAtten.z = GetVertexAttenForLight( worldPos, 2, false );
|
|
//o.lightAtten.w = GetVertexAttenForLight( worldPos, 3, false );
|
|
|
|
//o.vBaseUV_PatternUV.xy = i.vTexCoord;
|
|
//
|
|
//o.vBaseUV_PatternUV.z = dot ( i.vTexCoord, g_baseTextureTransform[0].xy ) + g_baseTextureTransform[0].w;
|
|
//o.vBaseUV_PatternUV.w = dot ( i.vTexCoord, g_baseTextureTransform[1].xy ) + g_baseTextureTransform[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;
|
|
|
|
}
|