Reflex – Dev Diary 46

Over the past couple of weeks I have been developing a new lighting engine with the help of some tutorials from Grizzlius Maximus which is significantly more powerful than the lighting engine I’ve been using in the past. The original lighting engine in Asylum and Reflex is based on drawing shadows and lights using surfaces and although the results are extremely good they make quite an impact on performance so you have to be very careful how they are used.

The new lighting engine I’ve put together uses shaders exclusively to create the same effects. This means that the entire shadow system is handed over to the GPU to deal with reducing the load on the CPU that is dealing with the rest of the game logic. The upside of this is the game can hand hundreds, even thousands, of real-time dynamic lights and still reach 60fps. In comparison to the original lighting I had to ensure that the number of dynamic lights was kept as low as possible (under 10 ideally).

Reflex needed to use static lighting for this reason and although I was happy with the results if I could get to a stage where dynamic lighting was possible I wanted to give it a try.

And so over the last few days I have been removing the previous engine and integrating the new one. Everything slotted in really nicely and I’ve started improving the lighting for the game. The wall lights are now dynamic and I’ve added a light to the missiles booster so that it illuminates darker areas of a map as it passes by and casts nice shadows from the walls. The lights now cast shadows from the walls and other environmental objects. Reactors have been given a pulsing light as well.

The above screenshot is from a world 2 level. You can see here that the light on the left wall is striking the wall and casting a subtle shadow across the ground. I still need to go through each level and make sure the light placements are correct to ensure the level is suitably lit. I’m also going to place lights on the outside of the levels where the start positions are; and I need to increase the shadow caster size as it was set up to apply only to the middle of the wall for the last engine and now it needs to span a bit further out.

Moving away from lighting. I’ve added in a new wall style that is used for World 2. My plan is to have a different wall type for each world.

And finally there was another round of bug fixes. When switching screen resolutions from a lower to a higher one the planet backgrounds would not update correctly. This is down to a restriction with GMS not allowing the currently active room (view) from being altered in resolution. Instead I now set the new resolution change and transition to a secondary room which then in turn updates the game environment resolution and then returns the player to the menu. It sounds clunky but it works smoothly.