# VPOS in DX10?

## Recommended Posts

51mon    342
Hi I’m porting some code from DX9 to DX10. In DX9 I used an input semantic to the pixel shader called VPOS which informed me of the position of the fragment I was writing to. After reading the documentation I got the impression that this functionality was still around but when I tried to implement it I got this message: f:\Programing\MyEngine\MyEngine.fx(397,7): D3D10EffectCompiler: ERROR: No valid VertexShader-PixelShader combination could be found in Technique CreateRSM, Pass P0 (this is an issue because the GeometryShader is always NULL). I used the same code as I had used in DX9 (float2 ScreenPos : VPOS). Can I do something to solve this? Thanks
CREATE_RSM_PS_OUT CreateRSM_PS( CREATE_RSM_VS_OUT Input, float2 ScreenPos : VPOS)
{
CREATE_RSM_PS_OUT Output;

Output.Direction.xyz = normalize( Input.LightDir);
Output.Direction.w = 0.0f;
Output.Position = Input.LightPos;
Output.Color = g_MeshTexture.Sample( MeshTextureSampler, Input.TextureUV);

return Output;
}

technique10 CreateRSM
{
pass P0
{
}
}



##### Share on other sites
jollyjeffers    1570

Under D3D9 you couldn't use POSITION directly so you had a special-case VPOS for SM3 paths, which is a bit clunky really. With D3D10 they've simplified things and there's just the single semantic to rule them all [smile]

hth
Jack

##### Share on other sites
51mon    342
Quote:
 Original post by jollyjeffersTry SV_POSITION instead.Under D3D9 you couldn't use POSITION directly so you had a special-case VPOS for SM3 paths, which is a bit clunky really. With D3D10 they've simplified things and there's just the single semantic to rule them all [smile]hthJack

If you want to use SV_POSITION in the same way as VPOS then you have to transform the world position on the VS side with some orthogonal projection matrix, or am I wrong? I think VPOS in DX9 was convenient.

##### Share on other sites
jbarcz1    265

SV_POSITION in a pixel shader gives you the coordinates of the pixel in the render target (offset by 0.5).

Its kindof confusing that SV_POSITION in a pixel shader != SV_POSITION from the vertex shader, but thats how they did it.