Thanks Rigoletto (you must excuse because thats the first shader I'm triing to program and it's very hard to learn with my bad english
)
So here is my 2nd try
Code:
material material_test
{
effect
"
float4x4 matWorldViewProj;
texture entSkin1;
sampler ScreenProjSampler = sampler_state
{
texture = <entSkin1>;
magfilter = LINEAR;
minfilter = LINEAR;
mipfilter = LINEAR;
};
float3 mainVS(float4 Pos : POSITION0) : TEXCOORD0
{
float4 toScreen = mul(float4(Pos.xyz,1),matWorldViewProj);
float3 tex0;
tex0.x = 0.5f * (toScreen.z+toScreen.x);
tex0.y = 0.5f * (toScreen.z-toScreen.y);
tex0.z = 1.0f * toScreen.w;
return tex0;
}
float4 mainPS(float3 tex0 : TEXCOORD0) : COLOR0
{
float2 screenCoords;
screenCoords.x = tex0.x/tex0.z;
screenCoords.y = tex0.y/tex0.z;
float4 ScreenSpaceSample = tex2D(ScreenProjSampler,screenCoords.xy);
return ScreenSpaceSample;
}
technique test
{
pass p0
{
VertexShader = compile vs_2_0 mainVS();
PixelShader = compile ps_2_0 mainPS();
}
}
";
}
Now I get an error with the position in the vs and i can't understand why.