Block Lighting Engine 2D – Version 1.1 Is Live!

Posted on

It has already been about 2 months since I launched Block Lighting Engine 2D on the Unity Asset Store and during that time I had a blast discovering what works and what doesn’t. While I was cooling down from figuring out the great puzzle to make the lighting work, I worked on Terrainify 2D, which is my second (and free) asset that is now also live on the Unity Asset Store.

While I was working on Terrainify 2D, I received clear feedback on Block Lighting Engine 2D from a buyer. It happened to be something I could also improve on Terrainify 2D so that’s what I did first. Shortly after releasing Terrainify 2D it was verified by a 5-star rating with encouraging words and it made me grab my paid asset again for its first major update.

Since I ended up making Terrainify 2D a free asset, the first thing I wanted to do is to incorporate that into Block Lighting Engine 2D. I figured that anyone who buys this asset would want a chunking system to go along with the engine since it’s an effective and highly efficient way of dynamically loading and unloading sections of a world. The first version was something that just worked, more of an ‘example of 2D block lighting’ as accurately described by a reviewer. It simply had this large array of data with a fixed size and it was always loaded in memory. The reason for this is because I initially planned to make Terrainify 2D a paid asset and I wanted that asset to include the chunk loading part. I actually downgraded Block Lighting Engine 2D for this reason, even though it already worked with chunks in my game!

The second major change was a huge performance boost to the existing code. The worst part of it is that I was sitting on the solution all this time while debugging and I never actually thought about making it a functional part of the asset. For debugging purposes I often found myself having to slow down the lighting executions to actually be able to see what happened in the background on screen. Normally I had all lights simply calculate their whole thing in a single frame per light and even though performance-wise it often stayed above 60 frames per second, it was quite apparent while profiling. So what if we slow down these calculations just a little bit? Say, a thousand iterations before it should wait a frame before continuing? If you combine this with the fact that all lights are loaded in chunks outside the player’s viewing area, it makes sense that it doesn’t matter if the lights take a few frames to complete correct visuals. The player never sees it! I also decided to incorporate this into the lighting UI, giving the user total control on how taxing the lighting system actually is for their own games. No matter how many years of experience you have, I can guarantee you that stupid epiphanies like these will keep happening to you. And it doesn’t matter. Moments like these teach you the most and allow you to grow and shape you as a developer.

So what will the future bring for this asset? I am thinking of implementing a day / night cycle option that’ll adjust the natural lighting depending on the time of day. Knowing my system, it actually isn’t that hard to implement, but I can’t say anything about a potential release date right now. Make sure to follow this website for updates on this and my other projects since this is the place where they are posted first. This update comes with many more features and improvements than what I just listed, so make sure to check out the update video at the top or the updated asset description, which I’ll add below:

What is it?
Block Lighting Engine 2D provides everything you need for a propagating light framework that penetrates the ground. This engine includes a two-layer system to also simulate a lesser back-layer falloff, as you would expect in cave environments. It is fully 2D and works with Unity’s Tilemap system.

Core features
– Ambient lighting and colored lights, all customizable in color and strength;
– A highly optimized algorithm ensuring incredibly fast light updates that aren’t bound to the number of active lights directly for every action. You can have hundreds of lights in view with only a fraction of the performance loss;
– A complete lighting user interface with settings like:
– – – – Core performance control, guaranteed high performance without frame drops on any system with the right setting;
– – – – Light penetration adjustment for the front and back layer;
– – – – Toggling all lighting effects on or off with the press of a button;
– – – – Back layer shading for finetuning visuals.
The user interface also provides tools right out of the box like:
– – – – Placing blocks on any layer;
– – – – Removing blocks on any layer;
– – – – Placing lights throughout the world;
– – – – Removing lights;
– A terrain generator combined with a robust chunk loading system with a matching terrain user interface and basic tools to experiment with lighting on any world type;
– A guide explaining the asset in its entirety, including how to set it up in your game, F.A.Q. and more as well as fully documented code for each script.

Requirements
– Unity 2017.2 or later for direct download and play functionality with Unity’s Tilemap system is highly recommended. Earlier versions of Unity should work if hooked up to your own block data structures with reference tweaking.

Future plans
– A day/night cycle system;
– [Finished] A thorough expansion of engine functions to make it easier to manipulate the engine;

This slideshow requires JavaScript.