Trim it down alter it as needed, this is copy pasted.
private VertexPositionNormalColorUv[] screenQuadVertices;
private int[] screenQuadIndices;
private void CreateScreenQuad()
{
float z = 0.0f;
float adjustment = .0f;
float scale = 2f; // scale 2 and matrix identity passed straight thru is litterally orthographic
//screenQuadVertices = new VertexPositionColorTexture[4];
screenQuadVertices = new VertexPositionNormalColorUv[4];
screenQuadVertices[0].Position = new Vector3((adjustment - 0.5f) * scale, (adjustment - 0.5f) * scale, z);
screenQuadVertices[0].Normal = Vector3.Backward;
screenQuadVertices[0].Color = Color.White;
screenQuadVertices[0].TextureCoordinateA = new Vector2(0f, 1f);
screenQuadVertices[1].Position = new Vector3((adjustment - 0.5f) * scale, (adjustment + 0.5f) * scale, z);
screenQuadVertices[1].Normal = Vector3.Backward;
screenQuadVertices[1].Color = Color.White;
screenQuadVertices[1].TextureCoordinateA = new Vector2(0f, 0f);
screenQuadVertices[2].Position = new Vector3((adjustment + 0.5f) * scale, (adjustment - 0.5f) * scale, z);
screenQuadVertices[2].Normal = Vector3.Backward;
screenQuadVertices[2].Color = Color.White;
screenQuadVertices[2].TextureCoordinateA = new Vector2(1f, 1f);
screenQuadVertices[3].Position = new Vector3((adjustment + 0.5f) * scale, (adjustment + 0.5f) * scale, z);
screenQuadVertices[3].Normal = Vector3.Backward;
screenQuadVertices[3].Color = Color.White;
screenQuadVertices[3].TextureCoordinateA = new Vector2(1f, 0f);
screenQuadIndices = new int[6];
screenQuadIndices[0] = 0;
screenQuadIndices[1] = 1;
screenQuadIndices[2] = 2;
screenQuadIndices[3] = 2;
screenQuadIndices[4] = 1;
screenQuadIndices[5] = 3;
}
public void DrawUserIndexPrimitiveScreenQuad(GraphicsDevice gd)
{
gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, screenQuadVertices, 0, screenQuadVertices.Length, screenQuadIndices, 0, 2, VertexPositionNormalColorUv.VertexDeclaration);
}
vertex def
public struct VertexPositionNormalColorUv : IVertexType
{
public Vector3 Position;
public Color Color;
public Vector3 Normal;
public Vector2 TextureCoordinateA;
public static VertexDeclaration VertexDeclaration = new VertexDeclaration
(
new VertexElement(VertexElementByteOffset.PositionStartOffset(), VertexElementFormat.Vector3, VertexElementUsage.Position, 0),
new VertexElement(VertexElementByteOffset.OffsetColor(), VertexElementFormat.Color, VertexElementUsage.Color, 0),
new VertexElement(VertexElementByteOffset.OffsetVector3(), VertexElementFormat.Vector3, VertexElementUsage.Normal, 0),
new VertexElement(VertexElementByteOffset.OffsetVector2(), VertexElementFormat.Vector2, VertexElementUsage.TextureCoordinate, 0)
);
VertexDeclaration IVertexType.VertexDeclaration { get { return VertexDeclaration; } }
}
/// <summary>
/// This is a helper struct for tallying byte offsets
/// </summary>
public struct VertexElementByteOffset
{
public static int currentByteSize = 0;
public static int PositionStartOffset() { currentByteSize = 0; var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
public static int Offset(float n) { var s = sizeof(float); currentByteSize += s; return currentByteSize - s; }
public static int Offset(Vector2 n) { var s = sizeof(float) * 2; currentByteSize += s; return currentByteSize - s; }
public static int Offset(Color n) { var s = sizeof(int); currentByteSize += s; return currentByteSize - s; }
public static int Offset(Vector3 n) { var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
public static int Offset(Vector4 n) { var s = sizeof(float) * 4; currentByteSize += s; return currentByteSize - s; }
public static int OffsetFloat() { var s = sizeof(float); currentByteSize += s; return currentByteSize - s; }
public static int OffsetColor() { var s = sizeof(int); currentByteSize += s; return currentByteSize - s; }
public static int OffsetVector2() { var s = sizeof(float) * 2; currentByteSize += s; return currentByteSize - s; }
public static int OffsetVector3() { var s = sizeof(float) * 3; currentByteSize += s; return currentByteSize - s; }
public static int OffsetVector4() { var s = sizeof(float) * 4; currentByteSize += s; return currentByteSize - s; }
}
relevant shader code is basic
//_______________________________________________________________
// structs ScreenQuadDraw
//_______________________________________________________________
struct VertexShaderInputScreenQuad
{
float4 Position : POSITION0;
float3 Normal : NORMAL0;
float4 Color : COLOR0;
float2 TexureCoordinateA : TEXCOORD0;
};
struct VertexShaderOutputScreenQuad
{
float4 Position : SV_Position;
//float3 Normal : NORMAL0;// not needed yet
float4 Color : COLOR0;
float2 TexureCoordinateA : TEXCOORD0;
};
struct PixelShaderOutputScreenQuad
{
float4 Color : COLOR0;
};
VertexShaderOutputScreenQuad VertexShaderScreenQuadDraw(VertexShaderInputScreenQuad input)
{
VertexShaderOutputScreenQuad output;
output.Position = mul(input.Position, gworld); // basically matrix identity
output.Color = input.Color;
output.TexureCoordinateA = input.TexureCoordinateA;
return output;
}
PixelShaderOutputScreenQuad PixelShaderScreenQuadDraw(VertexShaderOutputScreenQuad input)
{
PixelShaderOutputScreenQuad output;
output.Color = tex2D(TextureSamplerA, input.TexureCoordinateA); // *input.Color;
return output;
}
technique ScreenQuadDraw
{
pass
{
VertexShader = compile VS_SHADERMODEL VertexShaderScreenQuadDraw();
PixelShader = compile PS_SHADERMODEL PixelShaderScreenQuadDraw();
}
}
the call looks like this. sorry its a bit sloppy.
public void DrawScreenQuad(Texture2D t)
{
//GraphicsDevice.RasterizerState = RasterizerState.CullNone;
myeffect.Parameters["TextureA"].SetValue(t);
myeffect.Parameters["gworld"].SetValue(Matrix.Identity * Matrix.CreateScale(1f));
myeffect.CurrentTechnique = myeffect.Techniques["ScreenQuadDraw"];
foreach (EffectPass pass in myeffect.CurrentTechnique.Passes)
{
pass.Apply();
pvs.DrawUserIndexPrimitiveScreenQuad(GraphicsDevice);
}
}
you should be able to peice it together as you like from that quickly.