Skip to content

Instantly share code, notes, and snippets.

@zachwlewis
Created September 17, 2010 04:47
Show Gist options
  • Save zachwlewis/583730 to your computer and use it in GitHub Desktop.
Save zachwlewis/583730 to your computer and use it in GitHub Desktop.
//=============================================================================
// [GLOBALS]
//=============================================================================
float4x4 World;
float4x4 Projection;
int ShaderIndex = 0;
float3 DiffuseColor;
struct VertexPositionColor
{
float4 Position : POSITION0;
float4 Color : COLOR0;
};
//=============================================================================
// [FUNCTIONS]
//=============================================================================
float4 DiffuseVertexShader(float4 input : POSITION0) : POSITION0
{
float4 output = mul(input, World);
return mul(output, Projection);
}
float4 DiffusePixelShader(float4 input : POSITION0) : COLOR0
{
return float4( DiffuseColor, 1.0 );
}
VertexPositionColor VertexColorVertexShader(VertexPositionColor input)
{
VertexPositionColor output;
output.Position = mul(input.Position, World);
output.Position = mul(output.Position, Projection);
output.Color = input.Color;
return output;
}
float4 VertexColorPixelShader(VertexPositionColor input) : COLOR0
{
return input.Color;
}
VertexShader VertexShaders[2] =
{
compile vs_2_0 DiffuseVertexShader(),
compile vs_2_0 VertexColorVertexShader()
};
PixelShader PixelShaders[2] =
{
compile ps_2_0 DiffusePixelShader(),
compile ps_2_0 VertexColorVertexShader()
};
//=============================================================================
// [TECHNIQUES]
//=============================================================================
technique DefaultTechnique
{
pass
{
VertexShader = (VertexShaders[ShaderIndex]);
PixelShader = (PixelShaders[ShaderIndex]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment