I’m still doing engine work and this time I spent quite a bit of time on lighting again (Don’t worry, I’m not only doing engine work. I’ve just postponed engine work and now I’m getting it all off my to-do list.)
I wanted 2Volutions lighting to be as flexible as possible so that it would allow me to make the games lighting feel more than just a simple gradient between dark and light, or whatever other gradients you may use.
The current state of it
Going to get a bit more technical here, so the basic idea was that I’d like to have a combination of image based lighting and 2D dynamic shadows. Plus the shadows should not be sharp, instead they should be smooth and reveal quite a bit of the terrain.
So the first step was to generate an obstacle surface from the terrain, I wrote a simple shader for this that is kind of the opposite to an outline. There are 2 extra steps to make this surface as nice as possible though, first is to make it look a bit more random and the second is to smooth it out properly for smooth shadows.
Obstacle surface steps:
The second step is to fill another surface with light images. This is fairly simple and straight forward, I draw the lights on the surface with additive blending and it’s finished for the next step.
The third and the final step is the most complex one. This is where all the shadow magic happens. All the data is passed into the shadow shader where ray marching and a few other neat tricks are used to create the shadows.
Shadows, with and without the blur that was applied in the first step
One of the really good things about this is that if I don’t want smooth lighting it’s extremely easy to make it non-smooth! I can simply use different light sprites like this.
There still is a small bug (probably visible on one of the gifs), but it’ll be fixed in no time.
8 comments