Search Unity

DynamicGI.SetEmissive to bright

Discussion in 'Scripting' started by Pavlon, May 30, 2018.

  1. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    So i use this script to set some emissions.

    Code (CSharp):
    1.             DynamicGI.SetEmissive(renderer[i],colors[i] * Mathf.Lerp(targetStartEmissions[i],targetEmissions[i],currentPowerUpTime / fadeTime));
    2.  
    The lerp values range from 1.5 to 0.1 the colors are all white (1,1,1,1)...

    The problem is every thing gets super bright setting the value to 1.5 in the script is like setting it to 4.0 in the editor any one know what could cause this ?
     
  2. Pavlon

    Pavlon

    Joined:
    Apr 15, 2015
    Posts:
    191
    Unity was removing the texture this code works but it looks like I need to skip/wait like 3 frames so he can update the illumination.

    Code (CSharp):
    1.     private int frameCount = 0;
    2.     private int framesToSkip = 15;
    3.  
    4.     private void PowerUp()
    5.     {
    6.         currentPowerUpTime += Time.deltaTime;
    7.         frameCount ++;
    8.  
    9.         if(frameCount != framesToSkip)
    10.             return;
    11.  
    12.         frameCount = 0;
    13.  
    14.         for(int i = 0; i < renderer.Length; i ++)
    15.         {
    16.             renderer[i].material.SetColor("_EmissionColor",colors[i] * Mathf.Lerp(targetStartEmissions[i],targetEmissions[i],currentPowerUpTime / fadeTime));
    17.             renderer[i].UpdateGIMaterials();
    18.         }
    This cant be the way to go.