Game Development Reference
In-Depth Information
matrix ViewMatrix;
matrix ViewProjMatrix;
vector AmbientMtrl;
vector DiffuseMtrl;
vector LightDirection;
//
// Global variables used to hold the ambient light intensity (ambient
// light the light source emits) and the diffuse light
// intensity (diffuse light the light source emits). These
// variables are initialized here in the shader.
//
vector DiffuseLightIntensity = {0.0f, 0.0f, 1.0f, 1.0f};
vector AmbientLightIntensity = {0.0f, 0.0f, 0.2f, 1.0f};
//
// Input and Output structures.
//
struct VS_INPUT
{
vector position : POSITION;
vector normal
: NORMAL;
};
struct VS_OUTPUT
{
vector position : POSITION;
vector diffuse : COLOR;
};
//
// Main
//
VS_OUTPUT Main(VS_INPUT input)
{
// zero out all members of the output instance.
VS_OUTPUT output = (VS_OUTPUT)0;
//
// Transform position to homogeneous clip space
// and store in the output.position member.
//
output.position = mul(input.position, ViewProjMatrix);
//
// Transform lights and normals to view space. Set w
// components to zero since we're transforming vectors
// here and not points.
//
LightDirection.w = 0.0f;
Search WWH ::




Custom Search