I'm new to shader programing, so excuse me if I made a stupid mistake.
I want to use the Pixelposition in worldspace in my pixelshader. Therefore I pass the pixelposition on the screen using the VPOS semantic to the pixel shader, to recalculate it afterwards in 3d space using an inverse projection matrix. I don't know if that would work, but the problem is a little bit more basic:
Although listed in the HLSL semantic list ( http://msdn.microsoft.com/en-us/library ... .aspx#VPOS ), the console gives out an error:
This is my shader.HLSL pixel shader compilation failed:
(35): error X4502: invalid input semantic 'VPOS'
Code: Select all
float4x4 worldViewProj; // World * View * Projection transformation
float3 lightDir; // Light direction
//float3 viewPos; // camera position
float4x4 invProj; // inverse Projection transformation
struct VS_OUTPUT
{
float4 Position : POSITION0; // vertex position
float3 lightDir : TEXCOORD0;
};
VS_OUTPUT vertexMain(in float4 vPosition : POSITION0)
{
VS_OUTPUT Output;
Output.Position = mul(vPosition, worldViewProj);
Output.lightDir = lightDir;
return Output;
}
struct PS_OUTPUT
{
float4 RGBColor : COLOR0; // Pixel color
};
sampler2D tex0;
PS_OUTPUT pixelMain(float4 Position : POSITION0,
float4 PixelPos : VPOS,
float3 lightDir : TEXCOORD0)
{
PS_OUTPUT Output;
float4 worldpos = mul(invProj, PixelPos);
float3 pos = float3(worldpos.x, worldpos.y, worldpos.z);
Output.RGBColor = float4(1, 1, 1, 0)*(dot(pos, lightDir));
return Output;
}
Thanks for helping!