// STATIC: "VERTEXCOLOR" "0..1"
// STATIC: "HALFLAMBERT" "0..1"
// STATIC: "FLASHLIGHT" "0..1"
// DYNAMIC: "LIGHT_COMBO" "0..21"
// DYNAMIC: "DOWATERFOG" "0..1"
// DYNAMIC: "NUM_BONES" "0..3"
// DYNAMIC: "LIGHTING_PREVIEW" "0..1"
#include "common_vs_fxc.h"
static const int g_NumBones = NUM_BONES;
static const int g_LightCombo = LIGHT_COMBO;
static const int g_FogType = DOWATERFOG;
static const int g_LocalLightType0 = g_LocalLightType0Array[g_LightCombo];
static const int g_LocalLightType1 = g_LocalLightType1Array[g_LightCombo];
const float4 cBaseTexCoordTransform[2] : register( SHADER_SPECIFIC_CONST_0 );
//-----------------------------------------------------------------------------
// Input vertex format
//-----------------------------------------------------------------------------
struct VS_INPUT
{
// This is all of the stuff that we ever use.
float4 vPos : POSITION;
float4 vBoneWeights : BLENDWEIGHT;
float4 vBoneIndices : BLENDINDICES;
float3 vNormal : NORMAL;
float4 vColor : COLOR0;
float3 vSpecular : COLOR1;
// make these float2's and stick the [n n 0 1] in the dot math.
float4 vTexCoord0 : TEXCOORD0;
float4 vTexCoord1 : TEXCOORD1;
float4 vTexCoord2 : TEXCOORD2;
float4 vTexCoord3 : TEXCOORD3;
float3 vTangentS : TANGENT;
float3 vTangentT : BINORMAL;
float4 vUserData : TANGENT;
// Position and normal/tangent deltas
float3 vPosFlex : POSITION1;
float3 vNormalFlex : NORMAL1;
};
struct VS_OUTPUT
{
// Stuff that isn't seen by the pixel shader
float4 projPos : POSITION;
float fog : FOG;
float2 baseTexCoord : TEXCOORD0;
float4 color2_wrinkleWeight : TEXCOORD1;
float3 color1 : TEXCOORD2;
float3 worldVertToEyeVector : TEXCOORD3;
float3x3 tangentSpaceTranspose : TEXCOORD4;
// second row : TEXCOORD5;
// third row : TEXCOORD6;
float4 worldPos_projPosZ : TEXCOORD7;
};
//-----------------------------------------------------------------------------
// Main shader entry point
//-----------------------------------------------------------------------------
VS_OUTPUT main( const VS_INPUT v )
{
VS_OUTPUT o;// = ( VS_OUTPUT )0;
float4 vPosition = v.vPos;
float3 vNormal = v.vNormal;
float4 vTangent = v.vUserData;
// Flexes coming in from a separate stream (contribution masked by cFlexScale.x)
vPosition.xyz += v.vPosFlex * cFlexScale.x;
vNormal += v.vNormalFlex * cFlexScale.x;
vTangent.xyz += v.vNormalFlex * cFlexScale.x; // Tangent uses normal deltas
// Set the wrinkle map coefficient
o.color2_wrinkleWeight.w = abs(v.vPosFlex) / 2.0f;
// Perform skinning
float3 worldNormal, worldPos, worldTangentS, worldTangentT;
SkinPositionNormalAndTangentSpace( g_NumBones, vPosition, vNormal, vTangent,
v.vBoneWeights, v.vBoneIndices, worldPos,
worldNormal, worldTangentS, worldTangentT );
// Always normalize since flex path is controlled by runtime
// constant not a shader combo and will always generate the normalization
worldNormal = normalize( worldNormal );
worldTangentS = normalize( worldTangentS );
worldTangentT = normalize( worldTangentT );
// Transform into projection space
o.projPos = mul( float4( worldPos, 1 ), cViewProj );
o.fog = CalcFog( worldPos, o.projPos, g_FogType );
// Needed for water fog alpha and diffuse lighting
// FIXME: we shouldn't have to compute this all the time.
o.worldPos_projPosZ = float4( worldPos, o.projPos.z );
// Needed for specular
o.worldVertToEyeVector = VSHADER_VECT_SCALE * (cEyePos - worldPos);
// Compute bumped lighting
// FIXME: We shouldn't have to compute this for unlit materials
o.color1 = GetVertexColorForLight( worldPos, worldNormal, 0, g_LocalLightType0 );
o.color2_wrinkleWeight.xyz = GetVertexColorForLight( worldPos, worldNormal, 1, g_LocalLightType1 );
// Base texture coordinate transform
o.baseTexCoord.x = dot( v.vTexCoord0, cBaseTexCoordTransform[0] );
o.baseTexCoord.y = dot( v.vTexCoord0, cBaseTexCoordTransform[1] );
// Tangent space transform
o.tangentSpaceTranspose[0] = float3( worldTangentS.x, worldTangentT.x, worldNormal.x );
o.tangentSpaceTranspose[1] = float3( worldTangentS.y, worldTangentT.y, worldNormal.y );
o.tangentSpaceTranspose[2] = float3( worldTangentS.z, worldTangentT.z, worldNormal.z );
return o;
}
# |
Change |
User |
Description |
Committed |
|
#1
|
5817 |
Knut Wikstrom |
Added base Valve SDK code to start modding. |
|
|