GML How to avoid drawing lights over background?


Hello everyone. I might use wrong terminology, but please try to understand me.

Long story short:
I need to set alpha of any pixel, which alpha !=0 to 1.

Long story long:
I want to avoid drawing lights over background.

Change picture from this to this

So here is what I do:

After drawing all backgrounds I copy application surface to sf_bg, than I clear application surface:

if !surface_exists(sf_bg)
    sf_bg = surface_create(obj_camera.width,obj_camera.height);

I perform this code inside draw_event of an object named obj_test_1
This object exists in instance layer just above background layers.

So, drawing continues, and when it's time to draw shadows, my application layer should look like this:

Well, that is wrong, and it is problem number 1:
It actualy looks like this:

This part:

Should look like this:

Whenever I try to draw something over the pixel of an application surface, alpha of that pixel becomes alpha of the source. I use bm_normal, so why does this happen I have no idea.

So first of all I need to set alpha of any pixel, which alpha is not zero to one. How can I do this?

But any way, I continue to do what I do. I draw shadows and lights over my application surface, and by some miracle (or because I use bm_multiply ( gpu_set_blendmode_ext(bm_dest_colour,bm_zero) )

So I copy my application surface to temporaly surface sf_field, than darken my saved background (sf_bg) to match darkness of sf_field, draw sf_bg over application surface and than draw sf_field.

And it looks almost like I want to:

The only problem is transparent parts. So I want to get rid of them.

Once again:
How can I transform every alpha, that is !=0 into 1.
Or is there a better or less complicated way to avoid drawing shadows over background?


So, trying to solve this problem I created a shader.

// Simple passthrough fragment shader
varying vec2 v_vTexcoord;
varying vec4 v_vColour;

void main()
    vec4 Color = texture2D( gm_BaseTexture, v_vTexcoord );
    gl_FragColor = vec4( Color.r, Color.g, Color.b , dot( Color.a, 1000.0));
That's kinda solves my problem.