8.8 (5 votes)
    GM 6
    March 23, 2006
Dev - DB/form (refering to updated - check code)
    DOWNLOAD (933)
Dev - make AJAX
Screenshots (3)
Dev - Also, on form submission, use GD to resize the image as a new thumbnail file
Dev - In the submission form, you can now upload a banner image
SHS Lighting
<i>Simple, high speed lighting.</i>

<b>Controls :</b>
Left arrow : Previous effect.
Right Arrow : Next effect.
Up Arrow : Increase ambient light.
Down Arrow : Decrease ambient light.

<b>Simple because :</b>
All you need to do to create a light is set its parent object to tmpLightSource. Then all manipulation of the light is the same as any other object. image_angle, image_xscale, and so on are applied as they would be normally, with the exception of image_alpha, which can't be used due to the way subtractive drawing works. This can be easily overcome through smart use of image_blend, as demonstrated with the heart shaped lights. Since essentially any object (you must be careful with custom draw events) can be made into a light with this method, any sprite can be used just as easily, including animated sprites. Ambient lighting is also covered in an easy manner. Simply set global.ambientLight to the color you want, and it's done. This allows for easy day/night cycles.

<b>High speed because :</b>
Since lights are represented by simple objects (which require no script) and are handled in only a few lines of code in the controlling object (the inner loop is only one statement), execution is fast. The difference in speed caused by each additional light is minimal. On my laptop (with only on-board video), it took nearly 350 lights (using the first effect) before my framerate dropped below 60.

<b>Files included :</b>
An example demonstrating actual use of the engine, and a version of the file stripped down to just the engine, so as to be easily importable (via File > Merge Game). It really comes down to two resonably simple objects. One of which is simply a parent object for any lights you create.

<b>My thoughts :</b>
Lighting in GM does <i>not</i> have to be complicated. I've seen many lighting engines floating around and most of them are much more complicated (and therefore slower) than they need to be. Unless you need special effects like glare for lights that are too bright, something as simple as this should be fine, and will run much faster than most engines, simply because it does less work. and makes the built in functionality of GM do as much of that work as possible. Remember... GML is slow. ^_^

<b>Updates :</b>
1.1 : Fixed problem with deleting lights.

Target platforms:

Woah that's really GREAT! Thanks for the really great example!
Posted by Droolie March 21, 2006 9:24 - 11.7 years ago
| [#01]

LoL I know of these other light systems, they are very nice but as stated, rather slow...
This one is very simple in comparison, and does basicaly the same thing, and for that it's awsome.
Very cool example indeed.
Posted by membrain March 23, 2006 23:25 - 11.7 years ago
| [#02]

Posted by Kenon March 24, 2006 2:07 - 11.7 years ago
| [#03]

Hmmm... It seems to give an error when I implement it in my game... unknown variable object_index????
Posted by Droolie March 25, 2006 11:55 - 11.7 years ago
| [#04]

Are you perhaps using an earlier version of Game Maker? object_index is one of the built-in variables, indicating which object the instance is actually an instance of. It should never be unknown... The three possibilities that come to mind off-hand are:

1) You are using an old version of GM, which doesn't support object_index.
2) You typoed object_index somehow (incorrect case, maybe)?
3) You moved the code outside of an object.

If none of these seem to be the problem, let me know. I'd be happy to look at the actual file if you need.
Posted by Xemrel March 26, 2006 7:09 - 11.7 years ago
| [#05]

1. I'm using 6.1 REG
2. I didn't typo the object_index
3. The code is in objLightController that 'normally' draws every instance of tmpLightSource.
Anyway, there's only ONE light in the room, could that be the problem?
Posted by Droolie March 26, 2006 7:33 - 11.7 years ago
| [#06]

Okay, can it be the problem that one of the instances is not included in the room?
Posted by Droolie March 26, 2006 8:00 - 11.7 years ago
| [#07]


I found the problem. It was a stupid oversight on my part that had to do with removing a light from the room. I hadn't caught it before because I didn't delete any lights in the example. Whoops. Anyway, it's fixed now, so just re-download the file and use the new version. Sorry about the inconvenience. ^_^;;

<i>For anyone wanting to know more specifically what was wrong, when the lighting controller iterated through the lights to draw them, it neglected to test whether or not they still existed. This matters because Game Maker doesn't actually removed destroyed instances from the list of instances until the next step, so even if they're in the list, they may not exist. Peh.</i>
Posted by Xemrel March 26, 2006 12:19 - 11.7 years ago
| [#08]

Yes! Fixed! Thanks...
Posted by Droolie March 26, 2006 13:26 - 11.7 years ago
| [#09]

Ummm yea not bad, although i cant say i agree with you saying the 'other' engines arent fast for what they do. The only real CPU killer is rendering shadows. By they way dont use a surface as big as the room, only as big as the view window.
Posted by Adventus March 29, 2006 1:39 - 11.7 years ago
| [#10]

odd. it's not working for me. when i put it in my game, it simply shows the screen as a complete black spot.
Posted by V April 06, 2006 0:10 - 11.6 years ago
| [#11]

Super cool!!!!
Posted by Bipshark August 31, 2006 6:30 - 11.2 years ago
| [#12]

Very nice. Check out my latest blog to see your awesome engine in action!!
Posted by Misconstruct September 22, 2006 22:48 - 11.2 years ago
| [#13]

I originally used GearGOD's lighting example for my works in progress, but this lighting engine works really great for my purposes. Wonderfully simplified. :)
Posted by Ryan-Phoenixan November 13, 2006 16:52 - 11 years ago
| [#14]

Great work!

Posted by Flea1991 December 08, 2006 11:17 - 11 years ago
| [#15]

Wow, That really is fast 7/10
Posted by Archive555 April 13, 2007 22:35 - 10.6 years ago
| [#16]

Just feel like commenting again because this engine is so great! Honestly, you cannot beat it's simplicity. I haven't found anything that I prefer to this engine yet.
Posted by Misconstruct June 06, 2007 18:31 - 10.5 years ago
| [#17]

How did you draw the sprites in the end step?
Posted by Titanium July 15, 2008 18:48 - 9.4 years ago
| [#18]

Recent Activity
Active Users (0)