Lighting effects in Unity

I’m Guy Dimor, lead coder for team Wendigo, and today I’ll write about my journey into the wonderful world of lighting, Unity, and the combination thereof.

After the alpha playtests, my group decided that our immediate priorities are the implementation of the ‘fog mechanic’, concealing the true nature of game objects, and lighting effects, to add to the atmosphere of the game and greatly enhance the player’s experience.

Once I was done with the aforementioned fog mechanic, which involved using sprite masks and was all around a blast to create (I mean that unironically, it was really fun), I knew it was time to start working on the lights. However, one thing stood in my way, and that was the fact that I had no idea how lighting in Unity works. Fortunately for me, it was wednesday, which meant there were code tutors who could help me.

They explained, to the best of their abilities, the different types of lighting available as well as the need to create a material that reacts to light and apply it to every relevant sprite. For those wondering about the specifics, you need to create a material with the ‘sprites/diffuse’ shader and set the color to white. I then started experimenting with different lighting shapes, trying to find out as much as I could about how lighting works. For example, while masks don’t allow gradients (areas only partially affected), lighting does, meaning I get artsy with the cookie (the sprite dictating the shape). I started making images for that purpose (technically giving me a spot in art credits of the game) until I created one that was just right, as seen here.searchlight placeholder2
This image created a light as seen in the featured image. I then made the light a child of the rotating spotlight object in order to bind them together and added another small point light as a child of the player in order to have the small “aura” around the player. I made both lights pale yellow in color and I was done. I then encountered some strange bugs, which even the tutors couldn’t figure out, that caused some objects to be unaffected by light sources. The brute solution was to creat new objects from scratch with all the same components.

Another thing I did was make the darkness darker in order to conceal objects better. This can be done by going to Window > Lighting > Settings and changing the ambient color to something more to your liking.

And that’s about it. It took me a whole day, but I got it down eventually.

Leave a comment