If you need a fast way to draw tilemaps you can have a texture or rendertarget as the tilemap and use a shader to draw it. You can skip the constraction of thousand of quads, dividing the map into chucks for culling and rendering thousands of Vertices. You can see an example of a shader in my repo here.
Now…
- Spritebatch is using the so called Screenspace coordinates.It constructs the Projection by calling Matrix.CreateOrthographicOffCenter(left:0, right:vp.Width, bottom:vp.Height, top:0, zNearPlane:0, zFarPlane:-1);
notice how [top -> bottom] is defined as [0 -> vp.Height], resulting in reversing Y-axis.
Normally you would call
Matrix.CreateOrthographicOffCenter(left:0, right:vp.Width, bottom:0, top:vp.Height, zNearPlane:0, zFarPlane:-1);
to constructs a right-handed world space projection.
Therefore, you can do the same in your Projection/BasicEffect to draw primitives in screenspace just as spriteBatch.
(in 3.7.1 and prior you also need to add halfpixel for OpenGL platforms)
…or you can pass a BasicEffect in SpriteBatch.Begin(…) if you want to draw sprites in world space.
( just set BasicEffect.Projection/.View with you proj/view).
Personally I prefer to use SpriteBatch’s Screenspace only for GUI.
For game asset’s, sprites, 3D models, etc I use normal right-handed world space coordinates.
- SpriteEffect.TransformMatrix is what you pass at SpriteBatch.Begin(). It would be null if you don’t set it yourself.
I suppose you could use SpriteEffect to draw primitives but it’s best to avoid it. It’s a legacy class and it’s behavior keep changing, actually nowadays SpriteBatch could have used BasicEffect internally as it’s exactly the same shader code. Unfortunately someone made it public down the road for no good reason. Just pretend that it’s not there… as it doesn’t add anything in comparison to BasicEffect.