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;
struct VShader
{
float2 Coords : TEXCOORD0;
float4 Position : POSITION;
};
struct PShader
{
float2 Coords : TEXCOORD0;
};
VShader VertexShaderFunction(VShader input)
{
VShader output;
output.Position = mul(input.Position, matrixTransform);
output.Coords = input.Coords;
return output;
}
float4 PixelShaderFunction(PShader input) : COLOR0
{
return tex2D(textureSampler, input.Coords);
}
technique Technique1
{
pass Pass1
{
VertexShader = compile vs_3_0 VertexShaderFunction();
PixelShader = compile ps_3_0 PixelShaderFunction();
}
}
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));
}
public void ReloadMatrices()
{
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.
VShader inputinstead ofPShader 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. \$\endgroup\$