• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker Alpha Blend Modes are resulting in only 0/1 alpha values

AnalogF6

Member
I am trying to do a simple silhouette effect based on the Dynamic Rendering Masks example here:

https://www.yoyogames.com/blog/430/dynamic-rendering-masks

This works exactly as I expect except for one thing: I cannot set the alpha to anything other than 1 in the final draw action. If I change alpha blending anywhere else, it either doesn't draw at all or it draws everything with a 1 for alpha.

Essentially, when a player character is behind a wall, it should use the wall as a mask to draw the player's silhouette on top of the wall.

The code should disable alpha blending, draw a rectangle across the whole screen with alpha values set to 0, then re-enable alpha, draw the wall to set 1s where the tiles are, then finally draw the silhouette. This should, and does, only draw where the character is, but I can't seem to figure out how to get the tileset to draw the silhouette at a partially blended mode. I tried setting alpha to .5 and .1, no luck.

Here's the code.

Code:
//step 1
gpu_set_blendenable(false)
gpu_set_colorwriteenable(false,false,false,true);
draw_set_alpha(0);
draw_rectangle(0,0, room_width,room_height, false);
          
//step 2
draw_set_alpha(1)
draw_tilemap(tilemap,0,0)
gpu_set_blendenable(true);
gpu_set_colorwriteenable(true,true,true,true);
          
          
//step 3
gpu_set_blendmode_ext(bm_dest_alpha,bm_inv_dest_alpha);
gpu_set_alphatestenable(true);          
draw_sprite_part_ext(sprite_index,image_index,0,0,16,16,x,y,1,1,c_black,.2)
 
//step 4        
gpu_set_alphatestenable(false);
gpu_set_alphatestenable(false);
gpu_set_blendmode(bm_normal);
As above:
upload_2019-7-29_16-8-11.png

Desired Result:

upload_2019-7-29_16-13-3.png
 
Last edited:

AnalogF6

Member
I found the solution. I draw the tilemap to a surface, draw that to the screen, then set alpha to .5 and draw the sprite color data to the screen, then finally set the alpha back to normal (1).
 
Top