Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Weird grey colouring in timecycle

Discussion in 'Global Illumination' started by DraconicFire98, Jun 28, 2015.

  1. DraconicFire98

    DraconicFire98

    Joined:
    Jun 28, 2015
    Posts:
    3
    Hello, first time posting anything here, ive had unity for a while though.. never really got into it until recently

    but my issue is, i am trying to do a time cycle with directional lights, but when it gets dark everything has a weird grey tone to it, and certain objects dont go dark. like in the picture, heres my code
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DayNight : MonoBehaviour {
    5.    
    6.     public Light sun;
    7.     public float secondsInFullDay = 120f;
    8.     [Range(0,1)]
    9.     public float currentTimeOfDay = 0;
    10.     [HideInInspector]
    11.     public float timeMultiplier = 1f;
    12.    
    13.     float sunInitialIntensity;
    14.    
    15.     void Start() {
    16.         sunInitialIntensity = sun.intensity;
    17.     }
    18.    
    19.     void Update() {
    20.         UpdateSun();
    21.        
    22.         currentTimeOfDay += (Time.deltaTime / secondsInFullDay) * timeMultiplier;
    23.        
    24.         if (currentTimeOfDay >= 1) {
    25.             currentTimeOfDay = 0;
    26.         }
    27.     }
    28.    
    29.     void UpdateSun() {
    30.         sun.transform.localRotation = Quaternion.Euler((currentTimeOfDay * 360f) - 90, 170, 0);
    31.        
    32.         float intensityMultiplier = 1;
    33.         if (currentTimeOfDay <= 0.23f || currentTimeOfDay >= 0.75f) {
    34.             intensityMultiplier = 0;
    35.         }
    36.         else if (currentTimeOfDay <= 0.25f) {
    37.             intensityMultiplier = Mathf.Clamp01((currentTimeOfDay - 0.23f) * (1 / 0.02f));
    38.         }
    39.         else if (currentTimeOfDay >= 0.73f) {
    40.             intensityMultiplier = Mathf.Clamp01(1 - ((currentTimeOfDay - 0.73f) * (1 / 0.02f)));
    41.         }
    42.        
    43.         sun.intensity = sunInitialIntensity * intensityMultiplier;
    44.     }
    45. }
    not really sure what to do about it :/ im using unity 5.1.1f1 Personal if that helps...
    building.PNG
     
  2. DraconicFire98

    DraconicFire98

    Joined:
    Jun 28, 2015
    Posts:
    3
    completely forgot about this post... but im still getting the issue. i took a break for a bit which is why i forgot
     
  3. DraconicFire98

    DraconicFire98

    Joined:
    Jun 28, 2015
    Posts:
    3
    keep forgetting i posted here, been a while since ive had unity open.. ill keep this here in case i still get the error or whatever this is