• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Windows 3D alpha value?

S

Steve Gal

Guest
Hello.

So I recently wanted to try the d3d functions for a map screen only as the game I am working on has a lot of different layers of mapping. I managed to get very far really quick since what I need is really basic.

I am using "d3d_draw_floor" just to draw simple flat textures on different height levels, so far so good.
I even got the draw_set_alpha_test function so they work as intended.

The issue starts when I wanted to introduce alpha changes depending on what layer of the map you are looking for, only showing the layer you are focusing on as full alpha, and the one below and above at lets say 50% alpha.
Is this even possible? When I set draw alpha, or image alpha for those objects they just disappear or have no effect.

Is there any way to alter a textures alpha outside of 0, and 1? any way to make them only semi transparent?
Thank you in advance.
 

kraifpatrik

(edited)
GameMaker Dev.
Hey man! So the reason why this happens is that in 3D you have a thing that is a called a z-buffer. What the z-buffer does is that it stores the distance from the camera to objects that you draw (for each pixel) and when you draw something, the distances are compared to what already is in the z-buffer and based on the z-buffer compare function the pixels are either kept or discarded. This is why objects do not overlap each other incorrectly independently on the order in which you draw them (or you can achieve a different result when messing with the functions etc). So what happens with the partially transparent pixels is that they still write to the z-buffer as if they were fully opaque, so they still do discard stuff that's drawed behind them. So the way to fix this could be (from the top of my head) disabling zwrite and ztest and drawing the layers in the correct order (from the once in the distance to the closests ones). Good luck mate!
 
S

Steve Gal

Guest
Thanks, that sounds way more work than worth, since I would have to order about 250 different objects on 10 different layers and still have a perspective projection, I think I'm better off using transforms to create fake 2d in 2d instead.
 
If your camera's orientation doesn't change, you only need to order your instances once.

Also keep in mind that only images that are semi-transparent need to be depth sorted. Everything that is either 0 or 100% alpha will be correctly handled by the zbuffer even if it is drawn out of order.
 
Top