Hi there! I’m working on my first big project and I know next to nothing about Unity’s lighting system.
I’ve been having an issue with the lighting in my scene. I set up a simple day/ night cycle with a directional light as a sun, that rotates base don the time of day, and at night lowers it’s intensity to 0.
The day / night cycle works as expected for now but at night, the lighting looks awful. It’s just this bland flat grey on every object. Here’s a picture:
I want it to be dark at night, but only the sky really looks dark (in the upper left corner) everything else just looks grey, not dark.
Not sure what the steps are to resolve this though. It seems like Unity’s lighting systems are pretty complex and I’m just not sure where to start. I added a reflection probe to my scene based on a link I found, but it still doesn’t look great.
Should I be looking into lighting that isn’t a directional light? Are there effects I need to add to my scene to make this better?
Any tips or resources on taking the steps to fix this would be greatly appreciated, thanks in advance!
Yeah, those are my current settings, are you saying I should change them around? The intensity setting doesn’t really seem to do much for the night time.
Yep.
Setting intensity to 0, should resolve the issue. Unless you have some other light in the scene, as I see soft light on the wall and surface.
You can change skybox to color as well, if you prefer.
Ok so I’m not getting any differences when I set the Intensity Multiplier to 0. I tried experimenting a bit and when I set my scene’s directional light (sun) to -90 rotation on the X axis so that the whole scene is dark, then I do get pitch black nights, which is fine because I plan on using point light sources for lamps and such, after the lighting auto generates, but then when I hit play and it becomes daytime the day is pretty dark too.
Not sure if this is normal behavior or not. I feel like there should be a way to get really dark nights, and brighter days, but maybe I’m not using the right tools?
Environment Lighting is casting light to whole scene, irrespective if you have any light on scene or not.
If you remove your direct light (sun), then of course scene should be dark.
Normally in static scene, where light is constant, you should not need adjust at runtime the Environment Lighting intensity.
But if you want Day / Light cycle.
You will need adjust both sun intensity, and Environment Lighting.
Sun light, as directional light, is what allow cast shadows from the sun.
Environment Lighting is the minimum light, allowed, at given time of day.
So at night should be around 0, and during a day, around 1. Typically.
So your following steps should be
Disable any lights.
Change Environment Lighting and get intensity value of the night.
Get intensity value during the day.
Enable sun light of GameObject.
Now couple Environment Lighting intensity with direct light (sun) intensity via script.
Alternatively you can animate skybox. But it will require more play with it.
Thanks for the tips, so I edited up the script where I was changing the intensity of the sun (just going from 0 to 1 based on the time of day and rotating the light).
Now when I change the intensity of the sun I’m also using RenderSettings.ambientIntensity (I think that’s the right thing to use here) and setting it from 0 to 1 based on the sun.
Unfortunately, this is basically doing nothing. The scene lighting seems to still be completely decided on the initial X rotation of my sun. I have Auto Generate on in the Lighting settings and when I put my sun’s X rotation to -90 everything goes black, great for night, and when I put it on 90, everything looks bright, like daytime. That’s great and all, but then if I play the scene depending on where the sun’s X rotation was set during scene view(-90, 90, or 0) either the day is too dark or the night is too bright.
The weirdest part is that disabling the sun game object seems to very little effect on the scene. That is, changing the sun’s X rotation still affects the scene when the game object is disabled.
With some extra tweaking it looks like if I start the sun game object with a -90 rotation (so that the scene is pitch black) and then increase the Environmental Lighting intensity enough during gameplay in the script I can get the days and nights to look how I want them to (i.e. dark nights, and bright days). The issue though is that I can’t work in the scene because it’s pitch black, so I have to constantly change the sun’s X rotation, which seems odd.
Try set in the edit scene Environment Lighting to 1. And in the script of GameObject, on Start, set Environment Lighting to your desired value. This way you will see all in the scene during editing, as well as dark at runtime.
Yeah when I turn off scene lighting I can see pretty well. Changing the environment lighting intensity during edit mode doesn’t do anything when the sun is at -90, it’s still pitch black.
Still feels like a weird workaround though, I also noticed that when I turn off auto-generate in the lighting settings, then play mode looks off again. In the case where the sun is at a -90 on X the days look very dark.
Not sure if I’m missing something when it comes to the day / night cycles or if it’s just very finicky in Unity.
You are most likely doing something wrong. Make sure, you don’t have accidentally more than one source of light at this step, until you resolve the issue.
You can of course add more lights later.
Nerco post, but for anyone wondering. Remove the skybox as your environment lighting source. Change it to color. Up it to like HDR +2 for day and -2 for night.
Those are caused by specular which doesn’t work with light sources. Basically the Spec/Metallic/Smoothness part of the shader doesn’t work with light sources. They reflect light even when there is none as it defaults to skybox unless there is a reflection probe.
Add an indirect light controller and reduce the indirect light intenisity to 0. Or add a reflection probe that matches the environment at night (or with intensity 0) and it should be sort of fixed.