Simple 2D Lighting - GameMaker Tutorial

Поділитися
Вставка
  • Опубліковано 26 лип 2024
  • "Hole punching" is an extremely popular trick to implement simple 2D lighting in GameMaker games. It only takes a few minutes to set up and all you need is a surface and some blend mode magic!
    Example on Github:
    github.com/DragoniteSpam-Game...
    Surfaces:
    • Introduction to Surfac...
    The application surface:
    • The Application Surfac...
    Blend modes:
    • Blend Modes - Simple V...
    GameMaker Studio 2.3 playlist:
    • GameMaker: New & Beta ...
    GameMaker 3D playlist:
    • 3D in Game Maker Studio 2
    0:00 Introduction
    0:44 Project setup
    1:49 Preliminary knowledge
    2:59 Setting up the surfaces
    4:39 The different Draw Events
    6:08 Filling the lighting surfaces
    8:58 Punching holes with bm_subtract
    14:40 Fine-tuning the lighting effects
    22:17 A bit of subtractive blending math
    23:50 That's all
    #GameMaker
    #GameMakerLighting
    #GameMakerBlendModes
    - - - - -
    I've now made that Patreon:
    / wizardragon
    That promised social media link spam.
    / dragonitespam
    Transition / idle music is by my old friend Kamex:
    / greatgabite
    Rate, comment, subscribe, watch more, enjoy!
  • Ігри

КОМЕНТАРІ • 30

  • @AL-lh2ht
    @AL-lh2ht Рік тому +4

    Great video. Easy to understand and practical without much filler.

  • @Greeny_Official
    @Greeny_Official 7 місяців тому +3

    Very helpfull tutorial, thanks!
    Took some fiddling around myself to get it to fully work, but in the end it all came out great! 🙂

  • @Weusneus
    @Weusneus 2 роки тому

    Great video on simple lighting, I like the chill pace. Keep up the good tutorials!

  • @tomgola3
    @tomgola3 7 місяців тому

    Thank you!

  • @salvatorealiotta7221
    @salvatorealiotta7221 Рік тому

    Tankyou so much!

  • @TripleKenshi
    @TripleKenshi 9 місяців тому +1

    FINALLY I FOUND IT

  • @fierorecensione5828
    @fierorecensione5828 7 місяців тому

    TOP!

  • @hanspuhenshaimers6223
    @hanspuhenshaimers6223 2 роки тому +1

    Hola, funciona igual en gmk studio?

  • @__TV33__
    @__TV33__ 3 місяці тому

    I know this is an older video now, but I want to say how helpful this is. The only thing is the light doesn't want to shrink or grow / bob despite me fiddling with the code to try to get it to. Any idea why ?

  • @cheesestack2587
    @cheesestack2587 3 місяці тому

    In my project i have the viewport X offset by -600 in the viewport properties so that it appears on the left side of the screen at all times. This is causing a black bar to appear on the right side of the screen. do you know what could be causing this?

  • @nuclearbeeberman
    @nuclearbeeberman Рік тому

    great video once more. I wonder If it's possible to have the dark blue area in some sort of photoshop multiply effect over everything else.

    • @DragoniteSpam
      @DragoniteSpam  Рік тому

      you can: ua-cam.com/video/KqDe2JYxukA/v-deo.html
      still undecided if i like the way multiply looks for this though

    • @nuclearbeeberman
      @nuclearbeeberman Рік тому

      @@DragoniteSpam thanks for the super fast answer. how do you think do other games solve night time (for example stardew valley)? When I use photoshop I can get a kinda good night time color multiply but in game maker it's tough. Also because I still don't fully understand surfaces. Always when I think "this must work like this" it doesn't :D.

  • @stilt2209
    @stilt2209 Рік тому

    I have done this but my game has no camera. The screen works fine but it condenses the window and doesnt go fully to all edges

  • @puresoulx
    @puresoulx 6 місяців тому

    It worked but my game has levels and when I go to the next room the surface still there , how I can fix that ?

  • @siennas254
    @siennas254 13 днів тому

    How is the global._part_system defined at the beginning of the video so I can launch the game without it crashing for this not being referenced? Tried doing this during the bit where you first test the opaque black surface

    • @DragoniteSpam
      @DragoniteSpam  13 днів тому +1

      it's in the global code file called "particles"

  • @ToasterCat0622
    @ToasterCat0622 2 місяці тому

    How do I delete the lighting effect after applied. In my game I want this effect to work for 1 room but every room after that becomes pitch black even though I don't have the object

    • @Starbula
      @Starbula Місяць тому

      you need to add the clean up event to the lighting object and write this code in the cleanup event
      if (surface_exists(light_surface)) {surface_free(light_surface);}

  • @happy_cris95068
    @happy_cris95068 2 роки тому

    When I start up my game, the camera appears in the corner and doesn’t go full screen. A problem with viewports?

  • @carlacastrodasilvasantana6960

    everything works fine but for some reason only instances in a certain layer can create "light"

  • @stilt2209
    @stilt2209 Рік тому

    My game has levels and for the next one the effect needs to be turned off anyway on how to do that

  • @ciaranseymour31
    @ciaranseymour31 7 місяців тому +1

    Hi i cant seem to figure out why this doesnt work for me, ive got a camera obj that follows the player (just mentioning it incase its the cause, but i dont think it is)
    I typed the code the exact same as you did, but the light is never centered on the torch, it seems to move based on the torch's position in the world, with the further left it is, the further left the light is. and when i make it follow the player too, the light is just fixed to the left of the head, rather than being centered.
    My light cutouts origin is the center of the light, the torch's origin is the center of the flame, and the players origin is the center of the character

  • @JordanPost-zd6eb
    @JordanPost-zd6eb 2 місяці тому

    This is simple?

    • @DragoniteSpam
      @DragoniteSpam  2 місяці тому

      compared to most other lighting tricks, yeah

  • @PaffcioStudio
    @PaffcioStudio 2 роки тому

    It is a great pity that it is GMS 2 and not GMS 1.4.
    I gave up on GMS 2 because of the interface and the mess that reigns in the interface.

    • @DragoniteSpam
      @DragoniteSpam  2 роки тому +2

      This works in all versions of GameMaker. You really shouldn't use a version that hasn't been supported in about 4 years though.

    • @PaffcioStudio
      @PaffcioStudio 2 роки тому

      @@DragoniteSpam That's great. I really appreciate GM 1.4 for its simplicity and functionality. And it will stay that way ;) I have a nice day ;)