• 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 [SOLVED] Surfaces & Blendmodes?

Neptune

Member
I have two surfaces, S0 & S1. Both surfaces are filled with various color at 1.0 alpha.
When I set the drawing target to S1, and draw an opaque black sprite (bm_normal), it seems to chang the alpha of that entire area on the surface... allowing S0 to been seen underneath.
upload_2019-8-19_9-38-18.png
Is there a blendmode or a way I can just pancake opaque sprites onto S1, without cutting holes into it?
Any info is appreciated!
 

Neptune

Member
Idk if its noteworthy, but the black opaque spot is being drawn using:
Code:
event_perform(ev_draw,0);
In psuedo the drawing process is:
Code:
surface_set_target(S1);

   //FILL SURF WITH COLOR
   //RENDER OPAQUE SPOTS WITH 'event_perform'

surface_reset_target();

//DRAW SURF
Where S0 is just the application surface.
 

Neptune

Member
Creating a blank shader and adding
Code:
gl_FragColor.a = 1.0;
seems to solve the issue when used to draw S1...
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
    gl_FragColor = v_vColour * texture2D(gm_BaseTexture, v_vTexcoord );
    gl_FragColor.a = 1.0;
}
Uhh, this is all addressed here: https://www.yoyogames.com/blog/60/alpha-and-surfaces
However, all of the mentioned solution-functions don't seem to exist in GMS2, and this was the only way I could understand to go about fixing it.

Long story short, the alpha equation is:
Code:
final_alpha = (source_alpha * source_alpha) + (destination_alpha * (1-source_alpha));
So, a source of 0.5, and destination of 1.0 results in 0.75 or... holes in your surface :D
 
Top