Legacy GM 2D sprite has no alpha when in front of 3D background object? [SOLVED]

S

SilverTom93

Guest
So basically, I've had the old GameMaker 8 for a few years and have made a decent amount of 2D games with it. Recently I've got GameMaker Studio (v1.4.1757) and have been learning how to code things in 3D using GML, so I'm trying to remake one of my old game engines.
I've now got some nice 3D platforms and blocks in the background, but here's the problem:

When the player's sprite moves in front of any background scenery, it for some reason makes the scenery invisible behind the sprite's size box thing. I've checked the actual sprite itself, which does have transparent edges, so it's a bit confusing... There's probably a really simple solution for this, or maybe just an extra option I needed to tick, or a few lines of code, but I'm stumped. I've used loads of simple 2D Drag-N-Drop stuff in the past, but I've never used 3D with GameMaker before xD Any help will be really appreciated! :)

(This is also my first time using these forums) InfaBall 3D graphics glitch2.png
 

Mike

nobody important
GMC Elder
This is due to render order. as long as you render all your 3D stuff first, then disable the Z buffer, you should be fine. You should "sort" all your 2D sprites and render after opaque stuff.
 
S

SilverTom93

Guest
This is due to render order. as long as you render all your 3D stuff first, then disable the Z buffer, you should be fine. You should "sort" all your 2D sprites and render after opaque stuff.
No idea how to do any of that or what it all means xD It's fixed now though!
 
What he was saying, and this is for when you want to draw stuff that is partially transparent (i.e. no alpha test), you want to make sure that stuff draws after everything that is (optically) behind it. You'll need to make sure your zbuffer doesn't interfere with this process though. So you should turn off d3d_set_hidden just before drawing your partially-transparent stuff. That will cause things to be drawn no matter what is already on the zbuffer.

so...
1. stuff with partial alpha is drawn after things that are behind it have already been drawn.
2. if using zbuffer, turn off d3d_set_hidden just before drawing the partial alpha stuff. (or else make sure they are nearer to the camera than everything behind them). You may want to turn off the zwriting at this point in case you don't want the alpha stuff to possibly interfere with anything drawn afterward.
 
Last edited:
Top