Surface, Blend mode question

Discussion in 'Programming' started by Lars Karlsson, Aug 4, 2016.

  1. Lars Karlsson

    Lars Karlsson Member

    Aug 2, 2016
    Hi there. First I'd like to give thanks to maartenvt for sending me on the right direction and I've gotten really close to my goal. Just one last step that I'm stuck on.
    I'm quite bad at explaining so hopefully I'll get my question across.

    Game without surfaces. What the game looks like without any surfaces.
    Shadow1 A surface generated by a line-of-sight extention.
    Shadow1 + Grass The game with the surface applied using draw_set_blend_mode_ext(bm_dest_color,bm_zero).
    So far all good.

    Now to the hopefully last step.
    I want to achieve THIS with the help of either FOG1 or FOG2.
    I basically want the 'fog' to only draw where it's black.

    My best guess is to create a second surface which combines Shadow1 with either FOG1 or FOG2 and then draw that after the first surface. I've tried many different blend modes and combinations without result.

    EDIT: I feel like drawing a second surface with FOG2 should do. But I must be using the blend modes wrong.

    EDIT2: Using FOG2 above the first surface in Photoshop using the mode 'Lighten' achieves the right result. Is there a blend mode in GM that work just like the 'Lighten' mode in photoshop?

    I'd love to hear any suggestions. I'm just completely stuck on this. So close to achieveing what I want. :mad:

    Last edited: Aug 4, 2016
  2. jo-thijs

    jo-thijs Member

    Jun 20, 2016
    Best way is to have Shadow1 as an alpha map, where the black part has alpha 0 and the white part has alpha 1.
    You can then draw Shadow1 on the game without surfaces with the blend mode (bm_zero, bm_src_alpha).
    Then draw FOG1 to the result using the blend mode (bm_one, bm_inv_src_alpha).
    And that should do the trick.

    The only question is, how are you going to make the alpha map?
    For that, I would need to know how you currently draw Shadow1.
  3. Lars Karlsson

    Lars Karlsson Member

    Aug 2, 2016
    jo-thijs thanks for your input! :D Finally managed to figure this one out.
    I ended up using drawing the FOG1 ontop of Shadow1 + Grass with draw_set_blend_mode_ext(bm_inv_src_colour, bm_one )

    Here's the result. A bit rough atm, but it's definitely working.

  4. Pkirkby

    Pkirkby Member

    Mar 25, 2019
    I'm doing a similar thing with my night cycles, but I can't even figure out how to bm_subtract my "torchlight" from the dark blue surface I draw for my nighttime. I imagine its simple, but Im not sure where to start.

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