r/gamemaker • • 7d ago

Help! NEED HELP with drawing sprites with transparency in my 2.5D game project

Hello guys, I recently tried creating something following the 2.5D tutorials, but I stumbled upon one issue that's making me lose my mind hahaha

Everytime some objects walk over each other, or some effect happens there with semi-transparent edges or with some amount of transparency, it just has rough edges and its cutting into the sprite behind it... idk how to explain it, but when i searched all i found was that it was something with gpu_aet_ztestenable(true); gpu_set_alphatestenable(true); (but i tried various combinations and nothing helped, only made it worse)....

If someone knows stuff about drawing in 2.5d please please i would be so grateful for your help ♥ I can send you the objects' codes. Also I hope the screenshost makes it clear what I mean lol.

4 Upvotes

1 comment sorted by

3

u/SillyTree-txt 6d ago

This is a common probleme when working with transparency in 3d (or as you called it 2.5d).
As for a technical explanation to why it happenes, the game can not guarantee that polygons with a greater distance to the camera will be drawn first, so this distance information is written into the depth buffer regardless of the pixels alpha value and following pixels will be discarded if their distance to the camera is greater than the one written into the depth buffer in that position on the screen.

The way Gamemaker normally handles this when using 2d (because 2d in Gamemaker is really just 3d in a trenchcoat) is that it doesn't use the depth buffer at all by default and relys on manually sorting the polygons by depth (from furthest to nearest) in the vertex buffers it creates. This built in process fails in 3d because the distance to the camera no longer is a single number (the built-in depth variable)

The best solutions for your probleme would probably be to render all transparent polygons after the rest of the game (so in a Draw End event) to sort them manually. (TBF, I'm not entirely sure if this works because I'm uncertain if the vertex batches resulting from the usual draw events will be submitted before the start of the draw end event, but it's worth a shot)

Alternativly, you could try avoid actual transperancy alltogether by using something like dithering instead. In case this sounds like an interesting option to you, check out this video: https://youtu.be/O8yx60VbpMA (I'd generally recommened that the first thing you should do when trying to do/fix something (especially in 3d/2.5d) is finding out if there's a DragoniteSpam video about it, they're usually great)