# Purple screen when using vertex shaders

Alright, so I've tried everything I can think of. I've put in over 10 hours into this crap, but nothing seems to work (tried multiple online tutorials as well). Always purple screen.

Here is the simple .fx code:

float4x4 matrixTransform;

{
float2 Coords : TEXCOORD0;
float4 Position : POSITION;
};
{
float2 Coords : TEXCOORD0;
};

{

output.Position = mul(input.Position, matrixTransform);
output.Coords = input.Coords;

return output;
}

{

return tex2D(textureSampler, input.Coords);
}

technique Technique1
{
pass Pass1
{
}
}


Here is how I'm assigning MatrixTransform:

Matrix Projection = Matrix.CreateOrthographic(GameSettings.VectorResolution.X, GameSettings.VectorResolution.Y, -1, 1);

Matrix halfPixelOffset = Matrix.CreateTranslation(-0.5f, -0.5f, 0);
Projection = halfPixelOffset * Projection;

x.Parameters["matrixTransform"].SetValue(camera.Projection);


Note: the above code works just fine when the vertex shader is disabled. Everything displays like normal.

I'd appreciate it if someone could point out what I'm doing wrong.

Thanks.

EDIT:

I'm currently using multiple shaders in my code that do not use a vertex shader (pixel shaders). I am also making use of render targets. This leads me to believe there is something wrong with the vertex shader code, not the render targets.

EDIT 2:

public Matrix World { get; protected set; }
public Matrix Projection { get; protected set; }
public Matrix View(Vector2 parallax)
{
return Matrix.CreateTranslation(new Vector3(-Position * parallax, 0.0f)) *
Matrix.CreateTranslation(new Vector3(-Origin, 0.0f)) *
Matrix.CreateRotationZ(Rotation) *
Matrix.CreateScale(Zoom, Zoom, 1) *
Matrix.CreateTranslation(new Vector3(Origin, 0.0f));
}

{
World = Matrix.Invert(View(Vector2.One));
Projection = Matrix.CreateOrthographic(GameSettings.VectorResolution.X, GameSettings.VectorResolution.Y, -1, 1);
Matrix halfPixelOffset = Matrix.CreateTranslation(-0f, -0f, 0);
Projection *= halfPixelOffset;
}


Zoom is 1f, Rotation always remains unchanged, and Origin is center of screen.

• You should described what you're trying to achieve. – Vaillancourt Mar 29 '16 at 2:17
• No purple screen? I don't know how can be much more clear than this. When ever I use a vertex shader, purple screen (e.g, nothing draws on screen when in use). I want to be able to make use of the vertex shader, not be restricted to pixel shaders only. – Shyy Guy Mar 29 '16 at 2:19
• You're getting the purple screen, even while clearing the backbuffer with- for example Cornflowerblue? – Felsir Mar 29 '16 at 5:21
• This was a big topic years ago on the XNA forums. See these search results: xboxforums.create.msdn.com/search/… Also, it was fixed often by this answer: xboxforums.create.msdn.com/forums/p/95682/571781.aspx#571781 – Steve H Mar 29 '16 at 11:39
• I'm not on my usual machine so I can't confirm, but I'm reasonably sure that the output of the vertex shader has to align with the input of the pixel shader. Maybe try using VShader input instead of PShader input? I know this has worked on all the shaders I've written previously. Also might pay to check that you've calculated the view/projection matrix correctly. – Seta Mar 29 '16 at 21:31