Advertisement

XNA SpriteBatch depth with 3D objects

Started by September 28, 2019 09:36 PM
2 comments, last by george7378 5 years, 4 months ago

Hey everyone,

I'm using SpriteBatch to add some 2D elements to my 3D scene. Some of these elements are always in front of/behind the 3D objects so depth isn't always important, but others need to merge with the scene such that 3D geometry can partially obscure them based on depth. Does anyone know how I could do this with XNA?

I did something similar with raw D3D and C++ a few years ago, and I think ID3DXSPRITE.Draw() took care of it as you were able to pass position in as a 3D vector with a Z value for depth.

I guess I could always create a 3D quad and just render it with the rest of the scene, but if there's a more elegant way to do it with SpriteBatch then I'd love to know!

Thanks for the help.

Not sure if my reply is useful.

And I don't know if monogame is open source.Known this from your other post.

But just want to say,I have some experiment of FNA which is a open source XNA.

Work the same way as XNA.

With FNA you can trace function with break point and see where it goes.

So you know DX and C++ and you know those 3D rules,you may want to trace the source code and see how it works.

Then figure out how to do it.Also about how to use UnloadContent.

If you have ever played other XNA or XNA like framework game.

You can check their decompiled source code for reference.

There are still a lot of XNA family game.

Such as

Celeste

Saltand Sanctuary

Stardew Valley

Check and learn their coding style may help.

 

Advertisement

Hey - thanks for the reply! In the end I decided to use a flat 3D billboard instead of a sprite, so that depth is taken care of naturally. The effect is also a lot nicer, and closer to what I had in my mind!

This topic is closed to new replies.

Advertisement