home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
GameStar 2006 February
/
Gamestar_81_2006-02_dvd.iso
/
Dema
/
roboblitz_demo.msi
/
disk1.cab
/
LocalVertexFactory.cg
< prev
next >
Wrap
Text File
|
2005-03-31
|
2KB
|
64 lines
/*=============================================================================
LocalVertexFactory.hlsl: Local vertex factory shader code.
Copyright 2004 Epic Games, Inc. All Rights Reserved.
Revision history:
* Branched from HLSL code by Daniel Vogel.
=============================================================================*/
float4x4 LocalToWorld;
float3x3 WorldToLocal;
float4 ShadowCoordinateScaleBias;
struct vertexInput
{
float4 Position : POSITION;
half3 TangentX : TEXCOORD6; // TANGENT
half3 TangentY : TEXCOORD7; // BINORMAL
half3 TangentZ : NORMAL; // NORMAL
#if NUM_USER_TEXCOORDS
float2 UserTexCoords[NUM_USER_TEXCOORDS] : TEXCOORD0;
#endif
float2 LightMapCoordinate : COLOR;
};
struct vertexFactoryInterpolants
{
float2 LightMapCoordinate : TEXCOORD0;
#if NUM_USER_TEXCOORDS
float2 UserTexCoords[NUM_USER_TEXCOORDS] : TEXCOORD1;
#endif
};
userShaderInput getUserShaderInputs(vertexFactoryInterpolants Interpolants)
{
userShaderInput Result;
#if NUM_USER_TEXCOORDS
for(int CoordinateIndex = 0;CoordinateIndex < NUM_USER_TEXCOORDS;CoordinateIndex++)
Result.UserTexCoords[CoordinateIndex] = Interpolants.UserTexCoords[CoordinateIndex];
#endif
Result.UserVertexColor = 1;
Result.TangentNormal = Result.TangentCameraVector = Result.TangentReflectionVector = Result.TangentLightVector = 0;
return Result;
}
float2 getLightMapCoordinate(vertexFactoryInterpolants Interpolants)
{
return Interpolants.LightMapCoordinate;
}
float4 vertexFactoryGetWorldPosition(vertexInput Input,out vertexFactoryInterpolants Interpolants)
{
#if NUM_USER_TEXCOORDS
for(int CoordIndex = 0;CoordIndex < NUM_USER_TEXCOORDS;CoordIndex++)
Interpolants.UserTexCoords[CoordIndex] = Input.UserTexCoords[CoordIndex];
#endif
Interpolants.LightMapCoordinate = Input.LightMapCoordinate * ShadowCoordinateScaleBias.xy + ShadowCoordinateScaleBias.wz;
return mul(LocalToWorld,Input.Position);
}
float3 vertexFactoryWorldToTangentSpace(vertexInput Input,half3 WorldVector)
{
return mul(float3x3(Input.TangentX,Input.TangentY,Input.TangentZ) / 127.5,mul(WorldToLocal,WorldVector));
}