Jump to content


Photo

Easy Lighting V7.0.2 | Last Updated: 06/07/11


  • Please log in to reply
465 replies to this topic

#1 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 06 November 2008 - 10:26 PM

NOTICE: THIS ENGINE IS NO LONGER SUPPORTED! I AM STARTING A NEW BRANCH COMPATIBLE WITH STUDIO, CHECK IT OUT HERE

Easy Lighting v7.0.2!
Easy, yet effective.

Wow, up to version 7! When I started this .gex, it was a mere side-project thrown together to solve the issue of the lack of good lighting engines. Now-a-days that isn't much of a problem anymore, but I hope that through 7 full version, 3 rewrites, and many updates later you will be impressed and satisfied by what this .gex has become! This .gex is a full-fledged lighting engine with over 20 functions that provides a simple way to add impressive lighting and shadows to your games. I strive to provide a high-quality .gex that acts and performs as if it were part of GM itself. I am always open for suggestions, opinions, and ideas on how to improve my work and make it better for you. After close to 3 years of working on this .gex, I present to you Easy Lighting v7.0! Let me introduce you to some of the features:


-23 easy to use functions.
-Very flexible.
-Customizable ambient lighting for different moods and times of day.
-5 Included light shapes for quicker production.
-Supports varied light shapes with no extra slowdown!
-Supports animated lights for unique effects.
-Rotate and color your lights easily!
-Lights "interact" with objects and other lights, making moving lights look that much more stunning!
-View support, have the lights limited to a specified view for faster rendering on big levels!
-Option for control of light's update and drawing system. Static lighting? Ok, just draw it once!
-Delete unwanted lights for speed boost.
-Built-in shadow system for amazing results!
-Each shadow point can have a different z value.
-Shadows can be animated and morphed in-game.
-Stack multiple shadows on objects for a more 3D effect.
-Much, so much more.


If that isn't enough to get you interested, check out these screenshots taken from the provided example: (version 7.0)
screenshot1xt.png
-
screenshot2pv.png

Lights aren't just placed on top of objects, they interact with and brighten them! Though, of course, there is the option to remove additive lighting for a more simplistic look.
Here is a quick summary of the functions:[/b]
Lights can be turned on or off at will with lt_lightset/lt_lightset_on, along with the possibility to create flashing and blinking lights (among others) with ease!

So why are you still reading and not downloading? It is a small file-size and well worth the download!

FILE:
(v7.0.2) Download 1.2mb .zip <- .gex should now work with GM7 and GM4MAC, but not the example.

(v6.2 old) Download 800kb .zip <- Download, Made for GM8.0. (NOT COMPATIBLE WITH GM7 BECAUSE OF RESOURCE LOADING DIFFERENCES)

If you guys could leave feedback and tell me what you think, that would be very much appreciated. Thanks.

As always, with all of my .gex files, no credit is ever required (though appreciated) and you can use this .gex in both free and commercial projects.
Note: If you decide to credit me, please use the name Thagen Pinch

Extra Credit:
- With version 6.x+ I took a few ideas from the LS3 lighting engine by Adventus.



Changes In v7 Rewrite:
[b]lt_sysset - Set's properties for the lighting system
lt_lightadd - Creates a new light and returns an id
lt_lightset - Adjusts settings for an existing light
lt_lightdelete- Delete's a light
lt_lightget_x - Get's x position of a light
lt_lightget_y - Get's y position of a light
lt_lightget_on - Returns if a light is on or off
lt_lightget_castsshadows - Returns if the light can cast shadows
lt_lightexists - Returns if a light exists
lt_lightcount - Returns the number of lights created
lt_lightset_x - Sets a light's x position
lt_lightset_y - Sets a light's y position
lt_lightset_on - Turns a light on/off
lt_lightset_castsshadows - Enables/Disables shadow casting for this light
lt_refresh - Manually updates lighting settings
lt_redraw - Manually draws lights onto screen
lt_shadcreate - Creates a new shadow shape
lt_shadbegin - Starts defining new shadow shape
lt_shadreset - Resets the points for a shadow so they can be re-defined
lt_shadpoint - Adds a point to the shadow
lt_shadend - Ends the shadow shape
lt_shadobj - Assigns an object with a specified shadow
lt_shadsetobj - Re-sets properties for an object and shadow

There are many internal changes and there may be some compatibility issues.
-You can now define multiple shadows at once. As a result, the process is slightly different.
-I removed the internal built-in lights for GM7 compatibility. I provided 5 shapes in the file, however, as a substitute.
-Much greater optimization for large areas, providing bigger speed boosts when objects/lights are out of view.
-Added many quick return functions for ease of use.
-Fixed many invisible internal remnants that could cause crashes/slowdown over long play times.
-Added returns to almost every function.
-Added a few more personal error messages, more to come, for when the user does something wrong (Rather than a confusing GM message).
-Completely re-wrote the example, making it easier to understand and more step-by-step.
-Wrote a quick function list (html file) that provides a brief rundown of every function.
-Fixed many minor bugs, such as black screen when no lights exist, among others.
-Made everything more efficient and easy to access so 1) Faster results for you, 2) Easier for me to modify.
-Source code is not provided with v7, nor will it ever be.


Edited by Scyler_27, 31 March 2013 - 04:17 AM.

  • 12

#2 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 11 November 2008 - 05:12 AM

Hi there! Why is no one leaving feedback? Makes me sad. :P You know, even if you DON'T like it, you can still leave feedback, thanks. :)

Anyway, I have updated the lighting engine to v2! I added colored lights, you don't HAVE to define their color, if you do not it is set to "no color" which, believe it or not, IS different than white. If you do define their color, you need to insert the color (or c_nocolor if you don't want a color) and the alpha. (I suggest 0.5) Also, you will need to place light_colorset_step() somewhere, but only if you are using colors. (And I suggest placing it AFTER light_set_step() )

Well, please leave feedback guys! It is always appreciated!
  • 0

#3 kburkhart84

kburkhart84

    Firehammer Games

  • GMC Member
  • 1917 posts
  • Version:GM:Studio

Posted 11 November 2008 - 05:34 AM

I looked at it. It looks like it does the job well. I could see this being used possibly in my Organic Metal(no link yet). Towards the last levels, I think you will be fighting the aliens on their homeworld, and it may be where you have a level where you are inside a tunnel going to the final boss, or something like that. I could see good use for it. In fact, it could be useful in some game where the lighting defines the gameplay. I could see that happening.
  • 0

#4 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 18 November 2008 - 05:35 PM

Thanks kburk, hope you choose to use it, and wish you luck. ;)

To all else, I am really open for ideas and feedback. If you have an idea feel free to suggest it! No guarantee I will add it, but I will mostly likely give it a shot. Even if it is a comment about something you DON'T like, POST IT so I can DO something about it!

Thanks. ;)
  • 0

#5 flankattack

flankattack

    BETA Tester

  • New Member
  • 407 posts

Posted 21 November 2008 - 05:49 AM

This is cool. If you are making a topdown war game where one (or more) levels are at night; USE THIS.
  • 0

#6 death-droid

death-droid

    GMC Member

  • GMC Member
  • 2600 posts

Posted 21 November 2008 - 10:50 AM

How about doing a basic day night system that supports lights....
  • 0

#7 BUD

BUD

    GMC Member

  • New Member
  • 163 posts

Posted 22 November 2008 - 05:32 PM

BUD

Hi. do you think you can add like a flashlight effect??
  • 0

#8 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 24 November 2008 - 03:37 AM

Scyler, I love this! It's great. So simple, yet so good. Thank you a ton.

BUD: Try making a sprite that looks similar to what a flashlight beam would look like and use it in place of sh_* when your creating your light. Look at his example where he uses a sprite to define how the light looks.

Edited by bocochoco, 25 November 2008 - 09:59 PM.

  • 0

#9 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 28 November 2008 - 04:35 AM

Thank you guys for the comments and feedback! It is greatly appreciated. :lol:

@death-droid: I might add that to the next big update, good idea. Thanks.

@BUD: As boko said, you can create your own light shapes with custom sprites like in the example.

I did find a problem with using custom images though, it causes big lag if using too many. I will be fixing that once I have access to the computer with the .ged.
  • 0

#10 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 30 November 2008 - 10:38 PM

Wow it's really nice works great and is easy to customise lights.
Is it possible to rotate a light?

And heres my torch/spotlight which works quite well.
Posted Image

Edited by Krisando, 30 November 2008 - 10:41 PM.

  • 0

#11 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 30 November 2008 - 11:15 PM

I am glad you like my .gex. :)

As for rotation, I forgot to add that. O_o I can't believe it! Haha, I will add that to the next update! Thanks. (I might be able to update today, depending on how easy it is to fix a current lag issue with custom sprites)

EDIT: I have updated the .gex! Now v2.2, download same link!

Edited by Scyler_27, 01 December 2008 - 12:05 AM.

  • 0

#12 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 02:06 AM

Nice update Scyler. I love this engine =) Did you fix the lag issue with the custom sprite lights? I haven't had time to check yet.

Also, would it be possible to get a function to set the ambient light color and intensity? Instead of having it be pitch black wherever there isn't a light. Even a parameter on light_init() would be great.

Thanks a ton

<(^-^<) <(^-^)> (>^-^)>

edit: I just tested it out. With lots of custom sprite lights, it does lag =(. I had 12 of them and it lagged pretty bad. Also lags quite a bit with 4 of them. a flashlight that follows the mouse, and three rotating emergency lights.

Edited by bocochoco, 01 December 2008 - 02:56 AM.

  • 0

#13 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 03:37 AM

Dang really? I thought I fixed it. (I put about 15 with 30 fps, though now I just tested and put around 25 and it went around 18-25 fps) Well I think I know what the problem could be, I will probably be able to upload a new version within an hour or two. As for the light color, that isn't too hard so I will see if I can add that while I am at it. :)

EDIT: Ok, I really DID fix the lag issue this time! I tested it with 30 custom lights all rotating towards the mouse and it was at 30fps the whole time. Also, I added the option to change the surrounding light to whatever color you want. Though I think it looks best black, white looks cool too. :D You set its properties in the light_init() function, and you can change it with the newly added light_main_set() function. In the example you can right click to change it.

EDIT2: @bocochoco, I forgot to say, I will try adding the option to change the darkness alpha sometime tomorrow if I get the time. It is going to be hard to figure out how to do with the colored lights.

Edited by Scyler_27, 01 December 2008 - 05:10 AM.

  • 0

#14 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 05:06 AM

Sweet. Looks great. I kinda feel like I didn't get my idea across properly though. I was thinking of something that would make objects in the room not completely black, but allow you to add a sort of ambient light across the entire room. So that rather than the entire room being dark, and only being able to see where there is a light, there can be a small amount of light throughout the entire room.

Also, thank you soo much for adding the rotating lights option. I did manage to get them to rotate though, by drawing the sprite rotated on a surface every step and making a sprite out of it to use for the light. That really lagged like holy hell.


Edit: Sorry if I'm being picky :) Just seems like something important for a lighting engine.
Edit again: no lag!!!! Freakin awesome

Edited by bocochoco, 01 December 2008 - 05:12 AM.

  • 0

#15 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 05:15 AM

Sweet. Looks great. I kinda feel like I didn't get my idea across properly though. I was thinking of something that would make objects in the room not completely black, but allow you to add a sort of ambient light across the entire room. So that rather than the entire room being dark, and only being able to see where there is a light, there can be a small amount of light throughout the entire room.

You mean like being able to set how dark the "darkness" is? So you can see through it a little or make it look like dawn instead of night etc? If that is what you mean, I understood and will be trying to make it tomorrow. I just thought I would try making the color-change function tonight since it was pretty easy to implement. :)
  • 0

#16 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 05:17 AM

That is exactly what I mean. I would imagine that adding an alpha parameter would be able to handle that, but I've got no idea how you've coded this. I look forward to seeing what you come up with next.

Also, this might be tough to do as well, but perhaps adding a way for objects to block light?

Edited by bocochoco, 01 December 2008 - 05:18 AM.

  • 0

#17 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 05:21 AM

I have a bug for you =]
My view & room is larger then 640x480, so I get a square 640x480 not filling whole view =]
[IMG Edited]

Also, this might be tough to do as well, but perhaps adding a way for objects to block light?

I would think thats related to shadows :)
I really would like the alpha darkness aswel =]

The latest version has given me errors, and all kidns of glitches hmm

Edited by Krisando, 02 December 2008 - 09:20 PM.

  • 0

#18 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 07:05 AM

@bocochoco, yes that would be considered shadows. I am extremely iffy about shadows because they will be EXTREMELY hard to do.

@Krisando, That is extremely wierd. The lighting system isn't based around the view, it covers the entire level. It uses room_width and such so it is impossible for it to do that. Are you sure part of the view isn't going outside of the room? Since the lighting stops at the edge of the room, if you have the view go beyond it would give what you are seeing right now. I tried testing multiple things with views and room sizes just now and couldn't get the same problem as you. Mind making a quick example of how you got that problem and sending it to me? Would be greatly appreciated. :)
  • 0

#19 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 07:22 AM

I suppose that would be shadows. Would be pretty awesome if you could figure out a way to do that.
  • 0

#20 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 07:23 AM

@Krisando, That is extremely wierd. The lighting system isn't based around the view, it covers the entire level. It uses room_width and such so it is impossible for it to do that. Are you sure part of the view isn't going outside of the room? Since the lighting stops at the edge of the room, if you have the view go beyond it would give what you are seeing right now. I tried testing multiple things with views and room sizes just now and couldn't get the same problem as you. Mind making a quick example of how you got that problem and sending it to me? Would be greatly appreciated. :)

Ohh I figured why, the object I made create before the room started which had a room size of 640x480 to avoid an error.
Also I get this error in the latest which didn't appear in previous versions

___________________________________________
ERROR in
action number 2
of Step Event
for object o_bullet_1:

In extension function light_set_light:
Error in code at line 1:
var ID;ID=argument0;global.__lightx[ID]=argument1;glob
al.__lighty[ID]=argument2;global.__lightdiam[ID]=ar
gument3;global.__lighttype[ID]=argument4;var LIGHT;LIGHT=argument5;global.__lightangle[ID]=argu
ment6;if (LIGHT>=0&&LIGHT!=global.__lightshape_orig[ID]){

at position 235: Unknown variable __lightshape_orig or array index out of bounds


  • 0

#21 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 07:59 AM

Ok guys, I updated it, you now have your customisable suround lighting! Tell me what you think!

@bocochoco, Heh well, I will see if I can get shading in later versions, but no guarantees. :)

@Krisando, Oh I see. At the end of that room you can place light_end(); then just start it up again at the beginning of the next room. That should re-set EVERYTHING. (Though I actually haven't tested the light_end() much so there might be a few bugs, tell me if you come across any.) As for the error, I am not getting it, but I will check into it to see what is going wrong. (Also, could you download the new version and tell me if you get the error?)

EDIT: Also @Krisando, I just remembered, if you use light_set_light before using light_add_light then it should give you that error. Make sure that you are creating the light first.

Edited by Scyler_27, 01 December 2008 - 08:06 AM.

  • 0

#22 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 08:05 AM

Ive made the code that makes light around your mouse instead shed light around multiple objects, ill try make an example of error.
Odd that it worked in previous versions

Error Example
=]

Edited by Krisando, 01 December 2008 - 08:09 AM.

  • 0

#23 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 08:10 AM

Huh... Ok that would be great. What the error is saying, is that it is trying to check for the original image shape of a certain light, but that that light hasn't been created. So it is is giving an error. But this should only happen with custom lights, since you said you were using the exact code from the mouse (and that wasn't a custom light) that would be a big problem... Unless you ARE using a custom light?

EDIT: Huh, you are right... that is odd. Well, I DID upload a version with an error, but uploaded a fixed version about 1 minute later. You might just have happened to get the bad version. Download the newest version, it is v3.0 and has more features anyway. The example I uploaded with it works fine for me.

Edited by Scyler_27, 01 December 2008 - 08:14 AM.

  • 0

#24 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 08:22 AM

Keep with the constant updates =]

I noticed the 2 latest versions the x and possibly y coordinates have been noticibly changed position,
still get error. Ill just make it a custom light

Edited by Krisando, 01 December 2008 - 08:23 AM.

  • 0

#25 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 08:24 AM

Excellent stuff scyler. Keep the updates coming

Edited by bocochoco, 01 December 2008 - 08:26 AM.

  • 0

#26 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 08:26 AM

I've gotten that error too, after changing from 2.2 to 2.3. I checked treat uninitialized variables as zero and it went away. Though a fix for it would be preferable.

Thats for a workaround =]
  • 0

#27 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 08:30 AM

Hey just noticed you uploaded 3.0... I like. But I get an error, goes away with the workaround

[codebox]
In extension function light_set_light:
Error in code at line 1:
var ID;ID=argument0;global.__lightx[ID]=argument1;glob
al.__lighty[ID]=argument2;global.__lightdiam[ID]=a
r
gument3;global.__lighttype[ID]=argument4;var LIGHT;LIGHT=argument5;global.__lightangle[ID]=argu
ment6;if (LIGHT>=0&&LIGHT!=global.__lightshape_orig[ID])
{ sprite_delete(global.__lightshape[ID]) global.__lightshape[ID]=LIGHT; global.__lightshape_orig[ID]=sprite_duplicate(argu
ment5); sprite_set_alpha_from_sprite(global.__lightshape_o
rig[ID],global.__lightshape_orig[ID]); var TEMP; TEMP=global.__lightshape_orig[ID];
global.__lightshape_orig[ID]=global.__lightshape[I
D]; global.__lightshape[ID]=TEMP;}

at position 235: Unknown variable __lightshape_orig or array index out of bounds
[/codebox]

edit: fixed it so it didn't make the page expand. i hate that

Edited by bocochoco, 01 December 2008 - 09:14 AM.

  • 0

#28 Binsk

Binsk

    -Insane Kid-

  • GMC Member
  • 2917 posts
  • Version:GM:Studio

Posted 01 December 2008 - 08:34 AM

Hm, so it is still giving the error... Thanks... So wierd, it isn't giving it to me at all. I don't want you to have to use a work-around for it to work right. :) I will devote 10 minutes to trying to find a fix, then I need to go to bed. (2am and school tomorow. >.< ) If I don't fix tonight, I will try tomorow.

EDIT: I don't know why the example wouldn't work, but I THINK I might have found the problem. I will upload a (hopefully) fix in a few min. If it isn't the fix you have to wait till tomorow.

Edited by Scyler_27, 01 December 2008 - 08:40 AM.

  • 0

#29 bocochoco

bocochoco

    GMC Member

  • New Member
  • 140 posts

Posted 01 December 2008 - 08:37 AM

I know the feeling bro, I've got class in about 5 hours (its actually 4am here) and I've yet to sleep =) No need to update tonight, though I wouldn't complain.

Edited by bocochoco, 01 December 2008 - 08:40 AM.

  • 0

#30 Krisando

Krisando

    GMC Member

  • New Member
  • 1351 posts

Posted 01 December 2008 - 08:37 AM

Hm, so it is still giving the error... Thanks... So wierd, it isn't giving it to me at all. I don't want you to have to use a work-around for it to work right. :) I will devote 10 minutes to trying to find a fix, then I need to go to bed. (2am and school tomorow. >.< ) If I don't fix tonight, I will try tomorow.

Wow your dedicated xD
Good to know your extension means more to you then school :D
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users