SpriteBatch not working in same Draw as Basic Effect on some Computers

I will try to simplify the situation as best I can to see if anyone has any light bulb ideas as to the issue here.

I have an XNA/Monogame project that uses Basic Effect to draw some 3D objects as well as SpriteBatch to draw the HUD.

I launched the .exe on another PC and saw the game didn’t have sound and it was no longer drawing the HUD with spritebatch. Now, spritebatch will work. Just not if I’m using it in the same draw call as Basic Effect.

I managed to fix it by carefully going by realizing that spritebatch needed to be set to Immediate and not Deferred mode. I was able to modify the game easily enough to no longer use the Deferred mode. This fixed the issue. I wonder why one PC didn’t have an issue with this and another did. Something to do with DIrectX?

But here’s the new problem. I just put the game on another computer and once again it won’t draw Spritebatch and Basic Effect together. Now I don’t have any ideas.

Hey @DapperDave,

Without seein% your draw code, not really much anyone can help diagnose.

Is it possible for you to create a new minimal project that replicates the issue and put it in a git repo we can look at?

My original solution was to create a RenderTarget for the 3D render and then draw the 2D overlay HUD on top, that was wasting a round-trip to and from the video card.

The underlying issue is the depth value and scaling of the _spriteBatch.Draw() calls, by default the SpriteBatch draws a quad at 0,0,Depth scaled to the “preferred” dimensions and presented with an orthographic view.

To use SpriteBatch in a 3D context, the SpriteBatch.Begin(..., transformMatrix) transform matrix must be aligned very close to but beyond the near plane of the perspective matrix frustum. The matrix must include transform, rotation, and scaling from the near plane of the perspective view matrix.

Please note, I did this once 12 years ago in XNA. That code is long gone due to a hard drive crash.
Feedback would be appreciated with respect to the spritebatch transform matrix solution in MonoGame.

Do you have it set to BlendState.AlphaBlend?

Also check to see that both are using the same number system… for instance lots of places in Europe use 1.000 for 1,000 in the USA… This can cause things to draw in completely different places… That said without code im just guessing…