Simple Lighting System in GameMaker Studio 2

แชร์
ฝัง
  • เผยแพร่เมื่อ 7 ส.ค. 2024
  • In this episode we go through the simple steps of turning an unlit room/game into a full blown lit room that looks good. Join me as I walk you through the required simple steps!
    Support me on Patreon: / gamemakercasts
    Download the Starter Project: www.dropbox.com/s/395wxwhjijq...

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

  • @WilliamGarrisonArts
    @WilliamGarrisonArts 4 ปีที่แล้ว +25

    Now THIS....This this this THIS.... is a solid WORKING lighting tutorial. Well done, i love it. Clap!

  • @arcticsmp-officialchannel6180
    @arcticsmp-officialchannel6180 2 ปีที่แล้ว +6

    Little tip to some people:
    If some of your objects are appearing over the shadow layer, and you've made sure the shadow layer is at the highest layer order. You can set the shadow draw event to be Draw End instead of a Draw event. Learned it works better to help fit everything under!

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

      Bro thank u so much

  • @gamemaker4217
    @gamemaker4217 4 ปีที่แล้ว +1

    Excellent tutorial. Short and sweet but with awesome lighting method. Thanks!!

  • @chooby4405
    @chooby4405 4 ปีที่แล้ว +5

    helps a ton, been looking for a good lighting system tutorial for a while now

  • @ohpahn
    @ohpahn 2 ปีที่แล้ว +1

    Great tutorial! Perfect for the game I'm currently working on, thank you!

  • @NaikoArt
    @NaikoArt 2 ปีที่แล้ว +2

    what an amazing tutorial, very clear and practical

  • @nopetynope
    @nopetynope 3 ปีที่แล้ว +1

    This was super easy to follow. Great video!

  • @NickDerMitHut
    @NickDerMitHut 2 ปีที่แล้ว +11

    If you also have weird edges when two lights cross each other just tick the "Premultiply Alpha" box for the Simple_Light_Cutout sprite.

    • @masterjohn3126
      @masterjohn3126 ปีที่แล้ว +2

      Thank you so much bro, made my hour!

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

      @@masterjohn3126 glad to hear my weird discovery did eventually help someone haha

    • @djthicc1507
      @djthicc1507 ปีที่แล้ว +1

      Holy crap I was ripping my hair out because of this you are an angel

  • @ShamelezzSkillzz
    @ShamelezzSkillzz 3 ปีที่แล้ว +2

    Hey amazing job!! You can really play around with this and get amazing results. I had been struggling to make my own cut outs using your method but I figured it out. I made them in different sizes giving them a high quality look. For those interested to have them, let me know.

  • @super_bits
    @super_bits ปีที่แล้ว +2

    Amazing! Thank you for share this!

  • @dustinfinamore9801
    @dustinfinamore9801 3 ปีที่แล้ว

    This is the DOPEST tutorial on lighting! 100%!

  • @Diver13666
    @Diver13666 2 ปีที่แล้ว

    This short guide is priceless! Bravo!

  • @mrnobody7600
    @mrnobody7600 3 ปีที่แล้ว +1

    You're amazing bro, it worked very well.

  • @MetaHootOriginals
    @MetaHootOriginals 3 ปีที่แล้ว +1

    Absolutely amazing, right what my indie game needed. I was working with a similar system, just was missing some things in the configuration of the canva and with that when adding coding it would not take the canva countable and messed it all up, it only showed the subtracted cuttouts out when paused, this fixes all my issues.

  • @pipi7928
    @pipi7928 2 ปีที่แล้ว

    Awesome! Thats really really cool!

  • @heikkiaho6605
    @heikkiaho6605 2 ปีที่แล้ว

    Thanks so much! This was just the info I needed :)

  • @itaisinger1360
    @itaisinger1360 2 ปีที่แล้ว

    awesome video! thanks a lot!

  • @BloodMarket
    @BloodMarket 2 ปีที่แล้ว +1

    OMG THANK YOU SM FOR THIS TUTORIAL! Something I forgot to do (which I'm not sure if you mentioned or not. I was sleepy while doing this) Is to make the cutout invisible when rendering or else it's just look like a bright white light and you can't see the effects. Once I did that, it was like was a huge sigh of relief.

  • @scotsparaman
    @scotsparaman 4 ปีที่แล้ว

    Brilliant, easy to follow...

  • @pedroamaral1750
    @pedroamaral1750 3 ปีที่แล้ว

    thanks, you saved my game jam.

  • @nikolay-tsys
    @nikolay-tsys 2 ปีที่แล้ว

    Thank you so much, man!

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

    This is a good straightforward tutorial, though you really should only make the surface the size of your camera, if you have a large room making it the size of it could lead to performance problems.

  • @ro_drigo
    @ro_drigo 2 ปีที่แล้ว

    That's incredible,you did all with codes,I would draw all lights 😂

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

    Subscribed 🎉

  • @Kaaarrr
    @Kaaarrr 3 ปีที่แล้ว +1

    So awsome tutorial

  • @rosscondit8090
    @rosscondit8090 3 ปีที่แล้ว

    This is the best lighting tutorial on youtube how does it only have 2,000 views
    AND YOU DID LIKE 2 GIVEAWAYS WTF

  • @NickDerMitHut
    @NickDerMitHut 2 ปีที่แล้ว +1

    Nice and Simple Lighting system, I like it. Do you know how to make specific background layers not be affected by the light / darkness?

  • @RaidSpinel
    @RaidSpinel 2 ปีที่แล้ว +4

    I've never used surfaces before, don't know how I lived without these for an entire game lol. This tutorial did a great job explaining how they work and how to set them up.
    Although, wouldn't it be better at ~ 8:20 to set and reset the blendmode outside of the loop? Switching the blendmode 16 times a frame doesn't seem optimal. Using separate loops for subtracting and adding.

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว +1

      100%, if you don't need to add/sub anything else then yeah totally outside of that loop you are correct :)

    • @RaidSpinel
      @RaidSpinel 2 ปีที่แล้ว

      @@GameMakerCasts Thanks for the reply, and thanks for enlightening me to surfaces!

  • @fabbbydoo
    @fabbbydoo 4 ปีที่แล้ว +2

    Looking forward to trying to get this to work in a game I'm making. I'd like to attach the lighting to the player too, if it's not too tricky.

    • @GameMakerCasts
      @GameMakerCasts  4 ปีที่แล้ว +2

      100% not tricky at all! you basically end up looking for the play object and drawing the cutout around them. Does that make sense?

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

      @@GameMakerCasts how do you do that plssss?

  • @zombimana9518
    @zombimana9518 2 ปีที่แล้ว +1

    for some reason I can't create a colored light. I did everything as in the video

  • @peruano9187
    @peruano9187 3 ปีที่แล้ว +1

    a lot of thnks

  • @dergeilste7926
    @dergeilste7926 2 ปีที่แล้ว

    hey nice video. How did you setup this „skin“ for gamemaker?

  • @christophergraf5929
    @christophergraf5929 3 ปีที่แล้ว

    Hey! Great video. Super simple and really effective. By any chance, do you know a way to make the wobble slower? Thanks again

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว

      you would need to add a timer that goes up and down until it reaches a maximum / minimum where it flips, think of sin(timer) where that result is between -1 and 1 constantly going up and down.

    • @emmalogue1166
      @emmalogue1166 3 ปีที่แล้ว

      @@GameMakerCasts I'm not quite sure how to implement the timer, should it affect var wobble_amount_x/y or should it be its own variable that is implemented after draw_sprite_ext()? Thanks for the help!

  • @Timeline08
    @Timeline08 3 ปีที่แล้ว +2

    Thats great ! The only problem is that I want the surface_create to be the camera, could you do a tutorial base on the camera and not on the room_width, room_height ?

    • @sigmagamedev
      @sigmagamedev ปีที่แล้ว +1

      use these variables instead of the room width and height:
      cameraHeight = camera_get_view_height(view_camera[0]);
      cameraWidth = camera_get_view_width(view_camera[0]);
      just put them in the create event and use them when you create the layer in the draw event
      important: the cords in a surface are not equal to the cords in your room, so in the draw_surface event, you must find a way to translate the cords of your camera to the same cords but in the surface

  • @eunit08
    @eunit08 3 ปีที่แล้ว

    What software did you use when u made the light? I remember when you can do glow effects and more in the game maker sprite editor and now it's nowhere to be found. Now it's all done in codes and Im not in the advanced or intermediate levels of code

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว

      I usually load up Aseprite (bit.ly/37GKELk) and create the sprites in there, then just copy and paste them over :)

    • @eunit08
      @eunit08 3 ปีที่แล้ว +1

      @@GameMakerCasts ok thanks. Now i can make gradiants and all the extra features that game maker somehow removed for some odd reason

  • @superzilla784
    @superzilla784 3 ปีที่แล้ว +1

    Do you have a link to the paint program you use for this?

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว

      It is called Aseprite, and you can grab it from the humble bundle store at www.humblebundle.com/store/aseprite?partner=gamemakercasts You can also get it from steam as well at store.steampowered.com/app/431730/Aseprite/

  • @einaryt6972
    @einaryt6972 6 หลายเดือนก่อน

    What do I do If instead of black its a very white surface even though i just set c_black?

  • @jaredgc8423
    @jaredgc8423 3 ปีที่แล้ว

    How do you handle overlapping colours? Mine are producing dark edges in awkward places!

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว +1

      You will need to play with the lighting at the end. So you subtract the circle, but instead of a regular "add" use "bm_src_color" or at least I have found that worked for me

  • @professorpicklesphd.8312
    @professorpicklesphd.8312 3 ปีที่แล้ว +2

    hey! this is such a great tutorial, but the rooms i have in my game are relatively big and its starting to lag from the lighting. how would i do this in the Draw GUI event?

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว +1

      Thanks, looking at the code I wrote there if your room is huge, yeah lag. You can use the camera to get the width,height,x,y position of it and draw it that way. (camera_get_view_width/height, camera_get_view_x/y) should get your started.

    • @professorpicklesphd.8312
      @professorpicklesphd.8312 3 ปีที่แล้ว +1

      @@GameMakerCasts this works to draw the surface on only the camera, but when the player moves and the camera follows it the light sources stick to the camera. how do i stop this?

    • @TheCivildecay
      @TheCivildecay 3 ปีที่แล้ว +5

      @@professorpicklesphd.8312 use this to draw the sprite of the light:
      (Draw event)
      Draw_sprite(light_sprite, 0, x - camera_get_view_camera_x(view_camera[0], same for y...
      Then draw the surface to viewcamera_get_view_camera_x(view_camera[0], and same for y

    • @professorpicklesphd.8312
      @professorpicklesphd.8312 3 ปีที่แล้ว +3

      @@TheCivildecay thank you so much! this worked perfectly! ive been looking around for something to do this for a while but i couldnt find anything

    • @heikkiaho6605
      @heikkiaho6605 2 ปีที่แล้ว +1

      Yeess! thank you very much! this got me out of a dead end

  • @Lil_GreeD
    @Lil_GreeD 2 ปีที่แล้ว

    Hey, can I do that with another size? Like a triangle? (I wanna do a flashlight in my game)

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว +1

      You can do this by replacing the light sprite with another one (say a triangle)

  • @guy3480
    @guy3480 4 ปีที่แล้ว +2

    ive started using this and i noticed that overlapping light will create a dark area where they intersect. Did i do something wrong? Is there a way to make overlapping lights add their brightness values together to make a much stronger light source?

    • @lang_games
      @lang_games 3 ปีที่แล้ว

      I had this issue, can fix by lowering the intensity variable.

    • @jaredgc8423
      @jaredgc8423 3 ปีที่แล้ว

      I am having this issue too! Any chance you fixed it?

    • @guy3480
      @guy3480 3 ปีที่แล้ว +1

      @@jaredgc8423 its not fixable. If you put the sprites in an art program together overlapped you get the same effect. The only thing you can do to remove it without shifting towards a more advanced lighting system is use a cell shaded light sprite instead of a gradient

  • @bioyado
    @bioyado 9 หลายเดือนก่อน

    noice!!!

  • @wierdbob
    @wierdbob 2 ปีที่แล้ว

    If you aren't getting a black screen , you might of screwed up like I did by making the lighting render object invisible. I'm a newb but I'm guessing ticking that box means the draw step never happens so all that code is ignored?

  • @MatteoBenaissa
    @MatteoBenaissa 3 ปีที่แล้ว

    What is the game maker skin you're using ? it looks great !
    Huge thanks for the tutorial :)

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว

      Thanks :) I am using the dark dracula theme found at github.com/dracula/gamemaker-studio

    • @MatteoBenaissa
      @MatteoBenaissa 3 ปีที่แล้ว

      @@GameMakerCasts Oh ! I have it but I don't got the light blue menu names in the asset browser, did you change anything to get that ?

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

    I keep asking this on tutorials of this nature but when I use the subtract blend mode all things under the sprite are not drawn, including objects and tiles. It actually just makes a black square the shape of which is not consistent with the sprite drawn under the subtract or the sprites collision mask. Super confused as to how no one else has this issue. Worth noting I have my lighting object at a very low depth so all the lighting effects can effect everything in my game. Not sure why I can't cut out the dark surface.

    • @GameMakerCasts
      @GameMakerCasts  5 วันที่ผ่านมา

      If you have discord join the channel at discord.gg/hXaMWuwp and I can have a look for you

  • @Andresalex4
    @Andresalex4 2 ปีที่แล้ว

    Hey dude, I'm sorry for the dumb question, I am still not a pro with surfaces, but how could I make this work with different shades of darkness? For example, instead of black darkness I want it to be kinda blue tinted. I remember trying to change the color in draw_clear_alpha() but that made the lights themselves look weird, I assume I'd probably have to do some modifications in the sprite of the lights or the way they're drawn. Thanks in advance if you see this!

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว

      I mean instead of drawing the lights at "c_white" or "c_yellow" or whatever I had, you could use "c_blue" and try that first

    • @Andresalex4
      @Andresalex4 2 ปีที่แล้ว

      @@GameMakerCasts Sorry if I understood you wrong, but is that for changing the colors of the lights? In case it is, don't worry, I understood that part- what I want is to change the color of the darkness to i.e. blue, so the lights would be cutouts in a semi transparent blue foreground instead of a black one. I tried simply changing the color in draw_clear_alpha() but that gave me weird results with the lights (If you want I could try again and show). Do you reckon using draw_circle_colour() for the lights instead of sprites would get me a different result? Thanks for the response btw

  • @Robin-rb6qu
    @Robin-rb6qu 2 ปีที่แล้ว

    Hey downloaded aseprite and if i do the same like you my picture becomes black if i go on the left top corner. I can draw the white circle but there is black background and its not transparent. Could you help me

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว

      Make sure the circle isn't touching the edges. If you are still having troubles hit me up in discord discord.gg/HAAW2w2F

  • @squidge147
    @squidge147 4 ปีที่แล้ว

    I have made it so the surface follows the view and now it is not cutting any circles out? Please help.

    • @williambolls1819
      @williambolls1819 2 ปีที่แล้ว +2

      I know you posted this a year ago, but I thibk I know what the issue is if you didn't manage to figure it out.
      Surfaces use their own coordinate system thats seperate from the rooms, so you have to subtract the cameras position from the coordinates in the draw_sprite_ext section

  • @piscesartianyt
    @piscesartianyt 5 วันที่ผ่านมา

    bm_subtract doesnt seem to work at me... I've done it 1:1 but no cutout :(

    • @GameMakerCasts
      @GameMakerCasts  5 วันที่ผ่านมา

      are you able to share your project and I can take a look? You can hit me on up discord too, just look up the user mickifer or come to the server channel discord.gg/hXaMWuwp

  • @-breakdancepopcorn-498
    @-breakdancepopcorn-498 2 ปีที่แล้ว

    Hey, man. I followed your tutorial correctly but, for some reason, my screen goes fully black except for the heart HUD, I'd like to know if it can be fixed

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว

      Sounds like a drawing issue, are you able to send me your project or code and I can look at it?

    • @-breakdancepopcorn-498
      @-breakdancepopcorn-498 2 ปีที่แล้ว

      @@GameMakerCasts sure, let me get a Drive for it

  • @TheCivildecay
    @TheCivildecay 3 ปีที่แล้ว

    I like how your gamemaker looks like Godot :D

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว +1

      Thanks, if you want the theme you can grab it at github.com/dracula/gamemaker-studio :)

  • @gamerpros413
    @gamerpros413 4 ปีที่แล้ว +1

    amazing tutorial! question though, how do i attach the lighting to the player? Edit: While keeping other lights normal.

    • @WilliamGarrisonArts
      @WilliamGarrisonArts 4 ปีที่แล้ว

      You can try creating a new oLight or simply setting the (whichever) Light object to be
      x = player.x
      y = player.y
      inside the step event. Something like that.

    • @martinzilloxd2111
      @martinzilloxd2111 3 ปีที่แล้ว +1

      **** EVENT CREATE ****
      lighting_surface = -1;
      ***** EVENT DRAW ******
      draw_self();
      if (surface_exists(lighting_surface) == false)
      {
      lighting_surface = surface_create(room_width, room_height);
      }
      surface_set_target(lighting_surface);
      draw_clear_alpha(c_black, 0.6);
      {
      shakeX = random_range(1.2, 1);
      shakeY = random_range(1.2, 1);
      draw_set_blend_mode(bm_subtract);
      draw_sprite_ext(sprite7, 0, player.x, player.y , shakeX, shakeY, 0, c_white, 1);
      draw_sprite_ext(sprite7, 0, player.x, player.y, shakeX, shakeY, 0, c_red, 0.5);
      draw_set_blend_mode(bm_normal);
      surface_reset_target();
      draw_surface(lighting_surface, 0, 0);

  • @cosmic5244
    @cosmic5244 2 ปีที่แล้ว

    any way to make the lights not desaturate

    • @GameMakerCasts
      @GameMakerCasts  2 ปีที่แล้ว

      You would probably need to run a shader to do that afterwards. In the latest GameMaker version they do have some shaders that might help with this, but I haven't tried them

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

    W

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

    when i run this code on mac my whole screen will just be black

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

      it does work on windows

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

      That's really weird as there isn't anything super specific happening. I don't have a mac to test it on :(

  • @masterjohn3126
    @masterjohn3126 ปีที่แล้ว +1

    what if i have 2 of the same instances but only want 1 of them to light up?
    EDIT: 2 of my braincells just connected, i figured it out
    We are using a WITH statement here, i just need to put the variables in the object... facepalm

  • @tanura5830
    @tanura5830 2 ปีที่แล้ว +1

    the light looks ugly. But thanks for the tutorial

  • @Silknight
    @Silknight 3 ปีที่แล้ว

    The sliding words at the bottom of the screen are very distracting...

    • @GameMakerCasts
      @GameMakerCasts  3 ปีที่แล้ว

      Thanks for your input, I'll see what I can change up here :)