Hello, programmer person here.
I figured, I’d give you a little rundown on the new lighting system I’ve lazily dubbed lightv3 (exactly like that. lightv3). Because It came a long way.
As you can see up there, initially it … was weird to say the least.
It would also cause the project the same shadow shapes on all sprites in the scene.
The general idea was:
Well, if I know the position where the light came from, I can test for each light pixel, if there is something between that pixel and the light source. An obstacle, so to say.
It’s an easy enough idea for sure.
Turns out it wasn’t that easy to implement regardless. Not for me anyway. I’m not exactly the expert in terms of shader programming.
But I got to a solution at some point that would resemble something like a light casting shadows. Only… it had this nightmarish look to it. You know. monsters chomping away at the light with bloody fangs straight from a horror movie.
Additionally to that there were these artifacts on the light, opposite of the thing that actually casted shadows. Turned out I sort of over-sampled and the shader thought there would be shadow there, removing pixels from that bit.
Quite the unnerving thing, that was. As you can see, even if I had left the shadows as that awkward … whatever it was, it’s all not very natural looking.
The edges had to be blurred somewhat.
I did that by gradually removing alpha from the light pixels depending on their distance to the light obstacle (walls and stuff).
Last but not least I changed how the light pixels are blended on the screen buffer (in a soft additive fashion) and voilá.
That’s lightv3 now.
I also added options to lights to not cast shadows and another one for just shining on anything regardless ob light obstacles.
And that concludes this.
If you’re interested in the gory details of how the shader actually works, let me know in the comments or some such!
0 comments