This is the best lighting solution found for the computer game “Disco-Robo”. How does it work, and why is it considered to be the most optimized way for lighting? Without going into too much detail, we first need to understand shaders. Shaders are designed for GPU manipulation, changing the rule of how every pixel is drawn, and how vertices are configured. When it comes to lighting, it can be a very heavy task for GPUs. Imagine what the computer has to go through every frame. Calculate the distance of a light source from the pixel in correlation to the vertex, modify further depending on the vertex normal, etc.. In this situation, if you want a moderate frame rate, you will only have around 8 lights in a scene at a time. But what about deferred rendering? You can have almost as much light in a scene as you want!
Well, there is a pro and con for every lighting system, and for deferred rendering, the con would be no shadows. Light would bleed through every wall, like most lighting shaders. Secondly, the software that uses a shader to draw the lighting scene needs access to MRTs (Multiple Render Targets) in order to read and write shader data to three different passes at a time per pixel calculation. Unfortunately, GameMaker Studio 1.4 does not support MRTs. Guess what Disco-Robo was developed in? GMS 1.4.
So, if Disco-Robo wanted to use deferred rendering, it would be possible; That is, if you want to draw every vertex 3 times over in order to account for the 3 different passes. I think we all enjoy a good framerate, so this method will not work.
What will work? It seems that dynamic lighting shaders calculations every frame strays the framerate away, and excludes any shadows whatsoever. Fortunately, there is a way. It is a static lighting method, and a “brute-force” method because it is not automatically rendered by the computer, but not only is it optimal for performance, it includes shadows and lighting shapes! If you take a look at the featured image in this article, you may notice that at the top left corner of the image, you see two scenes. One is a model with the base textures and what not, and the view under it shows a greyscale scene with light textures. This method simply takes a duplicate model of the original, and replaces the base texture with a lighting texture, and completely revises that UV mapping. The two models are then drawn in the exact same spot, but for two different views. Those views are then combined into when, by applying the base view first, and the applying the lighting view over it with a blend-mode (Just another shader premade by GMS). And there you have it! 60fps or more, including shadows. Pre-drawn to give the GPU an easy time, and to give your eyes a great time.