Original Post
Hi, I have a strange problem with my HLSL fog shader. Here it is: The compiler complains here: "Invalid input semantic: POSITION" Now I understand that you can't directly pass a POSITION to the pixel shader, so if I change this to use a TEXCOORD1 instead, I get this: "Vertex shader must minimally write all four components of POSITION" What's going on here? The new_material.fx in NVidia's FX Composer uses the same semantics and their's compiles fine. regards
float4x4 matWVP : WorldViewProjection;
float3 cameraPos;
float fogNear : FOGNEAR = 0;
float fogFar : FORGAR = 20;
float4 fogColor : FOGCOLOR = float4(1, 1, 1, 1);
sampler Texture;
//------------------------------------
struct VS_INPUT {
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};
struct VS_OUTPUT {
float4 Position : POSITION;
float2 TexCoord : TEXCOORD0;
};
//------------------------------------
VS_OUTPUT VS_Simple(VS_INPUT input)
{
VS_OUTPUT output;
output.Position = mul(input.Position, matWVP);
output.TexCoord = input.TexCoord;
return output;
}
float4 PS_Fog(VS_OUTPUT input) : COLOR
{
float4 color = tex2D(Texture, input.TexCoord);
float d = length(input.Position - cameraPos);
float l = saturate((d - fogNear) / (fogFar - fogNear));
return lerp(color, fogColor, l);
}
//-----------------------------------
technique textured
{
pass p0
{
VertexShader = compile vs_1_1 VS_Simple();
PixelShader = compile ps_2_0 PS_Fog();
}
}
struct VS_OUTPUT {
float4 Position : POSITION;