Search Unity

My scene it too dark

Discussion in 'High Definition Render Pipeline' started by Tempest74, Apr 4, 2020.

  1. Tempest74

    Tempest74

    Joined:
    May 17, 2017
    Posts:
    133
    So I try to make a day/night cycle. I watch a tutorial but the project of that guy is a little different (maybe the fact that I have postprocessing and hdrp instaled). My scene is very dark when his scene is sort of blue. Can someone help me figure it out why? This is his scene:
    upload_2020-4-4_20-29-7.png
    And this is mine at the same exact moment:
    upload_2020-4-4_20-29-36.png
    We have the same presets. This is the script for the day/night cycle
    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. [ExecuteAlways]
    6. public class DayAndNight : MonoBehaviour
    7. {
    8.     [SerializeField] private Light directionalLight;
    9.     [SerializeField] private LightningPreset preset;
    10.     [SerializeField, Range(0,24)] private float timeOfTheDay;
    11.  
    12.     private void Update()
    13.     {
    14.         if (preset == null)
    15.         {
    16.             return;
    17.         }
    18.         if (Application.isPlaying)
    19.         {
    20.             timeOfTheDay += Time.deltaTime;
    21.             timeOfTheDay %= 24;
    22.             UpdateLighting(timeOfTheDay / 24f);
    23.         } else
    24.         {
    25.             UpdateLighting(timeOfTheDay / 24f);
    26.         }
    27.     }
    28.  
    29.     private void UpdateLighting(float timePercent)
    30.     {
    31.         RenderSettings.ambientLight = preset.ambientColor.Evaluate(timePercent);
    32.         RenderSettings.fogColor = preset.fogColor.Evaluate(timePercent);
    33.  
    34.         if(directionalLight)
    35.         {
    36.             directionalLight.color = preset.directionalColor.Evaluate(timePercent);
    37.             directionalLight.transform.rotation = Quaternion.Euler(new Vector3((timePercent * 360) - 90, 170f, 0));
    38.         }
    39.     }
    40.  
    41.     private void OnValidate()
    42.     {
    43.         if (directionalLight != null)
    44.             return;
    45.  
    46.         if (RenderSettings.sun != null)
    47.         {
    48.             directionalLight = RenderSettings.sun;
    49.         } else
    50.         {
    51.             Light[] lights = GameObject.FindObjectsOfType<Light>();
    52.             foreach(Light light in lights)
    53.             {
    54.                 if(light.type == LightType.Directional)
    55.                 {
    56.                     directionalLight = light;
    57.                     return;
    58.                 }
    59.             }
    60.         }
    61.     }
    62. }
    63.  
     
  2. unit_dev123

    unit_dev123

    Joined:
    Feb 10, 2020
    Posts:
    990
    u have full link to tutorial?
     
  3. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,320
    Perhaps the tone mapping in HDRP is making it all black? Try changing the exposure...
     
  4. warthos3399

    warthos3399

    Joined:
    May 11, 2019
    Posts:
    1,179
    Tone Mapping is usually the root cause, as all effects in post processing are turned on by default, check your PPE settings, one by one shut them off and on, to see if any of them are the cause.

    If it is tone mapping, just turn down the Alpha (controls the shadow darkness), or dont use it at all.
     
    Last edited: Apr 23, 2020
unityunity