├── GLE.gif ├── GLE.yyp ├── LICENSE ├── README.md ├── objects ├── o_controller │ ├── Create_0.gml │ ├── Step_0.gml │ └── o_controller.yy ├── o_light_drawer │ ├── Create_0.gml │ ├── Draw_0.gml │ └── o_light_drawer.yy ├── o_light_handler │ ├── CleanUp_0.gml │ ├── Create_0.gml │ ├── Draw_0.gml │ ├── Other_10.gml │ └── o_light_handler.yy ├── o_light_mouse │ ├── Step_0.gml │ └── o_light_mouse.yy ├── o_light_par │ ├── Create_0.gml │ ├── Step_0.gml │ └── o_light_par.yy ├── o_light_path │ ├── Create_0.gml │ └── o_light_path.yy ├── o_light_static │ └── o_light_static.yy ├── o_light_static2 │ └── o_light_static2.yy └── o_light_static3 │ └── o_light_static3.yy ├── options ├── linux │ └── options_linux.yy ├── mac │ └── options_mac.yy ├── main │ └── inherited │ │ └── options_main.inherited.yy └── windows │ └── options_windows.yy ├── paths └── p_light │ └── p_light.yy ├── rooms └── room0 │ └── room0.yy ├── scripts ├── project_shadow │ ├── project_shadow.gml │ └── project_shadow.yy ├── project_vertex │ ├── project_vertex.gml │ └── project_vertex.yy └── sign_test │ ├── sign_test.gml │ └── sign_test.yy ├── shaders └── sh_ambient_light │ ├── sh_ambient_light.fsh │ ├── sh_ambient_light.vsh │ └── sh_ambient_light.yy ├── sprites ├── s_collider_16px │ ├── c94ffce1-59ce-4c2f-808d-ec9a70d48903.png │ ├── layers │ │ └── c94ffce1-59ce-4c2f-808d-ec9a70d48903 │ │ │ └── 0c473ed4-591a-4be7-95d1-8c1e329ed2a3.png │ └── s_collider_16px.yy ├── s_collider_1px │ ├── f7e688a2-0f9e-442e-b066-dcda58fadca7.png │ ├── layers │ │ └── f7e688a2-0f9e-442e-b066-dcda58fadca7 │ │ │ └── 49bdfe3d-3f6e-4306-9ec7-0ce4018edfd8.png │ └── s_collider_1px.yy ├── s_collider_8px │ ├── 2cb4d362-cdcc-4957-9edb-686720616eef.png │ ├── layers │ │ └── 2cb4d362-cdcc-4957-9edb-686720616eef │ │ │ └── 9811fd70-41b5-427b-88e1-9ae5645ee774.png │ └── s_collider_8px.yy ├── s_light │ ├── 71757b19-64bf-486d-9141-7e071b501f6c.png │ ├── layers │ │ └── 71757b19-64bf-486d-9141-7e071b501f6c │ │ │ └── 859a3829-375c-4e28-aa57-48f6032851d5.png │ └── s_light.yy ├── s_light2 │ ├── 7922e30c-6cab-4398-a433-21b05e0bdcb6.png │ ├── layers │ │ └── 7922e30c-6cab-4398-a433-21b05e0bdcb6 │ │ │ └── c3be42d2-7162-4f0e-9eb3-e312fe4770a7.png │ └── s_light2.yy ├── s_light3 │ ├── 79cb44af-3ed3-4410-9c72-2b13dddb7d32.png │ ├── layers │ │ └── 79cb44af-3ed3-4410-9c72-2b13dddb7d32 │ │ │ └── c1e4aa15-9795-4b6a-b608-b817e2089059.png │ └── s_light3.yy ├── s_light_mask_128px │ ├── d6cb25e0-e1a2-4b47-a43f-47afbf176a8f.png │ ├── layers │ │ └── d6cb25e0-e1a2-4b47-a43f-47afbf176a8f │ │ │ └── 00de9825-e534-46dc-98d1-bbbbe5bea737.png │ └── s_light_mask_128px.yy ├── s_scene_background │ ├── 3cea73c4-b92e-4e66-96b8-947c31f8c5e0.png │ ├── layers │ │ └── 3cea73c4-b92e-4e66-96b8-947c31f8c5e0 │ │ │ └── 425e9720-765c-4e32-8bf4-187af507f364.png │ └── s_scene_background.yy ├── s_scene_tileset │ ├── be200f3d-7276-4ddb-8c56-0a940ed6ba05.png │ ├── e5a1fc9e-4423-499c-ac0d-dbdef33b2e23.png │ ├── layers │ │ ├── be200f3d-7276-4ddb-8c56-0a940ed6ba05 │ │ │ └── bd3d6c28-dc29-4194-8a1d-25cc7c95c7d8.png │ │ └── e5a1fc9e-4423-499c-ac0d-dbdef33b2e23 │ │ │ └── bd3d6c28-dc29-4194-8a1d-25cc7c95c7d8.png │ └── s_scene_tileset.yy └── s_scene_tileset_a0 │ ├── 2e09b69f-a98c-4ec6-8fd0-70d5003120af.png │ ├── layers │ └── 2e09b69f-a98c-4ec6-8fd0-70d5003120af │ │ └── 83bb8968-cb90-47d0-a2b1-9747d0bc0d3a.png │ └── s_scene_tileset_a0.yy ├── tilesets ├── t_collider_16px │ ├── output_tileset.png │ └── t_collider_16px.yy ├── t_collider_1px │ ├── output_tileset.png │ └── t_collider_1px.yy ├── t_collider_8px │ ├── output_tileset.png │ └── t_collider_8px.yy ├── t_scene │ ├── output_tileset.png │ └── t_scene.yy └── t_scene_0a │ ├── output_tileset.png │ └── t_scene_0a.yy └── views ├── 0165fb8a-7996-4482-afcc-8c9001266fb1.yy ├── 28d75bc6-9734-4d7c-873f-ad0b8eb0422b.yy ├── 299efdbb-1496-4e7f-83ea-e3594dcbe2ca.yy ├── 38b56b75-a0b7-4e69-83e6-249440320a3b.yy ├── 3ef7da56-29f4-42aa-b97e-552c5fc051f3.yy ├── 4320dd01-b435-4f0d-a141-adbbd100f4ff.yy ├── 48486f08-d357-4b6d-ae89-256f29727636.yy ├── 65082e3a-ffba-47a3-b25e-26962887a08e.yy ├── 6529885c-7482-41c2-9ab1-3ca6739a9fe4.yy ├── 6c6a678f-40bf-436c-a674-60ce999ddf9d.yy ├── 7f8594ea-db3e-4987-976b-ea4fae96cb1e.yy ├── 803ce9fe-7716-41a9-91d2-bc7770940764.yy ├── 869a16a3-0c66-49ca-b9ff-21e3a4e25f55.yy ├── 9091ddf7-157f-427e-bc04-c4db40b396a2.yy ├── 9a535fbc-9bfb-4498-bd30-fcd63c646c27.yy ├── a021b336-c9dc-4f54-9b01-4f5628e05018.yy └── a0dc53d3-fc6f-419c-b693-e0d62123acbc.yy /GLE.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bilouw/Gamemaker-Lighting-Engine/d10de98ec2eb1b191fece7b5d526ab65f9dbd860/GLE.gif -------------------------------------------------------------------------------- /GLE.yyp: -------------------------------------------------------------------------------- 1 | { 2 | "id": "f891b0d6-af40-43d6-bca1-ff82bcb926fa", 3 | "modelName": "GMProject", 4 | "mvc": "1.0", 5 | "IsDnDProject": false, 6 | "configs": [ 7 | 8 | ], 9 | "option_ecma": false, 10 | "parentProject": { 11 | "id": "abd0090c-7b5f-4039-98ee-11b7d4d6438e", 12 | "modelName": "GMProjectParent", 13 | "mvc": "1.0", 14 | "alteredResources": [ 15 | { 16 | "Key": "ed6a955d-5826-4f98-a450-10b414266c27", 17 | "Value": { 18 | "id": "cd1c1e49-4864-41d5-920a-8753abaf4476", 19 | "modelName": "GMResourceInfo", 20 | "mvc": "1.0", 21 | "configDeltaFiles": [ 22 | 23 | ], 24 | "configDeltas": [ 25 | "inherited" 26 | ], 27 | "resourceCreationConfigs": [ 28 | "default" 29 | ], 30 | "resourcePath": "options\/main\/options_main.yy", 31 | "resourceType": "GMMainOptions" 32 | } 33 | } 34 | ], 35 | "hiddenResources": [ 36 | 37 | ], 38 | "projectPath": "${base_project}" 39 | }, 40 | "resources": [ 41 | { 42 | "Key": "0165fb8a-7996-4482-afcc-8c9001266fb1", 43 | "Value": { 44 | "id": "c955e630-8331-49c2-9f63-53bf6e6b380f", 45 | "modelName": "GMResourceInfo", 46 | "mvc": "1.0", 47 | "configDeltaFiles": [ 48 | 49 | ], 50 | "configDeltas": [ 51 | 52 | ], 53 | "resourceCreationConfigs": [ 54 | "default" 55 | ], 56 | "resourcePath": "views\/0165fb8a-7996-4482-afcc-8c9001266fb1.yy", 57 | "resourceType": "GMFolder" 58 | } 59 | }, 60 | { 61 | "Key": "08b0177b-6f78-4142-89f0-e9e1b24b2be5", 62 | "Value": { 63 | "id": "fb39f6c3-c3d1-44b6-b71e-d7fab7a5a6bb", 64 | "modelName": "GMResourceInfo", 65 | "mvc": "1.0", 66 | "configDeltaFiles": [ 67 | 68 | ], 69 | "configDeltas": [ 70 | 71 | ], 72 | "resourceCreationConfigs": [ 73 | "default" 74 | ], 75 | "resourcePath": "sprites\/s_collider_1px\/s_collider_1px.yy", 76 | "resourceType": "GMSprite" 77 | } 78 | }, 79 | { 80 | "Key": "0aae366c-b6a6-4b68-be5f-d721d5c75d5d", 81 | "Value": { 82 | "id": "8539e5b0-28ba-4f26-960c-1c2d2026f822", 83 | "modelName": "GMResourceInfo", 84 | "mvc": "1.0", 85 | "configDeltaFiles": [ 86 | 87 | ], 88 | "configDeltas": [ 89 | 90 | ], 91 | "resourceCreationConfigs": [ 92 | "default" 93 | ], 94 | "resourcePath": "objects\/o_controller\/o_controller.yy", 95 | "resourceType": "GMObject" 96 | } 97 | }, 98 | { 99 | "Key": "145adb4a-2a80-4ff5-a2ce-0f05882da165", 100 | "Value": { 101 | "id": "2f3fefe4-234a-400a-9e63-65377c3363a8", 102 | "modelName": "GMResourceInfo", 103 | "mvc": "1.0", 104 | "configDeltaFiles": [ 105 | 106 | ], 107 | "configDeltas": [ 108 | 109 | ], 110 | "resourceCreationConfigs": [ 111 | "default" 112 | ], 113 | "resourcePath": "tilesets\/t_collider_16px\/t_collider_16px.yy", 114 | "resourceType": "GMTileSet" 115 | } 116 | }, 117 | { 118 | "Key": "1a0fa6b8-2576-4624-9308-54d0d395064d", 119 | "Value": { 120 | "id": "bf1cd19c-6af5-4697-8b96-a98ceaffd6de", 121 | "modelName": "GMResourceInfo", 122 | "mvc": "1.0", 123 | "configDeltaFiles": [ 124 | 125 | ], 126 | "configDeltas": [ 127 | 128 | ], 129 | "resourceCreationConfigs": [ 130 | "default" 131 | ], 132 | "resourcePath": "objects\/o_light_static3\/o_light_static3.yy", 133 | "resourceType": "GMObject" 134 | } 135 | }, 136 | { 137 | "Key": "221c22c3-69c2-4441-bb71-ddc7249ed99e", 138 | "Value": { 139 | "id": "8ab34c07-c6ce-4116-81f2-b3fd3d7e2954", 140 | "modelName": "GMResourceInfo", 141 | "mvc": "1.0", 142 | "configDeltaFiles": [ 143 | 144 | ], 145 | "configDeltas": [ 146 | 147 | ], 148 | "resourceCreationConfigs": [ 149 | "default" 150 | ], 151 | "resourcePath": "tilesets\/t_collider_1px\/t_collider_1px.yy", 152 | "resourceType": "GMTileSet" 153 | } 154 | }, 155 | { 156 | "Key": "237dd067-ef1e-437e-bbb9-42b62f101d6c", 157 | "Value": { 158 | "id": "15c1d943-fd2f-4a6a-afc3-4c28d23dba64", 159 | "modelName": "GMResourceInfo", 160 | "mvc": "1.0", 161 | "configDeltaFiles": [ 162 | 163 | ], 164 | "configDeltas": [ 165 | 166 | ], 167 | "resourceCreationConfigs": [ 168 | "default" 169 | ], 170 | "resourcePath": "sprites\/s_light2\/s_light2.yy", 171 | "resourceType": "GMSprite" 172 | } 173 | }, 174 | { 175 | "Key": "23d6342f-a9c8-4bef-9c23-6306221b99f6", 176 | "Value": { 177 | "id": "b2670bf6-a6b5-46e7-a26a-25f88d0344a9", 178 | "modelName": "GMResourceInfo", 179 | "mvc": "1.0", 180 | "configDeltaFiles": [ 181 | 182 | ], 183 | "configDeltas": [ 184 | 185 | ], 186 | "resourceCreationConfigs": [ 187 | "default" 188 | ], 189 | "resourcePath": "shaders\/sh_ambient_light\/sh_ambient_light.yy", 190 | "resourceType": "GMShader" 191 | } 192 | }, 193 | { 194 | "Key": "28b60203-5fc5-4600-9da8-654c4715b113", 195 | "Value": { 196 | "id": "591b7c13-ebc7-4652-87c8-ab2321970718", 197 | "modelName": "GMResourceInfo", 198 | "mvc": "1.0", 199 | "configDeltaFiles": [ 200 | 201 | ], 202 | "configDeltas": [ 203 | 204 | ], 205 | "resourceCreationConfigs": [ 206 | "default" 207 | ], 208 | "resourcePath": "tilesets\/t_collider_8px\/t_collider_8px.yy", 209 | "resourceType": "GMTileSet" 210 | } 211 | }, 212 | { 213 | "Key": "28d75bc6-9734-4d7c-873f-ad0b8eb0422b", 214 | "Value": { 215 | "id": "a567b68d-1660-434e-9f78-12423b9ed826", 216 | "modelName": "GMResourceInfo", 217 | "mvc": "1.0", 218 | "configDeltaFiles": [ 219 | 220 | ], 221 | "configDeltas": [ 222 | 223 | ], 224 | "resourceCreationConfigs": [ 225 | "default" 226 | ], 227 | "resourcePath": "views\/28d75bc6-9734-4d7c-873f-ad0b8eb0422b.yy", 228 | "resourceType": "GMFolder" 229 | } 230 | }, 231 | { 232 | "Key": "299efdbb-1496-4e7f-83ea-e3594dcbe2ca", 233 | "Value": { 234 | "id": "4051334a-108b-45d2-8f9d-aad440a19c0b", 235 | "modelName": "GMResourceInfo", 236 | "mvc": "1.0", 237 | "configDeltaFiles": [ 238 | 239 | ], 240 | "configDeltas": [ 241 | 242 | ], 243 | "resourceCreationConfigs": [ 244 | "default" 245 | ], 246 | "resourcePath": "views\/299efdbb-1496-4e7f-83ea-e3594dcbe2ca.yy", 247 | "resourceType": "GMFolder" 248 | } 249 | }, 250 | { 251 | "Key": "38b56b75-a0b7-4e69-83e6-249440320a3b", 252 | "Value": { 253 | "id": "48212228-6130-40c6-9dfe-9a3afb4acdfb", 254 | "modelName": "GMResourceInfo", 255 | "mvc": "1.0", 256 | "configDeltaFiles": [ 257 | 258 | ], 259 | "configDeltas": [ 260 | 261 | ], 262 | "resourceCreationConfigs": [ 263 | "default" 264 | ], 265 | "resourcePath": "views\/38b56b75-a0b7-4e69-83e6-249440320a3b.yy", 266 | "resourceType": "GMFolder" 267 | } 268 | }, 269 | { 270 | "Key": "3ef7da56-29f4-42aa-b97e-552c5fc051f3", 271 | "Value": { 272 | "id": "4db3164d-02aa-4cf0-b41c-31dd10990b7c", 273 | "modelName": "GMResourceInfo", 274 | "mvc": "1.0", 275 | "configDeltaFiles": [ 276 | 277 | ], 278 | "configDeltas": [ 279 | 280 | ], 281 | "resourceCreationConfigs": [ 282 | "default" 283 | ], 284 | "resourcePath": "views\/3ef7da56-29f4-42aa-b97e-552c5fc051f3.yy", 285 | "resourceType": "GMFolder" 286 | } 287 | }, 288 | { 289 | "Key": "3f206c1a-4bcb-45d5-b3e0-37aae570da7a", 290 | "Value": { 291 | "id": "3cee25d0-ba29-4554-a584-9382144ef9aa", 292 | "modelName": "GMResourceInfo", 293 | "mvc": "1.0", 294 | "configDeltaFiles": [ 295 | 296 | ], 297 | "configDeltas": [ 298 | 299 | ], 300 | "resourceCreationConfigs": [ 301 | "default" 302 | ], 303 | "resourcePath": "scripts\/project_vertex\/project_vertex.yy", 304 | "resourceType": "GMScript" 305 | } 306 | }, 307 | { 308 | "Key": "4320dd01-b435-4f0d-a141-adbbd100f4ff", 309 | "Value": { 310 | "id": "84faf0b2-87e6-484f-b862-c74ec0e7293f", 311 | "modelName": "GMResourceInfo", 312 | "mvc": "1.0", 313 | "configDeltaFiles": [ 314 | 315 | ], 316 | "configDeltas": [ 317 | 318 | ], 319 | "resourceCreationConfigs": [ 320 | "default" 321 | ], 322 | "resourcePath": "views\/4320dd01-b435-4f0d-a141-adbbd100f4ff.yy", 323 | "resourceType": "GMFolder" 324 | } 325 | }, 326 | { 327 | "Key": "48486f08-d357-4b6d-ae89-256f29727636", 328 | "Value": { 329 | "id": "122a821a-7f50-40fd-bf20-6d54a43aa18b", 330 | "modelName": "GMResourceInfo", 331 | "mvc": "1.0", 332 | "configDeltaFiles": [ 333 | 334 | ], 335 | "configDeltas": [ 336 | 337 | ], 338 | "resourceCreationConfigs": [ 339 | "default" 340 | ], 341 | "resourcePath": "views\/48486f08-d357-4b6d-ae89-256f29727636.yy", 342 | "resourceType": "GMFolder" 343 | } 344 | }, 345 | { 346 | "Key": "4d59eaba-95cc-4b22-930e-5bf3f98fffef", 347 | "Value": { 348 | "id": "135d5025-54f6-4b9b-bf0b-d56d82dcfa28", 349 | "modelName": "GMResourceInfo", 350 | "mvc": "1.0", 351 | "configDeltaFiles": [ 352 | 353 | ], 354 | "configDeltas": [ 355 | 356 | ], 357 | "resourceCreationConfigs": [ 358 | "default" 359 | ], 360 | "resourcePath": "sprites\/s_light3\/s_light3.yy", 361 | "resourceType": "GMSprite" 362 | } 363 | }, 364 | { 365 | "Key": "4d5b41bf-d552-4c1a-bb81-7a25217b9e70", 366 | "Value": { 367 | "id": "3f7747e1-8aa5-4428-b4a1-05fa48016929", 368 | "modelName": "GMResourceInfo", 369 | "mvc": "1.0", 370 | "configDeltaFiles": [ 371 | 372 | ], 373 | "configDeltas": [ 374 | 375 | ], 376 | "resourceCreationConfigs": [ 377 | "default" 378 | ], 379 | "resourcePath": "tilesets\/t_scene\/t_scene.yy", 380 | "resourceType": "GMTileSet" 381 | } 382 | }, 383 | { 384 | "Key": "5834f378-8762-40ce-a889-0c500d2911f4", 385 | "Value": { 386 | "id": "48e6f28d-4747-4f7a-8e8f-b6aca484fb1a", 387 | "modelName": "GMResourceInfo", 388 | "mvc": "1.0", 389 | "configDeltaFiles": [ 390 | 391 | ], 392 | "configDeltas": [ 393 | 394 | ], 395 | "resourceCreationConfigs": [ 396 | "default" 397 | ], 398 | "resourcePath": "tilesets\/t_scene_0a\/t_scene_0a.yy", 399 | "resourceType": "GMTileSet" 400 | } 401 | }, 402 | { 403 | "Key": "65082e3a-ffba-47a3-b25e-26962887a08e", 404 | "Value": { 405 | "id": "d7e9736d-1e4c-4b9e-acf6-48256641bb38", 406 | "modelName": "GMResourceInfo", 407 | "mvc": "1.0", 408 | "configDeltaFiles": [ 409 | 410 | ], 411 | "configDeltas": [ 412 | 413 | ], 414 | "resourceCreationConfigs": [ 415 | "default" 416 | ], 417 | "resourcePath": "views\/65082e3a-ffba-47a3-b25e-26962887a08e.yy", 418 | "resourceType": "GMFolder" 419 | } 420 | }, 421 | { 422 | "Key": "6529885c-7482-41c2-9ab1-3ca6739a9fe4", 423 | "Value": { 424 | "id": "4b6148f7-3091-42c0-9f5f-ffef6d5567da", 425 | "modelName": "GMResourceInfo", 426 | "mvc": "1.0", 427 | "configDeltaFiles": [ 428 | 429 | ], 430 | "configDeltas": [ 431 | 432 | ], 433 | "resourceCreationConfigs": [ 434 | "default" 435 | ], 436 | "resourcePath": "views\/6529885c-7482-41c2-9ab1-3ca6739a9fe4.yy", 437 | "resourceType": "GMFolder" 438 | } 439 | }, 440 | { 441 | "Key": "6587220d-2aa4-489e-8f97-81d6e4af4066", 442 | "Value": { 443 | "id": "6efe5681-470f-4e2c-84cf-cea7ed23425f", 444 | "modelName": "GMResourceInfo", 445 | "mvc": "1.0", 446 | "configDeltaFiles": [ 447 | 448 | ], 449 | "configDeltas": [ 450 | 451 | ], 452 | "resourceCreationConfigs": [ 453 | "default" 454 | ], 455 | "resourcePath": "scripts\/project_shadow\/project_shadow.yy", 456 | "resourceType": "GMScript" 457 | } 458 | }, 459 | { 460 | "Key": "6c6a678f-40bf-436c-a674-60ce999ddf9d", 461 | "Value": { 462 | "id": "1da42873-87d5-477f-b9f0-8f68e4720aee", 463 | "modelName": "GMResourceInfo", 464 | "mvc": "1.0", 465 | "configDeltaFiles": [ 466 | 467 | ], 468 | "configDeltas": [ 469 | 470 | ], 471 | "resourceCreationConfigs": [ 472 | "default" 473 | ], 474 | "resourcePath": "views\/6c6a678f-40bf-436c-a674-60ce999ddf9d.yy", 475 | "resourceType": "GMFolder" 476 | } 477 | }, 478 | { 479 | "Key": "78bfcb17-d638-495e-933a-dcc0cf0f6924", 480 | "Value": { 481 | "id": "e130c9af-935e-443c-b34e-b83fcc4465fa", 482 | "modelName": "GMResourceInfo", 483 | "mvc": "1.0", 484 | "configDeltaFiles": [ 485 | 486 | ], 487 | "configDeltas": [ 488 | 489 | ], 490 | "resourceCreationConfigs": [ 491 | "default" 492 | ], 493 | "resourcePath": "objects\/o_light_static\/o_light_static.yy", 494 | "resourceType": "GMObject" 495 | } 496 | }, 497 | { 498 | "Key": "7f8594ea-db3e-4987-976b-ea4fae96cb1e", 499 | "Value": { 500 | "id": "d501f2b8-c126-4526-97f8-6ca104d2a033", 501 | "modelName": "GMResourceInfo", 502 | "mvc": "1.0", 503 | "configDeltaFiles": [ 504 | 505 | ], 506 | "configDeltas": [ 507 | 508 | ], 509 | "resourceCreationConfigs": [ 510 | "default" 511 | ], 512 | "resourcePath": "views\/7f8594ea-db3e-4987-976b-ea4fae96cb1e.yy", 513 | "resourceType": "GMFolder" 514 | } 515 | }, 516 | { 517 | "Key": "803ce9fe-7716-41a9-91d2-bc7770940764", 518 | "Value": { 519 | "id": "ad3f24be-e747-41a2-81d0-75fd33e7f77b", 520 | "modelName": "GMResourceInfo", 521 | "mvc": "1.0", 522 | "configDeltaFiles": [ 523 | 524 | ], 525 | "configDeltas": [ 526 | 527 | ], 528 | "resourceCreationConfigs": [ 529 | "default" 530 | ], 531 | "resourcePath": "views\/803ce9fe-7716-41a9-91d2-bc7770940764.yy", 532 | "resourceType": "GMFolder" 533 | } 534 | }, 535 | { 536 | "Key": "81706db9-2731-4dc6-b92f-3df3006fb647", 537 | "Value": { 538 | "id": "647613b8-1f2c-4c8f-b6a7-19732eaabacf", 539 | "modelName": "GMResourceInfo", 540 | "mvc": "1.0", 541 | "configDeltaFiles": [ 542 | 543 | ], 544 | "configDeltas": [ 545 | 546 | ], 547 | "resourceCreationConfigs": [ 548 | "default" 549 | ], 550 | "resourcePath": "objects\/o_light_drawer\/o_light_drawer.yy", 551 | "resourceType": "GMObject" 552 | } 553 | }, 554 | { 555 | "Key": "8654544e-fbab-469d-b07d-50e825e37145", 556 | "Value": { 557 | "id": "0878f31b-30b3-490b-bb50-817266833638", 558 | "modelName": "GMResourceInfo", 559 | "mvc": "1.0", 560 | "configDeltaFiles": [ 561 | 562 | ], 563 | "configDeltas": [ 564 | 565 | ], 566 | "resourceCreationConfigs": [ 567 | "default" 568 | ], 569 | "resourcePath": "sprites\/s_collider_8px\/s_collider_8px.yy", 570 | "resourceType": "GMSprite" 571 | } 572 | }, 573 | { 574 | "Key": "869a16a3-0c66-49ca-b9ff-21e3a4e25f55", 575 | "Value": { 576 | "id": "cc166fb3-c041-4569-9bf8-ce9d92321921", 577 | "modelName": "GMResourceInfo", 578 | "mvc": "1.0", 579 | "configDeltaFiles": [ 580 | 581 | ], 582 | "configDeltas": [ 583 | 584 | ], 585 | "resourceCreationConfigs": [ 586 | "default" 587 | ], 588 | "resourcePath": "views\/869a16a3-0c66-49ca-b9ff-21e3a4e25f55.yy", 589 | "resourceType": "GMFolder" 590 | } 591 | }, 592 | { 593 | "Key": "8ae1ba0a-ae70-4de2-a948-70cdc66f9b23", 594 | "Value": { 595 | "id": "85fdc753-f6cb-4c06-913f-86ff348f4af4", 596 | "modelName": "GMResourceInfo", 597 | "mvc": "1.0", 598 | "configDeltaFiles": [ 599 | 600 | ], 601 | "configDeltas": [ 602 | 603 | ], 604 | "resourceCreationConfigs": [ 605 | "default" 606 | ], 607 | "resourcePath": "objects\/o_light_path\/o_light_path.yy", 608 | "resourceType": "GMObject" 609 | } 610 | }, 611 | { 612 | "Key": "8fa22ea2-8a9b-48e4-8099-fc4253b94712", 613 | "Value": { 614 | "id": "b0fad167-a38a-4cdf-961f-7804ef83e86b", 615 | "modelName": "GMResourceInfo", 616 | "mvc": "1.0", 617 | "configDeltaFiles": [ 618 | 619 | ], 620 | "configDeltas": [ 621 | 622 | ], 623 | "resourceCreationConfigs": [ 624 | "default" 625 | ], 626 | "resourcePath": "rooms\/room0\/room0.yy", 627 | "resourceType": "GMRoom" 628 | } 629 | }, 630 | { 631 | "Key": "9091ddf7-157f-427e-bc04-c4db40b396a2", 632 | "Value": { 633 | "id": "9cb0b860-b3f9-4a3e-adb1-bfd68661d103", 634 | "modelName": "GMResourceInfo", 635 | "mvc": "1.0", 636 | "configDeltaFiles": [ 637 | 638 | ], 639 | "configDeltas": [ 640 | 641 | ], 642 | "resourceCreationConfigs": [ 643 | "default" 644 | ], 645 | "resourcePath": "views\/9091ddf7-157f-427e-bc04-c4db40b396a2.yy", 646 | "resourceType": "GMFolder" 647 | } 648 | }, 649 | { 650 | "Key": "9a535fbc-9bfb-4498-bd30-fcd63c646c27", 651 | "Value": { 652 | "id": "2b0fcec6-831b-4621-9dce-f8f5d8faa0de", 653 | "modelName": "GMResourceInfo", 654 | "mvc": "1.0", 655 | "configDeltaFiles": [ 656 | 657 | ], 658 | "configDeltas": [ 659 | 660 | ], 661 | "resourceCreationConfigs": [ 662 | "default" 663 | ], 664 | "resourcePath": "views\/9a535fbc-9bfb-4498-bd30-fcd63c646c27.yy", 665 | "resourceType": "GMFolder" 666 | } 667 | }, 668 | { 669 | "Key": "a021b336-c9dc-4f54-9b01-4f5628e05018", 670 | "Value": { 671 | "id": "fdaf1ae6-fd2c-4347-beaa-a0269c28cd07", 672 | "modelName": "GMResourceInfo", 673 | "mvc": "1.0", 674 | "configDeltaFiles": [ 675 | 676 | ], 677 | "configDeltas": [ 678 | 679 | ], 680 | "resourceCreationConfigs": [ 681 | "default" 682 | ], 683 | "resourcePath": "views\/a021b336-c9dc-4f54-9b01-4f5628e05018.yy", 684 | "resourceType": "GMFolder" 685 | } 686 | }, 687 | { 688 | "Key": "a0dc53d3-fc6f-419c-b693-e0d62123acbc", 689 | "Value": { 690 | "id": "46dfd247-37d8-47ae-8ff4-f59a09108ad1", 691 | "modelName": "GMResourceInfo", 692 | "mvc": "1.0", 693 | "configDeltaFiles": [ 694 | 695 | ], 696 | "configDeltas": [ 697 | 698 | ], 699 | "resourceCreationConfigs": [ 700 | "default" 701 | ], 702 | "resourcePath": "views\/a0dc53d3-fc6f-419c-b693-e0d62123acbc.yy", 703 | "resourceType": "GMFolder" 704 | } 705 | }, 706 | { 707 | "Key": "a25eda14-d538-45d9-aac0-8cec2eb41ddf", 708 | "Value": { 709 | "id": "e5c87e89-1dbb-43da-94c9-fe227472a7e0", 710 | "modelName": "GMResourceInfo", 711 | "mvc": "1.0", 712 | "configDeltaFiles": [ 713 | 714 | ], 715 | "configDeltas": [ 716 | 717 | ], 718 | "resourceCreationConfigs": [ 719 | "default" 720 | ], 721 | "resourcePath": "objects\/o_light_handler\/o_light_handler.yy", 722 | "resourceType": "GMObject" 723 | } 724 | }, 725 | { 726 | "Key": "a762329b-617c-4bb3-bb70-bacf962448f0", 727 | "Value": { 728 | "id": "17e66d7d-f223-4fc8-b170-795a982d0896", 729 | "modelName": "GMResourceInfo", 730 | "mvc": "1.0", 731 | "configDeltaFiles": [ 732 | 733 | ], 734 | "configDeltas": [ 735 | 736 | ], 737 | "resourceCreationConfigs": [ 738 | "default" 739 | ], 740 | "resourcePath": "sprites\/s_light_mask_128px\/s_light_mask_128px.yy", 741 | "resourceType": "GMSprite" 742 | } 743 | }, 744 | { 745 | "Key": "a9188620-a624-4a5a-83ae-a1b53faf038b", 746 | "Value": { 747 | "id": "b6687f0d-a200-4a80-aab7-1e76c0ff3aa2", 748 | "modelName": "GMResourceInfo", 749 | "mvc": "1.0", 750 | "configDeltaFiles": [ 751 | 752 | ], 753 | "configDeltas": [ 754 | 755 | ], 756 | "resourceCreationConfigs": [ 757 | "default" 758 | ], 759 | "resourcePath": "options\/linux\/options_linux.yy", 760 | "resourceType": "GMLinuxOptions" 761 | } 762 | }, 763 | { 764 | "Key": "afe11900-1c46-41b0-b268-2826e155b74a", 765 | "Value": { 766 | "id": "22cf36a9-662c-4c53-9cd1-99e059e210c4", 767 | "modelName": "GMResourceInfo", 768 | "mvc": "1.0", 769 | "configDeltaFiles": [ 770 | 771 | ], 772 | "configDeltas": [ 773 | 774 | ], 775 | "resourceCreationConfigs": [ 776 | "default" 777 | ], 778 | "resourcePath": "paths\/p_light\/p_light.yy", 779 | "resourceType": "GMPath" 780 | } 781 | }, 782 | { 783 | "Key": "bac85dd8-61c8-441d-9b38-87e88aa4df70", 784 | "Value": { 785 | "id": "f1c09734-ed25-4122-8f8e-b0a34266b8e2", 786 | "modelName": "GMResourceInfo", 787 | "mvc": "1.0", 788 | "configDeltaFiles": [ 789 | 790 | ], 791 | "configDeltas": [ 792 | 793 | ], 794 | "resourceCreationConfigs": [ 795 | "default" 796 | ], 797 | "resourcePath": "sprites\/s_light\/s_light.yy", 798 | "resourceType": "GMSprite" 799 | } 800 | }, 801 | { 802 | "Key": "c3b59141-74dd-4b5d-8aaf-6810bfdcba00", 803 | "Value": { 804 | "id": "1a8b534a-2e27-4409-b32f-346601aeff8a", 805 | "modelName": "GMResourceInfo", 806 | "mvc": "1.0", 807 | "configDeltaFiles": [ 808 | 809 | ], 810 | "configDeltas": [ 811 | 812 | ], 813 | "resourceCreationConfigs": [ 814 | "default" 815 | ], 816 | "resourcePath": "sprites\/s_scene_background\/s_scene_background.yy", 817 | "resourceType": "GMSprite" 818 | } 819 | }, 820 | { 821 | "Key": "ca641cf8-5c99-45fc-8f2f-38ca037d9808", 822 | "Value": { 823 | "id": "e78a7d1b-45e5-49a9-8311-303160f38468", 824 | "modelName": "GMResourceInfo", 825 | "mvc": "1.0", 826 | "configDeltaFiles": [ 827 | 828 | ], 829 | "configDeltas": [ 830 | 831 | ], 832 | "resourceCreationConfigs": [ 833 | "default" 834 | ], 835 | "resourcePath": "scripts\/sign_test\/sign_test.yy", 836 | "resourceType": "GMScript" 837 | } 838 | }, 839 | { 840 | "Key": "cc98d028-7bdd-4680-85f3-c87a7baa481e", 841 | "Value": { 842 | "id": "470d2609-51f8-4b1d-a37c-40c02db1a35c", 843 | "modelName": "GMResourceInfo", 844 | "mvc": "1.0", 845 | "configDeltaFiles": [ 846 | 847 | ], 848 | "configDeltas": [ 849 | 850 | ], 851 | "resourceCreationConfigs": [ 852 | "default" 853 | ], 854 | "resourcePath": "options\/windows\/options_windows.yy", 855 | "resourceType": "GMWindowsOptions" 856 | } 857 | }, 858 | { 859 | "Key": "cfe2add7-1a68-4ef1-841c-1ea937c76745", 860 | "Value": { 861 | "id": "987c8029-5032-4de7-8035-397b56bd74eb", 862 | "modelName": "GMResourceInfo", 863 | "mvc": "1.0", 864 | "configDeltaFiles": [ 865 | 866 | ], 867 | "configDeltas": [ 868 | 869 | ], 870 | "resourceCreationConfigs": [ 871 | "default" 872 | ], 873 | "resourcePath": "sprites\/s_scene_tileset\/s_scene_tileset.yy", 874 | "resourceType": "GMSprite" 875 | } 876 | }, 877 | { 878 | "Key": "d4463bbb-3bea-4fcf-86b9-2f5ab5d5551b", 879 | "Value": { 880 | "id": "6389e434-7653-480f-928d-77b571982b84", 881 | "modelName": "GMResourceInfo", 882 | "mvc": "1.0", 883 | "configDeltaFiles": [ 884 | 885 | ], 886 | "configDeltas": [ 887 | 888 | ], 889 | "resourceCreationConfigs": [ 890 | "default" 891 | ], 892 | "resourcePath": "sprites\/s_scene_tileset_a0\/s_scene_tileset_a0.yy", 893 | "resourceType": "GMSprite" 894 | } 895 | }, 896 | { 897 | "Key": "e57f3735-f766-4fd0-bf74-f167a73c612c", 898 | "Value": { 899 | "id": "f026a11c-d4ca-4103-8d71-060bd2a388b3", 900 | "modelName": "GMResourceInfo", 901 | "mvc": "1.0", 902 | "configDeltaFiles": [ 903 | 904 | ], 905 | "configDeltas": [ 906 | 907 | ], 908 | "resourceCreationConfigs": [ 909 | "default" 910 | ], 911 | "resourcePath": "objects\/o_light_static2\/o_light_static2.yy", 912 | "resourceType": "GMObject" 913 | } 914 | }, 915 | { 916 | "Key": "f418569b-3bdd-4706-a0e4-364317f54032", 917 | "Value": { 918 | "id": "99fa25ef-acdb-442a-828a-ec28e3c9b244", 919 | "modelName": "GMResourceInfo", 920 | "mvc": "1.0", 921 | "configDeltaFiles": [ 922 | 923 | ], 924 | "configDeltas": [ 925 | 926 | ], 927 | "resourceCreationConfigs": [ 928 | "default" 929 | ], 930 | "resourcePath": "options\/mac\/options_mac.yy", 931 | "resourceType": "GMMacOptions" 932 | } 933 | }, 934 | { 935 | "Key": "f5741c99-b16d-4312-8388-f81cedeae82f", 936 | "Value": { 937 | "id": "333b9afe-7eb0-4754-b521-760ba4f4a5b4", 938 | "modelName": "GMResourceInfo", 939 | "mvc": "1.0", 940 | "configDeltaFiles": [ 941 | 942 | ], 943 | "configDeltas": [ 944 | 945 | ], 946 | "resourceCreationConfigs": [ 947 | "default" 948 | ], 949 | "resourcePath": "objects\/o_light_mouse\/o_light_mouse.yy", 950 | "resourceType": "GMObject" 951 | } 952 | }, 953 | { 954 | "Key": "f7295335-cd3d-484f-be82-5662a7f191b3", 955 | "Value": { 956 | "id": "7f296c04-8620-4bd9-8575-d9e946dc7b8b", 957 | "modelName": "GMResourceInfo", 958 | "mvc": "1.0", 959 | "configDeltaFiles": [ 960 | 961 | ], 962 | "configDeltas": [ 963 | 964 | ], 965 | "resourceCreationConfigs": [ 966 | "default" 967 | ], 968 | "resourcePath": "objects\/o_light_par\/o_light_par.yy", 969 | "resourceType": "GMObject" 970 | } 971 | }, 972 | { 973 | "Key": "fe48b22b-e34f-4e3c-9d30-f0c489797a6f", 974 | "Value": { 975 | "id": "c77327b2-0cc6-48e0-8f9f-3bdbc79a41ed", 976 | "modelName": "GMResourceInfo", 977 | "mvc": "1.0", 978 | "configDeltaFiles": [ 979 | 980 | ], 981 | "configDeltas": [ 982 | 983 | ], 984 | "resourceCreationConfigs": [ 985 | "default" 986 | ], 987 | "resourcePath": "sprites\/s_collider_16px\/s_collider_16px.yy", 988 | "resourceType": "GMSprite" 989 | } 990 | } 991 | ], 992 | "script_order": [ 993 | "6587220d-2aa4-489e-8f97-81d6e4af4066", 994 | "3f206c1a-4bcb-45d5-b3e0-37aae570da7a", 995 | "ca641cf8-5c99-45fc-8f2f-38ca037d9808" 996 | ], 997 | "tutorial": "" 998 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 bilouw 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gamemaker Lighting Engine 2 | 3 | ![](GLE.gif) 4 | 5 | Tiles based Lighting Engine that projects shadows. 6 | 7 | The shadows projection is based on a tutorial by Mike Dailly that can be found here : [https://www.yoyogames.com/blog/419/realtime-2d-lighting-in-gamemaker-studio-2-part-1](https://www.yoyogames.com/blog/419/realtime-2d-lighting-in-gamemaker-studio-2-part-1?fbclid=IwAR3RysnCli5LjJS5s3Y9ZbQFEAbvlA1_QC-GVmozdKdm7r0sIFDs1fFKSzA). Thanks to him because it is the most difficult part if you’re not so good at maths. 8 | 9 | Once the shadows are casted, I use a pretty common method to draw the shadows on a light sprite then make blend stuff with surfaces. 10 | 11 | It is not the most impressive light engine, but a good way to start with dynamic light development (which is pretty complex). Also, it can make a pretty good job in 2D games (mostly pixel art) to create some atmosphere and add volume to your scene. 12 | 13 | 14 | ## Usage 15 | 16 | 17 | 18 | ### Initial Setup : 19 | 20 | Just drag and drop the « o_light_handler » object in a layer in your room. The lights and shadows will be applied on every layer below. 21 | 22 | ### Add Lights : 23 | 24 | To add lights, create a child object of « o_light_par ». In « variables definitions » menu, you can set the scale of the radius light. You can also set if the light is static or dynamic. Static lights will be calculated only at room start. 25 | 26 | ### Foreground Lights : 27 | 28 | If you want, you can put a different ambient shadow for background and foreground. Maybe you want to have a very dark background, but a foreground with some assets less dark. You can do this in the Light Handler, just see instructions below. 29 | 30 | 31 | 32 | ### Light Handler : 33 | 34 | You can set differents things in « Variables Definitions » : 35 | 36 | - ambient_light_ : Set the value of the background light in the room. 0 for total shadow and 1 for total light. 37 | 38 | - foreground_ambient_light_ : Set the value of the foreground light in the room. 0 for total shadow and 1 for total light. 39 | 40 | - foreground_depth_ : Set the depth of the foreground. This is where you set up which layer the foreground ambient light is applied on. The default value is -1 which deactivates the foreground ambient shadow. 41 | 42 | 43 | 44 | ### Collider : 45 | 46 | The colliders are the tiles that block the lights and cast the shadows. These tiles can be the size you want, so you can cast a shadow from a tile of 1 pixel. You can also use the tilemap of your collision (if you have tile-based collision) to project shadow on every of your walls. 47 | 48 | To add tilemap, go in the « o_light_handler » and add the tilemap id in the « tilemap_ » variable which is an array. See the project example to learn more. 49 | 50 | ### Improvements : 51 | 52 | The Engine can be improved. Static lights are pretty optimized, but dynamics ones can be heavy to calculate. To improve this, just use static lights when you can, minimize the dynamics light number and radius, or do some improvements (like calcul only dynamics lights present in camera). Below, some improvement that I might do in the future (I use this engine in my game development) : 53 | 54 | - Add some color to the light (easy to do, you can do it yourself) 55 | 56 | - Make some particules/flickering effects. 57 | 58 | - Optimize the calcul of shadows for dynamics lights. 59 | 60 | - To use RGBA channel to draw 4 lights mask per surface (more efficient) and to can make shadows more complex and realistic. 61 | 62 | Here a link of Celeste's creator that explain how lights works in Celeste : https://medium.com/@NoelFB/remaking-celestes-lighting-3478d6f10bf 63 | 64 | In the last part, the optimization i talked ealier is a little bit explained. Also, it's a pretty good explanation on how this engine works too, because i followed most of this method. 65 | 66 | You can also take this project as a base to start, then make your own functionality to make the engine better for you. I hope it will be helpful. 67 | 68 | ## Credits : 69 | 70 | Mike Dailly : For his tutorial on shadows projection https://www.yoyogames.com/blog/419/realtime-2d-lighting-in-gamemaker-studio-2-part-1 71 | 72 | Adam Saltsman : For his free asset pack that i used for this project : https://adamatomic.itch.io/ 73 | 74 | ## License : 75 | 76 | You can use this code in any project (Commercial or not). I just demand to be credited. -------------------------------------------------------------------------------- /objects/o_controller/Create_0.gml: -------------------------------------------------------------------------------- 1 | /// @description 2 | 3 | //show_debug_overlay(true); 4 | display_reset(0, true); 5 | -------------------------------------------------------------------------------- /objects/o_controller/Step_0.gml: -------------------------------------------------------------------------------- 1 | /// @description camera control 2 | 3 | var cx = camera_get_view_x(view_camera[0]); 4 | var cy = camera_get_view_y(view_camera[0]); 5 | var cw = camera_get_view_width(view_camera[0]); 6 | var ch = camera_get_view_height(view_camera[0]); 7 | 8 | if (keyboard_check(vk_right)) { cx+=3; } 9 | else if (keyboard_check(vk_down)) { cy+=3; } 10 | else if (keyboard_check(vk_left)) { cx-=3; } 11 | else if (keyboard_check(vk_up)) { cy-=3; } 12 | 13 | cx = clamp(cx, 0, room_width - cw); 14 | cy = clamp(cy, 0, room_height - ch); 15 | 16 | camera_set_view_pos(view_camera[0], cx, cy); 17 | 18 | 19 | -------------------------------------------------------------------------------- /objects/o_controller/o_controller.yy: -------------------------------------------------------------------------------- 1 | { 2 | "id": "0aae366c-b6a6-4b68-be5f-d721d5c75d5d", 3 | "modelName": "GMObject", 4 | "mvc": "1.0", 5 | "name": "o_controller", 6 | "eventList": [ 7 | { 8 | "id": "db669daa-3ec2-4ff5-86ee-970a3aab72dc", 9 | "modelName": "GMEvent", 10 | "mvc": "1.0", 11 | "IsDnD": false, 12 | "collisionObjectId": "00000000-0000-0000-0000-000000000000", 13 | "enumb": 0, 14 | "eventtype": 3, 15 | "m_owner": "0aae366c-b6a6-4b68-be5f-d721d5c75d5d" 16 | }, 17 | { 18 | "id": "ace4bbe4-b1f1-4cd6-95e7-3b6d00b89c3a", 19 | "modelName": "GMEvent", 20 | "mvc": "1.0", 21 | "IsDnD": false, 22 | "collisionObjectId": "00000000-0000-0000-0000-000000000000", 23 | "enumb": 0, 24 | "eventtype": 0, 25 | "m_owner": "0aae366c-b6a6-4b68-be5f-d721d5c75d5d" 26 | } 27 | ], 28 | "maskSpriteId": "00000000-0000-0000-0000-000000000000", 29 | "overriddenProperties": null, 30 | "parentObjectId": "00000000-0000-0000-0000-000000000000", 31 | "persistent": false, 32 | "physicsAngularDamping": 0.1, 33 | "physicsDensity": 0.5, 34 | "physicsFriction": 0.2, 35 | "physicsGroup": 0, 36 | "physicsKinematic": false, 37 | "physicsLinearDamping": 0.1, 38 | "physicsObject": false, 39 | "physicsRestitution": 0.1, 40 | "physicsSensor": false, 41 | "physicsShape": 1, 42 | "physicsShapePoints": null, 43 | "physicsStartAwake": true, 44 | "properties": null, 45 | "solid": false, 46 | "spriteId": "00000000-0000-0000-0000-000000000000", 47 | "visible": true 48 | } -------------------------------------------------------------------------------- /objects/o_light_drawer/Create_0.gml: -------------------------------------------------------------------------------- 1 | /// @description Insert description here 2 | // You can write your code in this editor 3 | u_ambient_light_ = shader_get_uniform(sh_ambient_light, "u_fAmbientLight"); 4 | ambient_light_ = 1; -------------------------------------------------------------------------------- /objects/o_light_drawer/Draw_0.gml: -------------------------------------------------------------------------------- 1 | /// @description Insert description here 2 | // You can write your code in this editor 3 | 4 | var cx = camera_get_view_x(view_camera[0]); 5 | var cy = camera_get_view_y(view_camera[0]); 6 | var surf = o_light_handler.light_surf_; 7 | 8 | if (surface_exists(surf)) 9 | { 10 | gpu_set_blendmode_ext(bm_dest_color, bm_zero); 11 | shader_set(sh_ambient_light); 12 | shader_set_uniform_f(u_ambient_light_, ambient_light_); 13 | draw_surface(o_light_handler.light_surf_, cx, cy); 14 | shader_reset(); 15 | gpu_set_blendmode(bm_normal); 16 | } -------------------------------------------------------------------------------- /objects/o_light_drawer/o_light_drawer.yy: -------------------------------------------------------------------------------- 1 | { 2 | "id": "81706db9-2731-4dc6-b92f-3df3006fb647", 3 | "modelName": "GMObject", 4 | "mvc": "1.0", 5 | "name": "o_light_drawer", 6 | "eventList": [ 7 | { 8 | "id": "1944a1d8-489d-4693-8b2d-6175089ee16c", 9 | "modelName": "GMEvent", 10 | "mvc": "1.0", 11 | "IsDnD": false, 12 | "collisionObjectId": "00000000-0000-0000-0000-000000000000", 13 | "enumb": 0, 14 | "eventtype": 8, 15 | "m_owner": "81706db9-2731-4dc6-b92f-3df3006fb647" 16 | }, 17 | { 18 | "id": "4f6615a1-a9ae-44fb-a874-50aa0b0e44ee", 19 | "modelName": "GMEvent", 20 | "mvc": "1.0", 21 | "IsDnD": false, 22 | "collisionObjectId": "00000000-0000-0000-0000-000000000000", 23 | "enumb": 0, 24 | "eventtype": 0, 25 | "m_owner": "81706db9-2731-4dc6-b92f-3df3006fb647" 26 | } 27 | ], 28 | "maskSpriteId": "00000000-0000-0000-0000-000000000000", 29 | "overriddenProperties": null, 30 | "parentObjectId": "00000000-0000-0000-0000-000000000000", 31 | "persistent": false, 32 | "physicsAngularDamping": 0.1, 33 | "physicsDensity": 0.5, 34 | "physicsFriction": 0.2, 35 | "physicsGroup": 0, 36 | "physicsKinematic": false, 37 | "physicsLinearDamping": 0.1, 38 | "physicsObject": false, 39 | "physicsRestitution": 0.1, 40 | "physicsSensor": false, 41 | "physicsShape": 1, 42 | "physicsShapePoints": null, 43 | "physicsStartAwake": true, 44 | "properties": null, 45 | "solid": false, 46 | "spriteId": "00000000-0000-0000-0000-000000000000", 47 | "visible": true 48 | } -------------------------------------------------------------------------------- /objects/o_light_handler/CleanUp_0.gml: -------------------------------------------------------------------------------- 1 | /// @description clean surface 2 | 3 | surface_free(light_surf_); 4 | surface_free(shadow_surf_); 5 | surface_free(lightmap_surf_); 6 | surface_free(static_lightmap_surf_); -------------------------------------------------------------------------------- /objects/o_light_handler/Create_0.gml: -------------------------------------------------------------------------------- 1 | /// @description Init variables 2 | /// Some variables are declared in the "Variables definitions" window. 3 | 4 | init_ = false; 5 | light_count_ = instance_number(o_light_par); 6 | // Surfaces 7 | light_surf_ = -1; 8 | shadow_surf_ = -1; 9 | lightmap_surf_ = -1; 10 | static_lightmap_surf_ = -1; 11 | 12 | u_ambient_light_ = shader_get_uniform(sh_ambient_light, "u_fAmbientLight"); 13 | 14 | //Add tilemap here to cast shadows 15 | tilemap_[0] = layer_tilemap_get_id("collider_16px"); 16 | if (layer_exists("collider_1px")) { tilemap_[1] = layer_tilemap_get_id("collider_1px"); } 17 | 18 | if (foreground_depth_ != -1) 19 | { 20 | var lf = instance_create_depth(x, y, foreground_depth_, o_light_drawer); 21 | lf.ambient_light_ = foreground_ambient_light_; 22 | } 23 | 24 | //Create vertex buffer 25 | vertex_format_begin(); 26 | vertex_format_add_position(); 27 | vertex_format_add_color(); 28 | VertexFormat = vertex_format_end(); 29 | 30 | VBuffer = vertex_create_buffer(); 31 | 32 | #region check if surface exists 33 | if( !surface_exists(light_surf_) ){ 34 | light_surf_ = surface_create(128 ,128); 35 | } 36 | if( !surface_exists(shadow_surf_) ){ 37 | shadow_surf_ = surface_create(room_width ,room_height); 38 | } 39 | if( !surface_exists(lightmap_surf_) ){ 40 | lightmap_surf_ = surface_create(camera_get_view_width(view_camera[0]) ,camera_get_view_height(view_camera[0])); 41 | } 42 | if( !surface_exists(static_lightmap_surf_) ){ 43 | static_lightmap_surf_ = surface_create(room_width ,room_height); 44 | } 45 | #endregion -------------------------------------------------------------------------------- /objects/o_light_handler/Draw_0.gml: -------------------------------------------------------------------------------- 1 | /// @description draw lights 2 | 3 | if (!init_) 4 | { 5 | event_user(0); 6 | init_ = true; 7 | } 8 | 9 | #region Check if surfaces exists. 10 | if( !surface_exists(light_surf_) ){ 11 | light_surf_ = surface_create(128 ,128); 12 | } 13 | if( !surface_exists(shadow_surf_) ){ 14 | shadow_surf_ = surface_create(room_width ,room_height); 15 | } 16 | if( !surface_exists(lightmap_surf_) ){ 17 | lightmap_surf_ = surface_create(camera_get_view_width(view_camera[0]) ,camera_get_view_height(view_camera[0])); 18 | } 19 | if( !surface_exists(static_lightmap_surf_) ){ 20 | static_lightmap_surf_ = surface_create(room_width ,room_height); 21 | } 22 | #endregion 23 | 24 | light_count_ = instance_number(o_light_par); 25 | 26 | var cx = camera_get_view_x(view_camera[0]); 27 | var cy = camera_get_view_y(view_camera[0]); 28 | var cw = camera_get_view_width(view_camera[0]); 29 | var ch = camera_get_view_height(view_camera[0]); 30 | 31 | var first_light = true; 32 | for(var i=0; i