2D shadow system prototype
For my current solo project, I have been setting up systems that are going to be helpful for creating the game experience I want to achieve. One of those systems is a 2D shadow system. Unity’s 2D lighting system does not support sprites very well. Each sprite has a box around it. Instead of using the actual sprite image, it uses the box, leaving the shadow with a box-like appearance. This is different from 3D lighting systems where shadows look like actual shadows of the object rendered. My goal was to create more realistic 2D shadows while maintaining a retro feel.
My system uses a combination of C# and HLSL code to achieve the results shown in the pictures and videos. A big problem while working on the project was the amount of data the system had to go through to calculate the shadow. To solve the problem, I learned a new programming language: HLSL. HLSL is used in unity’s regular shader code and compute shader scripts. Utilizing the GPU instead of the CPU allowed for more data to be passed in and allow this prototype to display 2D shadows inside of unity.
Although the system currently is a prototype I plan on expanding it to encompass shadows overlapping with structures correctly and different types of lights such as global, single point emission and area emission.
Experimenting with z depth
Experimenting with multiple light sources and colours!