GMS 2 Alpha issues with gpu_set_blendmode_sepalpha?

Discussion in 'Programming' started by mattmls00, Oct 8, 2019.

  1. mattmls00

    mattmls00 Member

    Joined:
    Oct 6, 2019
    Posts:
    13
    Alright can someone tell me what I am missing here?

    I have a surface being draw to the application surface. The surface being drawn is cleared black with a .5 alpha. If I draw this surface without blend modes the black region looks as it should. Basically it darkens the screen a little.

    Now when I use this blend mode (I need the multiply blend for additive lighting):

    Code:
    gpu_set_blendmode_ext_sepalpha(bm_dest_color, bm_zero, bm_one, bm_zero )
    All the black areas revert to full alpha and hide everything. In my mind the alpha should be:

    (0.5 * 1) + (1*0) = .5

    So it should work correctly. However I even tried this code:

    Code:
    gpu_set_blendmode_ext_sepalpha(bm_dest_color, bm_zero, bm_zero, bm_zero )
    Where the alpha should equate to:

    (0.5 * 0) + (1*0) = 0

    and yet the black portion is still at full alpha. What am I missing here?
     
  2. robproctor83

    robproctor83 Member

    Joined:
    Sep 30, 2019
    Posts:
    13
    I don't believe it works like that. I am fairly sure that the opacity for the blendmode is meaning how much opacity it should paint onto the surface, not what the output of the surface will be.
    Try what your doing with a colored surface, like blue, instead of black, and run your code and see what happens. If I am right, I think you would get a solid blue surface with another color partially multiplied on top.
     
  3. mattmls00

    mattmls00 Member

    Joined:
    Oct 6, 2019
    Posts:
    13
    I'm not 100% certain what you mean by opacity to paint onto the surface vs what the output of the surface is (that sounds the same to me).

    Anyhow, I think you are right because I can see textures below the blue. But this would make sense the color blue is being multiplied by the color at the destination. I am failing to see the function of the alpha components in
    gpu_set_blendmode_ext_sepalpha.


    So is there no way to control opacity of the surface being drawn with blend modes?

    I tried looking for info on how to do it with a shader, but everyone just says it's better to use blend modes.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice