Scene in complete darkness in Unity

Viewed 11413

I want to create a scene in complete Darkeness, which will be iluminated just by the lightnings of a storm. But I am already failing in the first step, I am not able to make the scene completely in darkness, even if I remove all lights in the scene and set background of the camera as black, I still get this:

enter image description here

And Hier my Hierarchy where you can see there are no lights:

enter image description here

What am I missing?

4 Answers

You can try to set the ambient light to black, so it will be all in darkness. You can do this programatically with this line:

RenderSettings.ambientLight = Color.black;

And also, to switch off any light you may have in your scene (just in case)

Light[] ligths = FindObjectsOfType(typeof(Light)) as Light[];
    foreach (Light ligth in ligths) {
        ligth.enabled = false;
}

Take care also of the follwing three things, which may be adding some light into the scene.

  • Turn off or delete any light maps.
  • Ensure shaders are not using self-illuminating or particle shaders.
  • Ensure that "use scene lighting" is turned on in the scene view.

However I think in your case with the ambient light set to Black will be enough. Your scene seems quite simple.

To light your scene entirely from lights placed, you need to drop your Ambient Light settings. Ambient light is the light that is added to every object so that things do not appear entirely black - but there are many cases where you want them to.


Answer

Ambient Light settings can be found by going Window > Lighting > Settings. Make sure that theEnvironment Lightingsource is set toColor`. Here you can also tweak the color using the RGB picker to have greater control over how the ambient light looks.

enter image description here

You may want to use a color that is slightly above black so that things can still be very faintly seen, without your lighting effects.


One thing to note, some materials may be set up to emit or use their own light settings - but these can usually be tweaked by modifying the material.


Another note, you can preview the lighting in the editor (or conversely - see what you are doing) with the lighting switch in the editor. This will toggle lighting effects on or off (including ambient light settings) for the Scene view.

enter image description here

In most cases the answers already given are correct. But also attention to the Light Probes! ;) Try disabling it on the object's Mesh Renderer.

Making things pitch black at night without artificial light involved several steps for me. I wanted a Sun that rose and set, so first I made a script to simply change my Directional Light's (gameobject Sun) x rotation over time.

Then I made a script to adjust my Sun's intensity, with the intensity starting at 0 when the sun rose and quickly rising to 1 at about 15 degrees, and contrariwise at about 165 degrees it goes from 1 back down to 0. So far so good....

Sun.intensity = intensity;

Next I made the script set the ambient light and reflection intensity to the same.

RenderSettings.ambientIntensity = intensity; // RenderSettings controls found in Lighting tab RenderSettings.reflectionIntensity = intensity;

And just for good measure I made sure to set these: RenderSettings.ambientEquatorColor = Color.white; RenderSettings.ambientGroundColor = Color.white; RenderSettings.ambientSkyColor = Color.white;

I noticed that when they were black, for example, even with intensities at 1.0 the ambient light was very, very low.

Finally, I had to use a custom shader to blend between a daytime skybox and a nighttime skybox. This because if you have the Skybox as the source for environment lighting (in your Lighting tab) then the ambient light will be affected by the color of your skybox. I.e., you want a bright daytime skybox and a dark nighttime skybox.

There you go. Now when the sun had set the terrain was completely black, only lit by scene lights like torches. I'm also using Ceto's water system, so I had to control the Ocean_TransparentQueue gameobject's UnderWater script to adjust the Absorption/Inscatter intensities as well, the same as above.

Related