Glatzemann 40c951e02b added licensing information to tools files
added a shader folder for the stock shaders
started the StockShaderCodeGenerator tool
added a tools solution file
added a bin folder in tools folder for precompiled tools and changed tools project files
removed StockEffects content project from solution and added the effect files to the shader folder for reference
2011-11-15 06:46:22 +00:00

59 lines
1.3 KiB
HLSL

//-----------------------------------------------------------------------------
// Common.fxh
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
float ComputeFogFactor(float4 position)
{
return saturate(dot(position, FogVector));
}
void ApplyFog(inout float4 color, float fogFactor)
{
color.rgb = lerp(color.rgb, FogColor * color.a, fogFactor);
}
void AddSpecular(inout float4 color, float3 specular)
{
color.rgb += specular * color.a;
}
struct CommonVSOutput
{
float4 Pos_ps;
float4 Diffuse;
float3 Specular;
float FogFactor;
};
CommonVSOutput ComputeCommonVSOutput(float4 position)
{
CommonVSOutput vout;
vout.Pos_ps = mul(position, WorldViewProj);
vout.Diffuse = DiffuseColor;
vout.Specular = 0;
vout.FogFactor = ComputeFogFactor(position);
return vout;
}
#define SetCommonVSOutputParams \
vout.PositionPS = cout.Pos_ps; \
vout.Diffuse = cout.Diffuse; \
vout.Specular = float4(cout.Specular, cout.FogFactor);
#define SetCommonVSOutputParamsNoFog \
vout.PositionPS = cout.Pos_ps; \
vout.Diffuse = cout.Diffuse;