Thanks Shaun, perfect timing for me. I'm going to try and combine this with my lighting system I already have in place, to see if I can create anything cool from it...or break my game, of course.
EDIT--I figured it out. By setting the shadow intensity in the "draw_shadow_map" script to 0. Under "shader_set_uniform_f_array", if you set the 1.0 values to 0.0(or any value under 1), you'll get rid of the "X" effect on small range values. Messing with the light enum values trying to get a small-scale circular light around the Player. I keep getting a "X" effect where light crosses through the light circle around the Player to make an X. This happens when I set eLight.Range to a small value such as 64. Otherwise the engine is great.
@Check I'm not sure. I haven't played around with the engine in a long time, but I understand your approach. If I pick it up again I'll try and explore this.
Just found this and used it in the game I'm playing around with and I love it! However, how do you make the ambient light level lower so it's darker in the room if not lit by any light sources? EDIT: I found the variable that handles this in the lighting_global script: global.ambientShadowIntensity = 0.85; Changing this value to something closer to 1 makes it much darker. Thought I'd edit this in case anyone else hadn't found that yet
does anyone know how I could decrease or increase the brightness of the rest of the room when using a light. I would like everything outside the light source to be pitch black edit: I figured it out. You just change the global.ambientShadowIntensity variable in the lighting_global script if anyone else wants to know.
Okay, to anyone as stupid as me: if you need to move shadowcaster put polygon = polygon_from_instance(id); in the step event. I spent 3 damn hours trying to figure that out.
fantastic tutorial, fantastic asset. took 10 mins to implement max. Thank you Sean and Jobo! Edit: Cant seem to make a non-square shadow. for a round ball for example. Digging through the code now,
Hullo I have a problem whenever I run my game no sprites are actually being drawn, not the lights nor the shadow casters. I'm not really sure why. Help me. Help me.
I'm trying to create a game that has this lighting system and has enemies that are only visible in the lit area. How would you go about detecting if an object other than the light source is lit by another light source? I'd like the visibility of the object (lit by the light source) to be a function of the amount of light where it's at, so if it is just barely lit, it will be barely visible (low opactiy).
3:10 so, not ENTIRELY a foolproof tip then to say "always put at the top"? Because if you have a "oInitialize" object that changes and SETS resolution / viewport / camera size, ratios, appsurface scaling etc. Surely you want the lighting object to load AFTER that one?
Great tutorial, but how to use different shape shadow casters instead of square boxes. I created a barrel (circle shape shadow caster) but it still had a square shadow?
im trying to figure this out myself, there is very little documentation on this system... what good is it if no one knows how to utilize its abilities?
I figured out to use polygon_from_path and then create a path with the circle shape you need. But for the origin i worked out (by trial and error) needs to be the negative of the objects X and Y position. But thats as far as i got. I dont know how to resize or move the object (with path attached) in game.
Hi, is it possible to make height of light (z coordinate) to achieve length of the shadow? Is it possible to use custom light type (custom light aplha sprite)? Is it possible to use global light? Have u seen old CBNA smart light (search in the youtube)?
I get an error whenever I destroy an object that's a child of obj_shadow_caster. It's related to the polygon it creates. How do I fix this? ERROR in action number 1 of Draw Event for object obj_light_renderer: trying to index a variable which is not an array at gml_Script_polygon_get_area (line 15) - var px = pt[eVertex.X]; ############################################################################################ gml_Script_polygon_get_area (line 15) gml_Script_lighting_pre_composite (line 19) - cached_polygon_area = polygon_get_area(polygon); gml_Script_composite_shadow_map (line 10) - lighting_pre_composite(); gml_Object_obj_light_renderer_Draw_0 (line 8) - exists = composite_shadow_map(global.worldLights);
Got it) By setting the shadow intensity in the "draw_shadow_map" script to 0^: shader_set_uniform_f_array (global.u_TexelSize_ShadowMap, [0.1 / surface_get_width (surface), 0.1 / surface_get_height (surface)]). Also, play with this line (set numbers between 0.0 and 1) and obj_light (parent object. like in the video) variable definition to get the smoothest result.
it is possible to create a little shadow caster ? because with downing the shadow_lenght variable, when i am to close to the object, the shadow of the point near to me create a shadow on the object and it's soooo ugly
I've started using this system, and It has a huge potential. Would love to see more videos about this system. Especially about how to optimize room with a lot of light sources. This system has comments everywhere, but I don't really understand how it works with cameras? Is there a way not to cast shadows if an object is outside of your camera view to save computing resources?
Good lecture introducing awesome resource. By the way, I am curious about how you scaled the code- without scaling the code editor- like 6:36~6:38 Is there any command key for doing that?
On the Mac Creator version of gms2 the shadows seem to work perfectly but the individual lights don’t seem to render Do you have any idea why this happens? Edit: I followed your tutorial step by step not sure why it doesn’t wrk
Hey! I found the answer in one of the reviews on the YoYo Games marketplace page. "In all vertices shader (sh_blend_light.vsh and sh_shadow_map.vsh), replace all references "in_Texcoord" with "in_TextureCoord" and it'll work."
@@BeingFriends hm, maybe I didn't do this right, but I did a find and replace all for in_Textcoord --> in_TextureCoord and I still don't see anything. :(
Hello, thank you for the tutorial, I have a question, there is a polygon for the shadow, the problem is, my object is a tree, how can I use the sprite to do the shadow? thank you
does anyone know how to affect individual lights. I was trying to create a flickeriing on and off light and when i created it. it would affect all the lights. I have a Test light with an alarm in the create that alarm looks like this light[| eLight.Intensity] = 0; then i have another alarm that goes off after another 10 frames but again this affects this object and even other different light objects. So theyre all going off which is cool but id like to affect individual lights.
So I already have a day and night system for my game and was wondering can this be used strictly for my dungeons? I know I can use it but would it have any major downfalls if I don't make it persistent and call it in the rooms I need?
But how do you make a lighting system that doesn't have infinite shadows? A system where the shadow length is based on a given height value for each object.
hi shaun I'm using this asset, and would like to ask how I would go about adding layer based lighting, the issue I've been trying to solve with this engine, is disabling the lighting effect for the background layers or a specific layer in general.
@@peremoyaserra2749 My solution would be to make a shadow caster as an invisible object, then place it over any tilemap you want to have cast a shadow.
Because while the original light is *placed* at oTestLight it doesn't follow it. oTestLight simply creates the light. Technically you could make and manage many lights from one object, this is just a convenient way to track them.
Just found if you don't have any shadow casters, the lighting system doesn't do anything. I wanted lights without shadows (for my own reasons), so solved this by creating an off-camera shadow caster dummy object.
I've run into a problem with my game where it gives me an error saying it can't create a surface with a width or height of 0. I have no idea what causes this. When I make an entirely new room as in the video everything works just fine, but with my older rooms the game crashes right away. Any ideas what might cause this?
@@jacobfauston6837 I just figured out it has to do with the viewports. When I turn them off it works perfectly, but with them turned on the game crashes. Now I just need to figure out how to set the window size without having viewports. Any ideas?
@@TjuserX Alright, I found a way to fix it! Re enable viewports first of all. Then you'll need to change your object camera, in that object is probably camera_create(). But as it turns out you need to change it into camera_create_view(). I never used that yet, but it fixes the crash.
Hi Shaun! Thanks for all of the tutorials that you're making! I must say that's a gorgeous free 2 use lightning system. I'm also in search of information or video about initializing/loading rooms. When should a user create one, and how to define if all is loaded and ready to be shown inside of actual game world? Any good sources of info for that? Would also love to see a video from you on that topic one day.
Does this work with multiple cameras? I have situations where my view consists of 2 camera views combined into the actual view, is this flexible enough to work in a situation like that?
Make sure it has a round bounding (collision) area in the sprite. Alternatively there should be polygon creation functions (i.e. polygon_create(set) where set is a 1d array of eVertex, though you'd have to look to find out what an eVertex is). *Edit:* Turns out that it actually uses the square collision box. So you'll have to use the alternative method. Thankfully I found out how to set up your vertex array: set[0] = [x,y]; set[1] = [x,y + 16]; //Continue for all points - it shouldn't take too many to create a decent circle *Edit 2:* For a visual editor just create a path and use polygon_from_path(path,xOrigin,yOrigin).
This implies quite strongly you did something wrong or have your instance creation order off. Everything is handled by the main object as demonstrated in the video. I'd be careful about patching this over yourself instead of working out what went wrong.
Very good looking lighting system, but it's very slow on version GM 2.3, both in a stand-alone demo project and integrated into my existing game. Any ideas on how to fix this?
cool very cool, i had already tested the lightSystem2D but my graphics card vents would fire up, iam on a ATi raedonR9 msi overclocked by factory. But using this method and adding it to the game all the GPU fans are quiet. ( iam guessing the lightSystem2D default room is made to stress the gpu )
@@arnarkarlsson9916 I have tried it, but for some reason it did not seem to work for me tho; the lighting system would not appear to be working, I would still get the same character on a plain map. And after moving it around for a bit, the game would just crash for some reason.
I'm getting an error that says: "Can't create a surface with either a width or height of 0" at gml_Script_shadow_map_ensure_exists (line 24) . Line 24 is "shadowMap = surface_create(vw, vh);". If anyone already had this error, can you tell me how to fix it?
@@ofaca1429 I think I found a solution. I apologize for possible errors and other stuff - I am not a native speaker and used Google Translate Our problem is that the lighting system is designed to work with the old camera system. The script "lighting_get_active_camera" uses functions of the type "camera_get_view" which work only with cameras created in the room settings, or through the function "camera_create_view()". Cameras created through "camera_create()" do not support these functions. So we need to replace all these functions with the actual values used for our camera. In my case, the script "lighting_get_active_camera" now looks like this: if(global.worldCustomCamera == undefined) { // Get active view camera var camera = co_cam.vcam_cam // camera_get_active(); var cameraX = co_cam.vcam_cam_x-co_cam.vcam_width/2 //camera_get_view_x(camera); var cameraY = co_cam.vcam_cam_y-co_cam.vcam_height/2 //camera_get_view_y(camera); var cameraW = co_cam.vcam_width //camera_get_view_width(camera); var cameraH =co_cam. vcam_height // camera_get_view_height(camera); return [cameraX, cameraY, cameraW, cameraH]; } return global.worldCustomCamera; Where object "co_cam" controls all my cameras. The meaning of the remaining variables should be clear. With this fix, lighting now works for me
@@ОпустошенныйСон You don't need to apologize. I'm not a native speaker neither. Thank tou for your help. I can't wait to make this work in my games. Thanks :D
@@joeljames8591 ERROR in action number 1 of Draw Event for object obj_light_renderer: Can't create a surface with either a width or height of 0 at gml_Script_shadow_map_ensure_exists (line 25) - shadowMap = surface_create(vw, vh);
@@uwwwu9954 ok, i traced the issue to these variables for the height and width it wants to draw the surface. it tries to pull them from the camera width and height, but the way it's trying to do that is honestly way over my head and i have no idea how to troubleshoot that. setting those variables to a high number can get the game to run without crashing, but things don't really render properly...
So I know this is an old video but I was wondering if anybody could help me out? Whenever I put more than one light in my room it absolutely TANKS my FPS. Any Ideas?
after following this exactly my game doesn't launch and the error message "Script: light_cull at line 20 : unexpected symbol "[|" in expression" pops up. please help
Hey, I'm having an issue where multiple light sources in different rooms are massively impacting on the performance, anyone have any idea what it could be?
I had the same problem, you probably have some child objects of your Crate who do not inherit the creation event from the parent. So to solve this issue, make sure every object that is a child of a shadow caster has the 'event_inherit()' script in the creation event
Hey Shaun could you make a video on how to do physics like king Arthurs gold? Im really honestly stumped on how to do it and I dont see any of your videos show anything like it
Hey! I found the answer in one of the reviews on the YoYo Games marketplace page. "In all vertices shader (sh_blend_light.vsh and sh_shadow_map.vsh), replace all references "in_Texcoord" with "in_TextureCoord" and it'll work."
Anyone else getting a cleanup error? Variable oTestLight.light(100465, -2147483648) not set before reading it. at gml_Object_obj_light_CleanUp_0 (line 3) - light_remove_from_world(light);
Somehow it will not work for me, no stranger to these tutorials and they always have worked like charm! But this time I have no idea what I could be doing wrong. I followed everything step-by-step, tried it first in an existing project, then in a fresh new project just to see if anything was conflicting with my pre-existing code etc. I tried it with the parent-child objects and without (using the included objects) to check if anything there was going wrong. Still everything just goes dark (but still visible) as if the lights wont "turn on". If I pump up the light intensity then everything just goes light. Anybody have any suggestions? Double checked the instance creation order and layer orders... no idea why I cant get it to work :-S
Even weirder: just imported the tool again WITH the demo components and ran the demo rooms. They don't work either. Could there be anything regarding the shaders that perhaps would only work on Windows? I'm on GameMaker for Mac (paid Creator license, should that be of any importance). Or am I just not seeing something?
@@DankerAnimation Thanks for your comment, looks like it's a Mac thing then (brace yourself: mac jokes are coming) Hope there's a way to bypass the issue as to why it wouldn't work. It looks so awesome. I have no idea myself unfortunately. Praying for a quick fix, because this looks so awesome :)
I can't download the project since I'm using the evaluation version of GMS2 Lighting System 2D Jobo You need a paid GameMaker Studio 2 licence in order to have access to this asset. Contact Publisher | Support
Todays Livestream of viewer games is over at: www.twitch.tv/shaunjs !
How is this Lighting System with 2D platformer games? It seems this demonstration is best fit for Top-Down projects.
a question it support android?
Update link for description of this video
thecode.cafe/foss/lighting-2d
whenever I have a vague concept of something I wanna do in gamemaker youre always here with the appropriate solution!
Wow! I've been looking for a good solution to a 2D lighting system in GMS2 for some time now, thank you!
Thanks Shaun, perfect timing for me.
I'm going to try and combine this with my lighting system I already have in place, to see if I can create anything cool from it...or break my game, of course.
EDIT--I figured it out. By setting the shadow intensity in the "draw_shadow_map" script to 0.
Under "shader_set_uniform_f_array", if you set the 1.0 values to 0.0(or any value under 1), you'll get rid of the "X" effect on small range values.
Messing with the light enum values trying to get a small-scale circular light around the Player. I keep getting a "X" effect where light crosses through the light circle around the Player to make an X. This happens when I set eLight.Range to a small value such as 64. Otherwise the engine is great.
ur a fucking god dude. you saved me.
@Check I'm not sure. I haven't played around with the engine in a long time, but I understand your approach. If I pick it up again I'll try and explore this.
did you ever figure out how to create the circular light?
Wow, even after three years your comment just saved my project!
Just found this and used it in the game I'm playing around with and I love it! However, how do you make the ambient light level lower so it's darker in the room if not lit by any light sources?
EDIT: I found the variable that handles this in the lighting_global script: global.ambientShadowIntensity = 0.85;
Changing this value to something closer to 1 makes it much darker. Thought I'd edit this in case anyone else hadn't found that yet
MVP right here
Thank you so much friend!
Your a good man. Never would have found this
my hero
does anyone know how I could decrease or increase the brightness of the rest of the room when using a light. I would like everything outside the light source to be pitch black
edit: I figured it out. You just change the global.ambientShadowIntensity variable in the lighting_global script if anyone else wants to know.
Thanks for letting me know
I needed this information! Thanks!
HOLY £@¤% THANKS SHAUN IVE BEEN LOOKING FOR SOMETHING LIKE THIS IN PROBABLY ABOUT A WEEK
Okay, to anyone as stupid as me: if you need to move shadowcaster put polygon = polygon_from_instance(id); in the step event. I spent 3 damn hours trying to figure that out.
omg thank you
You're a lifesaver
Oh god you're goddamn right! thank you
you are a life saver my friend!
fantastic tutorial, fantastic asset. took 10 mins to implement max. Thank you Sean and Jobo!
Edit: Cant seem to make a non-square shadow. for a round ball for example. Digging through the code now,
Ever figure it out?
I am also trying to figure out how to cast the shadow of a round object. Any ideas?
solved with polygon_from_path, just make sure to set the origin to -x,-y, I don't understand why but I got it working thanks to a comment below.
Hullo I have a problem whenever I run my game no sprites are actually being drawn, not the lights nor the shadow casters. I'm not really sure why. Help me. Help me.
Could you explain how these shaders work? I love the way you teach things.
I would watch that, that's actually what I came here expecting to see.
I'm trying to create a game that has this lighting system and has enemies that are only visible in the lit area. How would you go about detecting if an object other than the light source is lit by another light source? I'd like the visibility of the object (lit by the light source) to be a function of the amount of light where it's at, so if it is just barely lit, it will be barely visible (low opactiy).
I know this answer is very late, but you could just make the shadows overlap the enemies.
3:10 so, not ENTIRELY a foolproof tip then to say "always put at the top"?
Because if you have a "oInitialize" object that changes and SETS resolution / viewport / camera size, ratios, appsurface scaling etc.
Surely you want the lighting object to load AFTER that one?
Great tutorial, but how to use different shape shadow casters instead of square boxes. I created a barrel (circle shape shadow caster) but it still had a square shadow?
im trying to figure this out myself, there is very little documentation on this system... what good is it if no one knows how to utilize its abilities?
I figured out to use polygon_from_path and then create a path with the circle shape you need. But for the origin i worked out (by trial and error) needs to be the negative of the objects X and Y position. But thats as far as i got. I dont know how to resize or move the object (with path attached) in game.
@@b1rdm4n22 thank you for the -x -y tip. I got round shadows working with polygon_from_path. Looking great!!!
Does this still work in 2.3?
This is freakin' awesome, especially since it's totally free!
Help me please. FPS fell down after inputing lighting in the room. How can I fix it?
There's no way
How to I update the shadows when an object moves in the scene that is affected by shadows?
Do u have the solution?
@@smily7040 Put it in a step event :)
@@HenrikoMagnifico put what exactly in a step event?
Great tutorial Shaun, thanks for sharing. I've been looking for something like this for my projects!
How do I properly set shadowcaster flags? .Dirty doesn't seem to update the shadows
Hi, is it possible to make height of light (z coordinate) to achieve length of the shadow? Is it possible to use custom light type (custom light aplha sprite)? Is it possible to use global light? Have u seen old CBNA smart light (search in the youtube)?
Works, when i run on windows, but when i run on android, lights and shadows are not working, evrything is just really dark, anyone know soulution?
Can you have a light sprite that acts as a torch from a player object to the mouse?
Just a quick question, I need some help would be greatly appreciated!:
How would I check the light levels/intensity at an x,y coordinate
Thanks
Please if anyone has a spare moment it would really help, trying to make my first real project outside of tutorials and struggling
which functions or scripts should I modify to have a less dark screen or a more powerful light?
i solved problem. i founded in script lighiting_global the variable global.ambientShadowIntensity change it and darkness intensity change
this is freaking awesome, im gonna put this into my project
I get an error whenever I destroy an object that's a child of obj_shadow_caster. It's related to the polygon it creates. How do I fix this?
ERROR in
action number 1
of Draw Event
for object obj_light_renderer:
trying to index a variable which is not an array
at gml_Script_polygon_get_area (line 15) - var px = pt[eVertex.X];
############################################################################################
gml_Script_polygon_get_area (line 15)
gml_Script_lighting_pre_composite (line 19) - cached_polygon_area = polygon_get_area(polygon);
gml_Script_composite_shadow_map (line 10) - lighting_pre_composite();
gml_Object_obj_light_renderer_Draw_0 (line 8) - exists = composite_shadow_map(global.worldLights);
How do i get extensions in game maker? Do i need to buy a licence?
Sorry if someone already asked but there is an issue with light leaking through adjacent tiles(obj). Does anybody know how to fix this?
Hi! Did you find the solution? I have the same issue.
Got it) By setting the shadow intensity in the "draw_shadow_map" script to 0^:
shader_set_uniform_f_array (global.u_TexelSize_ShadowMap, [0.1 / surface_get_width (surface), 0.1 / surface_get_height (surface)]).
Also, play with this line (set numbers between 0.0 and 1) and obj_light (parent object. like in the video) variable definition to get the smoothest result.
@@Oliwarder great. I tried to "fix" it by making the collision mask 1 pixel larger but your solution is probably best.
@@hidoimusic6184 Glad I helped) After 5 month) I mean, I just found this tutor. Actually, I'm creating a game too. There is a teaser on my channel)
Nice engine, unfortunately with complicated shapes shadows start overlap on each other, not sure if it is possible to solve.
Doesn't work on my mac, not even the demo rooms :(
my god this is awsome, and it still works for me, which is also awsome
You're the reason i use gamemaker studio
it is possible to create a little shadow caster ? because with downing the shadow_lenght variable, when i am to close to the object, the shadow of the point near to me create a shadow on the object and it's soooo ugly
I've started using this system, and It has a huge potential. Would love to see more videos about this system.
Especially about how to optimize room with a lot of light sources.
This system has comments everywhere, but I don't really understand how it works with cameras?
Is there a way not to cast shadows if an object is outside of your camera view to save computing resources?
I would also like to know if anybody finds a good optimization for this.
@@xea7844 Use light_ignore_shadow_caster() when it's out of screen. In the demo you can find an example of this function
@@MaxSkaw oh sweet I'll have to try that. Thanks!
@Check Old comment but could you elaborate? I'm desperate lol
Good lecture introducing awesome resource. By the way, I am curious about how you scaled the code- without scaling the code editor- like 6:36~6:38 Is there any command key for doing that?
F7 and F8 zoom in/out respectively. (Or it's reversed I don't remember)
can you make something like tile based lighting? it's should be helpful if you made it!
hey man i got a question i use this for my player but the light isnt big enough so it makes most of the room dark how can i make the radius bigger?
Just when I was thinking that it would be nice if you did a lighting tutorial
Vesk well he didnt he just showed how to work with his precoded system
On the Mac Creator version of gms2 the shadows seem to work perfectly but the individual lights don’t seem to render
Do you have any idea why this happens?
Edit: I followed your tutorial step by step not sure why it doesn’t wrk
Hey! I found the answer in one of the reviews on the YoYo Games marketplace page.
"In all vertices shader (sh_blend_light.vsh and sh_shadow_map.vsh), replace all references "in_Texcoord" with "in_TextureCoord" and it'll work."
@@BeingFriends hm, maybe I didn't do this right, but I did a find and replace all for in_Textcoord --> in_TextureCoord and I still don't see anything. :(
same here
the shadows only works with cube? or have a way to use the shadows in more complex images?
anyone having a problem with lights not wworking on mac???
(dont tell me about the in_Textcoord or smth i tried it and it still doesnt work)
Yes mine do not work
@@kidnamedfinger6306 that was like a year ago 💀💀
@@Spario your point?
@@kidnamedfinger6306 i dont use mac anymore sorry
Hello, thank you for the tutorial, I have a question, there is a polygon for the shadow, the problem is, my object is a tree, how can I use the sprite to do the shadow? thank you
does anyone know how to affect individual lights. I was trying to create a flickeriing on and off light and when i created it. it would affect all the lights.
I have a Test light with an alarm in the create
that alarm looks like this
light[| eLight.Intensity] = 0;
then i have another alarm that goes off after another 10 frames but again this affects this object and even other different light objects.
So theyre all going off which is cool but id like to affect individual lights.
So I already have a day and night system for my game and was wondering can this be used strictly for my dungeons? I know I can use it but would it have any major downfalls if I don't make it persistent and call it in the rooms I need?
I can't make a new create event because there already is one what do I do?
Does this work in Game Maker 8.1 Professional Edition?
Is there any way to use it with tilemaps? Something like generating a bunch of polygons with the tilemap data
Did you figure it out?
@@l0m-dev have interes too
But how do you make a lighting system that doesn't have infinite shadows? A system where the shadow length is based on a given height value for each object.
hi shaun I'm using this asset, and would like to ask how I would go about adding layer based lighting, the issue I've been trying to solve with this engine, is disabling the lighting effect for the background layers or a specific layer in general.
the only thing making light rn is my screen because its 3am and ive been doing this for 4 hours and it still isnt working
How can I use this in android? Light not working normally. Sometimes room being darkness, sometimes room being lighter.
Any way to make the sprites cast shadows, instead of the collision boxes?
make a sprite collision layer and use the same collision as the sprite
Wow! I’ve always wanted this :)
how can I make it work with tiles?
Have you found out? I also wanna know
@@peremoyaserra2749 My solution would be to make a shadow caster as an invisible object, then place it over any tilemap you want to have cast a shadow.
@@noisynixx It's what I ended up doing but it's not very elegant
Why don´t just move the x and y of the object oTestLight ?
Because while the original light is *placed* at oTestLight it doesn't follow it. oTestLight simply creates the light. Technically you could make and manage many lights from one object, this is just a convenient way to track them.
How do you save object with lighting with JSON?
Just found if you don't have any shadow casters, the lighting system doesn't do anything.
I wanted lights without shadows (for my own reasons), so solved this by creating an off-camera shadow caster dummy object.
I've run into a problem with my game where it gives me an error saying it can't create a surface with a width or height of 0. I have no idea what causes this. When I make an entirely new room as in the video everything works just fine, but with my older rooms the game crashes right away. Any ideas what might cause this?
I'm having the same issue
@@jacobfauston6837 I just figured out it has to do with the viewports. When I turn them off it works perfectly, but with them turned on the game crashes. Now I just need to figure out how to set the window size without having viewports. Any ideas?
@@TjuserX Alright, I found a way to fix it! Re enable viewports first of all. Then you'll need to change your object camera, in that object is probably camera_create(). But as it turns out you need to change it into camera_create_view(). I never used that yet, but it fixes the crash.
@@jacobfauston6837 Fantastic, thanks man! I'll try that right now.
Ah it sort of works right now, except the shadows aren't appearing where they should. They are now disjointed from the actual shadow casters.
Hi Shaun! Thanks for all of the tutorials that you're making! I must say that's a gorgeous free 2 use lightning system.
I'm also in search of information or video about initializing/loading rooms.
When should a user create one, and how to define if all is loaded and ready
to be shown inside of actual game world?
Any good sources of info for that? Would also love to see a video from you on that topic one day.
Everything is just dark and no light is being cast. Any help?
Amazing bro, congrats!
Great tutorial as always! Keep it up :)
Would this work with tiles?
I have an issue. The child object always has the same sprite as the child object for some reason
Can this lighting be used for comercial use?
Yes
Does this work with multiple cameras? I have situations where my view consists of 2 camera views combined into the actual view, is this flexible enough to work in a situation like that?
I tried and it doesn't work straight out of the box with multiple cameras. Any idea if adding support for 2 or more active cameras is possible?
I was looking for a tutorial on how to make this kind of thing, could you do one of those?
ya im doing everything exactly as you say and its not working, my room is now dark but there is no light being cast anywhere.
any help?
with me too :( I'm searching, but not found any solution for this. have U found?
This just doesnt work for mew on my mac. I get no lights even with one of the bundled demo rooms. Shame.
how to show the shadow of a round object?
Make sure it has a round bounding (collision) area in the sprite. Alternatively there should be polygon creation functions (i.e. polygon_create(set) where set is a 1d array of eVertex, though you'd have to look to find out what an eVertex is).
*Edit:* Turns out that it actually uses the square collision box. So you'll have to use the alternative method.
Thankfully I found out how to set up your vertex array:
set[0] = [x,y];
set[1] = [x,y + 16];
//Continue for all points - it shouldn't take too many to create a decent circle
*Edit 2:* For a visual editor just create a path and use polygon_from_path(path,xOrigin,yOrigin).
@@DiamondWolfX Thank you so much man! And where did you found info on eVertex? Google seem to know nothing.
Certain variables apparently aren't defined for me. I had to manually add them in.
This implies quite strongly you did something wrong or have your instance creation order off. Everything is handled by the main object as demonstrated in the video. I'd be careful about patching this over yourself instead of working out what went wrong.
Very good looking lighting system, but it's very slow on version GM 2.3, both in a stand-alone demo project and integrated into my existing game. Any ideas on how to fix this?
I was ready to download and try this until I read this comment--do you think this makes it unusable? were you able to figure this out at all?
@@CopyCopyOriginal I think it was my machine. Apparently the surface pro chokes graphic speed to make up for the fact it doesn't have a proper fan. 🤔
This is lit👌 I hope you can play my game when it's finished
"Lit"
Ha, I get it
Lince Assassino loooooool that was accidental pun, I was just being myself 😂😅
@@Temzy I wanna see your game.
Kaare Withersmann lool You're gonna have a wait a year
@@Temzy Niieeeeeaaaaaooooooo !!!! Well, gonna sub *in case you post some dev vids at some point. gl with the game.
cool very cool, i had already tested the lightSystem2D but my graphics card vents would fire up, iam on a ATi raedonR9 msi overclocked by factory. But using this method and adding it to the game all the GPU fans are quiet. ( iam guessing the lightSystem2D default room is made to stress the gpu )
Is it possible to make the light follow an object instead of the mouse?
yes. "light[| eLight.Y] = oPlayer.y;"
@@arnarkarlsson9916 I have tried it, but for some reason it did not seem to work for me tho; the lighting system would not appear to be working, I would still get the same character on a plain map. And after moving it around for a bit, the game would just crash for some reason.
@@jgordon9022 Did you find a solution? I have the same problem with the SpotLight
does this apply to particles?
I'm getting an error that says: "Can't create a surface with either a width or height of 0" at gml_Script_shadow_map_ensure_exists (line 24) . Line 24 is "shadowMap = surface_create(vw, vh);". If anyone already had this error, can you tell me how to fix it?
Hey. I have the same problem. Appeared after I started using "cameras" instead of "views". I don’t have a solution yet either
@@ОпустошенныйСон i don't know if i'm using cameras or views, i'm a beginner at gms2. If you find a way to fix this, can you tell me?
@@ofaca1429 I think I found a solution. I apologize for possible errors and other stuff - I am not a native speaker and used Google Translate
Our problem is that the lighting system is designed to work with the old camera system. The script "lighting_get_active_camera" uses functions of the type "camera_get_view" which work only with cameras created in the room settings, or through the function "camera_create_view()". Cameras created through "camera_create()" do not support these functions.
So we need to replace all these functions with the actual values used for our camera. In my case, the script "lighting_get_active_camera" now looks like this:
if(global.worldCustomCamera == undefined) {
// Get active view camera
var camera = co_cam.vcam_cam // camera_get_active();
var cameraX = co_cam.vcam_cam_x-co_cam.vcam_width/2 //camera_get_view_x(camera);
var cameraY = co_cam.vcam_cam_y-co_cam.vcam_height/2 //camera_get_view_y(camera);
var cameraW = co_cam.vcam_width //camera_get_view_width(camera);
var cameraH =co_cam. vcam_height // camera_get_view_height(camera);
return [cameraX, cameraY, cameraW, cameraH];
}
return global.worldCustomCamera;
Where object "co_cam" controls all my cameras. The meaning of the remaining variables should be clear. With this fix, lighting now works for me
@@ОпустошенныйСон You don't need to apologize. I'm not a native speaker neither.
Thank tou for your help. I can't wait to make this work in my games. Thanks :D
How do you make the shadow casters non-static so that the shadow can move with the object
try putting ' polygon = polygon_from_instance(id); ' into Step Event instead of the Create Event
@@BenAitkenhead thanks for this tips. It work well. I will now check the perf if I got too many moving obj :)
Very easy, nice and beautiful, but, i can't use that with the Camera And ViewPort. Why?
I'm having the same problem!?!?!?!?!
Does anybody know how to fix the errors that appear? I cannot run the game. Please help!
What errors appear?
@@joeljames8591 ERROR in
action number 1
of Draw Event
for object obj_light_renderer:
Can't create a surface with either a width or height of 0
at gml_Script_shadow_map_ensure_exists (line 25) - shadowMap = surface_create(vw, vh);
@@uwwwu9954 fuck, i'm getting the same thing. the fact that both of us are getting this now probably means it's a new issue with 2.3...
@@uwwwu9954 ok, i traced the issue to these variables for the height and width it wants to draw the surface. it tries to pull them from the camera width and height, but the way it's trying to do that is honestly way over my head and i have no idea how to troubleshoot that. setting those variables to a high number can get the game to run without crashing, but things don't really render properly...
how can I change the intensity of the light?
You can try to play with the variable in lighting_global script: "global.ambientShadowIntensity = 0.85" line 25
So I know this is an old video but I was wondering if anybody could help me out? Whenever I put more than one light in my room it absolutely TANKS my FPS. Any Ideas?
it's super resource-intensive. optimize, use fewer lights, reduce their range, and even then you're probably out of luck.
after following this exactly my game doesn't launch and the error message "Script: light_cull at line 20 : unexpected symbol "[|" in expression" pops up.
please help
mine too, give the same mistake
Would this work with 3D GMS2 projects as well?
It's 2D for a reason...
how do you change the colors of the lights?
could you find it mate?
Hey, I'm having an issue where multiple light sources in different rooms are massively impacting on the performance, anyone have any idea what it could be?
same issue here anyone figure out why? its causing alot of lag
there is a a way to change the color of the light?
look at variable definitions of obj_light
2nd variable is Light_color, you can change it there.
@@pillow855
Wow thank you!!
its throwing an error for "flags not set before reading" ??
I had the same problem, you probably have some child objects of your Crate who do not inherit the creation event from the parent. So to solve this issue, make sure every object that is a child of a shadow caster has the 'event_inherit()' script in the creation event
Hey Shaun could you make a video on how to do physics like king Arthurs gold? Im really honestly stumped on how to do it and I dont see any of your videos show anything like it
Lol, I don't think KAG's code serves as any type of example on what to do when it comes to code.
Is it possible that this dose not work on Mac OS X?
Hey! I found the answer in one of the reviews on the YoYo Games marketplace page.
"In all vertices shader (sh_blend_light.vsh and sh_shadow_map.vsh), replace all references "in_Texcoord" with "in_TextureCoord" and it'll work."
@@BeingFriends its not working ;/
Anyone else getting a cleanup error?
Variable oTestLight.light(100465, -2147483648) not set before reading it.
at gml_Object_obj_light_CleanUp_0 (line 3) - light_remove_from_world(light);
Change the name of this variable "light". Apparently there is a global variable called light, this variable should be private in the object
how to use a yymp file?
can you please convert it into compatible with gamemaker 1.4?
Somehow it will not work for me, no stranger to these tutorials and they always have worked like charm! But this time I have no idea what I could be doing wrong. I followed everything step-by-step, tried it first in an existing project, then in a fresh new project just to see if anything was conflicting with my pre-existing code etc. I tried it with the parent-child objects and without (using the included objects) to check if anything there was going wrong. Still everything just goes dark (but still visible) as if the lights wont "turn on". If I pump up the light intensity then everything just goes light. Anybody have any suggestions? Double checked the instance creation order and layer orders... no idea why I cant get it to work :-S
Even weirder: just imported the tool again WITH the demo components and ran the demo rooms. They don't work either. Could there be anything regarding the shaders that perhaps would only work on Windows? I'm on GameMaker for Mac (paid Creator license, should that be of any importance). Or am I just not seeing something?
me too. It not work,Mac gamemaker studio2
@@DankerAnimation Thanks for your comment, looks like it's a Mac thing then (brace yourself: mac jokes are coming) Hope there's a way to bypass the issue as to why it wouldn't work. It looks so awesome. I have no idea myself unfortunately. Praying for a quick fix, because this looks so awesome :)
Same problem with Desktop license on Mac. :-(
Ward Crockett bummer! :( looks like we’re just excluded from this awesomeness then.
My light seems to grow dimmer with every room... and I don't know why
That could be a core gameplay mechanic :3
followed it step by step and I've got this: global variable name 'lightDefaultExtensions' index (100012) not set before reading it.
Double check to see if obj_lighting_init is the first instance created in your room.
I can't download the project since I'm using the evaluation version of GMS2
Lighting System 2D
Jobo
You need a paid GameMaker Studio 2 licence in order to have access to this asset.
Contact Publisher | Support
Maybe not working anymore or not working on the javascript builds. But currently not working like in the other comments.
Boo'ya! :D Thanks, buddy :D