Search

Unity Lighting

Updated: Aug 22, 2019

Another aspect of my previous 3D games that I was always more than happy to push onto someone else, lighting and I have always shared a strange relationship. I've written in the past about how logical and mathematically-minded I am; it's why it's easy for me to model perfectly symmetrical objects, or to code at all, because those things have a clear and perfect "done" point. But you can always continue to tweak lighting, and someone more artistic than me would be more qualified to do that. My solution would be to just not use lighting at all, keeping whatever Unity's default is nine times out of ten. Hell, when I did my animation final a million years ago, one of the big criticisms was the "flat lighting". It wasn't something I had even given a second thought to.


But anyway, this would be the tenth time, where I felt that some variation could help. The different planets may be pretty stereotypical in their themes, but it was important that they felt different from each other. However. At first, I still cheated. When I was designing materials for Purple Planet, I was confused because even with Unity's default light settings, they looked vastly different in-game than they did in the Photoshop files. That was what started me down the rabbit hole of shader research, and led me to using unlit shaders for nearly everything. I was once again ignoring lighting because I wanted everything to look how I wanted it to look, and lighting was screwing that up. Every material across my first two planets used unlit shaders, with the exception of the transparent force fields and the metallic UFO windscreens and cow helmets.


Then came Vulcanix, and since I had a really specific vision for that as well, I decided to try lighting again. But I needed dark for the general atmosphere, and bright light for the lava, and my special moving worldspace tiling shader wasn't set up to support lighting either...I tried some things using the facts I'm going to lay out in the next paragraph, but in the end, it just wasn't working for me. I solved the problem by once more using the simplest solution: turn off all the lighting, and if I wanted something lighter or darker than it currently was, modify the material for that specific thing to make it so.


Now, Glimmer Ridge definitely needed something else, in order to get a nice contrast between the forest and cavern parts. There are...I'd say four and a half different types of lighting you can leverage in Unity. Point lights (which illuminate the spherical area around them), directional lights (which simulate light coming from the specified direction via an infinitely-far-away source), spotlights (which are like directional lights but have a source at a user-defined position in space), ambient lights (which affect everything and are the best for setting atmosphere), and skybox lights (which are the extra half, because they're technically also ambient lights but can also be used to modify reflections and other things). I encourage you to do more research if you're actually trying to build a lighting scheme for yourself.


Ambient light was what I wanted here, so I could give everything above ground a golden tinge, and make everything below dark and murky. ...Yeah, except for you only get one ambient light setting per scene, and it completely ignores walls and floors, so I could only do either/or, not both. Even worse, the golden light specifically was really messing up everything that wasn't a tree in my scene: those transparent and metallic objects from before started to look really ugly, and even the grey caves were turning dark brown. Not to mention how the cave walls changed color, but the cave floor (still using my unlit worldspace shader), stayed the same. This was a particular problem, because they used the same material (but a different shader...go back and reread by early posts if you're confused) and needed to be the same. I also learned here that you can't make a space darker by adding lights to it. ...Yeah, okay, but I thought if I turned the light's color to black, it might do something for me. It did not affect the scene at all once it got below a certain brightness value.


Good ambience, but look at the ugly color of the cave and force fields in the background

This was the all-too familiar point where nothing was working, nothing looked right, and I was very frustrated. So I once again fell back to what I knew. Using screenshots I had taken of the golden ambient light, I turned it back to normal and then modified the ground and tree textures individually until they matched the pictures. The forest looked golden now, while leaving the metallic textures exactly the way they were. I did the same thing to everything below ground, and I did it uniformly, so the walls and ground still matched each other. I think this may be better anyway, because it's a much darker environment, but you can still clearly see yourself flying around, and the glow of the force fields as landmarks.


The post is called "Unity Lighting" but I just spent the entire thing talking about how I did everything I could to avoid using it, then eventually gave it up as not working for me at all. And yet, I still wouldn't describe my four different planets as using "flat lighting", and more importantly, I'm happy with how they all currently look. I guess the moral of this story is the same as it always is: there's always a way to make it work, even if it takes a few attempts.