Simple 2D Lighting - GameMaker Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ส.ค. 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!
  • เกม

ความคิดเห็น • 34

  • @Greeny_Official
    @Greeny_Official 8 หลายเดือนก่อน +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! 🙂

  • @AL-lh2ht
    @AL-lh2ht ปีที่แล้ว +4

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

  • @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!

  • @fierorecensione5828
    @fierorecensione5828 7 หลายเดือนก่อน

    TOP!

  • @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?

  • @TripleKenshi
    @TripleKenshi 9 หลายเดือนก่อน +1

    FINALLY I FOUND IT

  • @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 ?

  • @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: th-cam.com/video/KqDe2JYxukA/w-d-xo.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.

  • @siennas254
    @siennas254 25 วันที่ผ่านมา

    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  25 วันที่ผ่านมา +1

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

  • @puresoulx
    @puresoulx 7 หลายเดือนก่อน

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

  • @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

  • @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?

  • @stilt2209
    @stilt2209 ปีที่แล้ว

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

    • @puresoulx
      @puresoulx 7 หลายเดือนก่อน

      Same

  • @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);}

    • @fireenderboy
      @fireenderboy 7 วันที่ผ่านมา

      @@Starbula not working for me

    • @Starbula
      @Starbula 7 วันที่ผ่านมา

      @@fireenderboy please be much more specific about your problem then that

    • @fireenderboy
      @fireenderboy 7 วันที่ผ่านมา

      @@Starbula surface_free never changes anything, when the object is deleted or I activate that from anywhere else, it doesn't do anything. All my other rooms are pitch black and nothing else.

    • @Starbula
      @Starbula 7 วันที่ผ่านมา

      @@fireenderboy alright what is the actual problem you are having

  • @carlacastrodasilvasantana6960
    @carlacastrodasilvasantana6960 ปีที่แล้ว

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

  • @ciaranseymour31
    @ciaranseymour31 8 หลายเดือนก่อน +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 3 หลายเดือนก่อน

    This is simple?

    • @DragoniteSpam
      @DragoniteSpam  3 หลายเดือนก่อน

      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 ;)