Surface Transparency Issue

Discussion in 'Programming' started by Mottafier, Jul 13, 2019 at 3:27 PM.

  1. Mottafier

    Mottafier Member

    Joined:
    Sep 3, 2016
    Posts:
    9
    Hello! I'm currently working on a local multiplayer game that utilizes dynamic splitscreen. When the players are close together, you both share one view, but when you move far apart enough, the view splits into two and they each follow a player.
    gamemaker 1.PNG
    The view on the left follows player one, and it really takes up the whole screen, it just gets covered by player two's view. The player two view (right) is a surface that gets drawn OVER the player one view, and uses blend mode subtract to take out the area where player one's view should be.
    gamemaker 2.PNG
    The image above shows just the surface that holds player two's view. The issue is, that anything transparent thats on screen when this surface is made seems to stay transparent, even with a solid color beneath it! The large green square here is transparent just to illustrate the issue better. The issue this creates is that when the second view gets drawn, anything transparent makes the surface partially transparent, and so anything in player one's view (left) bleeds through this surface. If you look close enough, you can see a "ghost" of player two to the right of the player in player Two's view in the first picture. I figured out this is due to the transparent surface showing player one's view beneath it. And for four brutal days I've been trying everything to fix it but nothing has worked.

    This was a little tough to explain, so if I need to be more clear please let me know! Also I could post code, but I don't think it's necessary in this situation, however that can change if you'd like to see it.

    Ideally, if there were a way for me to set the surface's alpha to 1 and THEN subtract the triangle where view one should be, that would work, but currently the best I can do is draw_enable_alphablend(false) and then draw player two's surface, which makes the whole surface opaque, which then covers up player one's view beneath it.

    Thanks in advance, I hope this isn't unsolvable!
     
  2. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    I'll be honest with you, your explanation of the issue is a bit confusing and I didn't understand it fully, so I'll just refer to your suspected solution:
    You actually can do this by setting the blend mode to bm_add and drawing a black fill with 1.0 alpha. Since black has RGB (0, 0, 0) it won't change the color itself but it will max out the alpha.
     
  3. Azenris

    Azenris Member

    Joined:
    Oct 30, 2016
    Posts:
    61
    not sure I udnerstand the question.

    could you gpu_set_colourwriteenable(true,true,true,false); first, then draw to the surface.
    then re-enable all, then do the subtract thing, then draw the surface to your app
     
  4. Mottafier

    Mottafier Member

    Joined:
    Sep 3, 2016
    Posts:
    9
    IT WORKS thank you so much!!! I can enjoy life again!!!!!
     
  5. Annoyed Grunt

    Annoyed Grunt Member

    Joined:
    Jun 20, 2016
    Posts:
    110
    Phew, thankfully it works, otherwise I would be out of guesses. It's a very confusing issue!
     

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