38 lines
771 B
HLSL
38 lines
771 B
HLSL
float4 g_fogColor : register(c1);
|
|
|
|
sampler2D texDiffuse : register(s0);
|
|
|
|
struct PS_INPUT
|
|
{
|
|
float4 diffuse : COLOR;
|
|
float2 uv_albedo : TEXCOORD0;
|
|
float1 fog : TEXCOORD1;
|
|
};
|
|
|
|
struct PS_OUTPUT
|
|
{
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
PS_OUTPUT main(const PS_INPUT v)
|
|
{
|
|
PS_OUTPUT output;
|
|
|
|
// Sample maps
|
|
float4 diffuse = tex2D(texDiffuse, v.uv_albedo);
|
|
|
|
// Multiply by vertex color
|
|
float4 finalColor = diffuse * v.diffuse;
|
|
|
|
// Pre-multiply diffuse by alpha
|
|
finalColor.xyz = finalColor.xyz * finalColor.w;
|
|
|
|
// Multiply fog by alpha
|
|
float4 fogColor = g_fogColor * finalColor.w;
|
|
|
|
// Interpolate between diffuse color and fog color
|
|
output.color = lerp(fogColor.xyzw, finalColor.xyzw, v.fog.xxxx);
|
|
|
|
return output;
|
|
}
|