   Pixel Shader Problem
  Why does this gives an error when trying to load the effect?float4x4 World;float4x4 WorldIT;float4x4 Wvp;float4x4 ViewI;struct appdata {    float3 Position: POSITION;    float4 Normal: NORMAL;};struct vertexOutput {    float4 HPosition : POSITION;    float3 WorldNormal : TEXCOORD0;    float4 Pos : TEXCOORD1;};vertexOutput VertexShader_VS(appdata IN) {    vertexOutput OUT = (vertexOutput)0;    OUT.WorldNormal = mul(IN.Normal,WorldIT).xyz;    OUT.HPosition = mul(float4(IN.Position.xyz,1.0),Wvp);OUT.Pos = float4(IN.Position.xyz,1.0);return OUT;}float4 PixelShader_PS(vertexOutput IN) : COLOR {if (IN.HPosition.x > 100) {return float4(float3(0.0, 0.0, 1.0),1.0);} else {return float4(float3(1.0, 0.0, 0.0),1.0);}}technique Main {    pass p0 {   VertexShader = compile vs_1_1 VertexShader_VS();   PixelShader = compile ps_3_0 PixelShader_PS();    }}The problem starts when I use "IN.HPosition.x" in my pixel shader. Without it everything works fine.   
  I think you need to declare the vertex position input for the pixel shader using the SV_POSITION semantic instead.float4 HPosition : SV_POSITION;;I think he's using DirectX9, so the POSITION semantic is not passed from the vertex shader to the pixel shader, even though you specify it as the output from the vertex shader. This is something particular to the POSITION semantic (the compiler will tell you it's an invalid input semantic for the pixel shader), but unfortunately I don't know why this is exactly.In order to fix this, you can pass the position as another semantic that's properly passed to the pixel shader. One of the TEXCOORD semantics is often (ab)used for this. You already seem to have such a member called Pos defined in the vertex shader output, which might be what you want to use in your pixel shader. If so, replacing this lineif (IN.HPosition.x > 100) {with thisif (IN.Pos.x > 100) {should do the trick. This Pos might also be closer to what you want, since HPosition is in post-projection coordinates which are in the range [(-1,-1);(1,1)] for the visible area of your world, so checking if the HPosition.x > 100 might not be useful.;  Changing this:if (IN.HPosition.x > 100) {to this:if (IN.Pos.x > 100) {won't work for me, because I want to know exactly what you said,if the pixel position is in the screen or out of it.SV_POSITION didn't work.   ;  I finally understood what you said. I changed the code and now I know if a pixel is in the visible area or not. Here is the code:float4x4 World;float4x4 WorldIT;float4x4 Wvp;float4x4 ViewI;struct appdata {    float3 Position: POSITION;    float4 Normal: NORMAL;};struct vertexOutput {    float4 HPosition : POSITION;    float3 WorldNormal : TEXCOORD0;    float4 Pos : TEXCOORD1;    float4 HPos : TEXCOORD2;};vertexOutput VertexShader_VS(appdata IN) {    vertexOutput OUT = (vertexOutput)0;    OUT.WorldNormal = mul(IN.Normal,WorldIT).xyz;    OUT.HPosition = mul(float4(IN.Position.xyz,1.0),Wvp);    OUT.HPos = mul(float4(IN.Position.xyz,1.0),Wvp);    OUT.Pos = float4(IN.Position.xyz,1.0);    return OUT;}float4 PixelShader_PS(vertexOutput IN) : COLOR {if (((IN.HPos.x / IN.HPos.w) > 1.0) || ((IN.HPos.x / IN.HPos.w) < -1.0) || ((IN.HPos.y / IN.HPos.w) > 1.0) || ((IN.HPos.y / IN.HPos.w) < -1.0)) {return float4(float3(0.0, 0.0, 1.0),1.0);} else {return float4(float3(1.0, 0.0, 0.0),1.0);}}technique Main {    pass p0 {   VertexShader = compile vs_1_1 VertexShader_VS();   PixelShader = compile ps_3_0 PixelShader_PS();    }}Thank you very much!   ;  you could also shrink that condition toif (abs(IN.HPos.xy / IN.HPos.w) > 1.0){return ....}...   ;Quote:Original post by ZosimasI finally understood what you said.Glad to hear it worked out and sorry that I wasn't clearer in the first place [smile]One final nitpick I noticed is that you're mixing VS_1_1 and PS_3_0 shaders. This can cause problems on older SM3 hardware and will cause an error when running the debug runtimes ("ps_3_0 shader can only be used with vs_3_0+ shader"), so you might want to consider switching to PS_2_0 for compatibility or compile the vertex shader to VS_3_0 if you want to keep PS_3_0 as the pixel shader target.