I’m have a barebones shader. It’s supposed to return the sprite but all I get is a blue screen. If I comment out the vertex shader it works. But I can’t do that because I plan to add some code in the vertex shader.
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0
#define PS_SHADERMODEL ps_4_0
#endif
sampler2D myTexture : register(s0);
matrix WorldViewProjection;
struct VertexShaderInput
{
float4 Position : POSITION0;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
VertexShaderOutput MainVS(VertexShaderInput input)
{
VertexShaderOutput output = (VertexShaderOutput)0;
output.Position = mul(input.Position, WorldViewProjection);
output.Color = input.Color;
output.TextureCoordinates = input.TextureCoordinates;
return output;
}
float4 MainPS(VertexShaderOutput input) : COLOR
{
return tex2D(myTexture, input.TextureCoordinates);
}
technique BasicColorDrawing
{
pass P0
{
VertexShader = compile VS_SHADERMODEL MainVS();
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
/// draw code.
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, effect);
spriteBatch.Draw(texture: texture, destinationRectangle: new Rectangle(0, 0, 800, 600), sourceRectangle: new Rectangle(0, 0, texture.Width, texture.Height), color: Color.White, layerDepth: 0.5f,
rotation:0, origin: Vector2.Zero, effects: SpriteEffects.None);
spriteBatch.End();
base.Draw(gameTime);