Search Unity

How to compute HDRP "final" light color taking account of light temperature?

Discussion in 'High Definition Render Pipeline' started by stephero, Jan 13, 2022.

  1. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    Hello,
    I have a fairly simple question: in HDRP, you can customize the light temperature when using the Light Appearance mode "Filter and Temperature".
    Screenshot_33.png

    The temperature modulates the final color of the light, making it look more red or blue basically.
    Is there a way to compute the final color of the light by taking account of both the basic color ("filter" property in that case) and the temperature?
    I checked the HDAdditionalLightData script API but can't find anything related to that.
    Thanks
     
  2. Bambelle

    Bambelle

    Joined:
    Mar 3, 2016
    Posts:
    2
    Hello, you can do it that way

    Code (CSharp):
    1.  
    2. var lightComponent = sunLight.GetComponent<Light>();
    3. var additionalLightData = sunLight.GetComponent<HDAdditionalLightData>();
    4. var lightColor = lightComponent.color.linear * lightComponent.intensity;
    5. if (additionalLightData.useColorTemperature)
    6.     lightColor *= Mathf.CorrelatedColorTemperatureToRGB(lightComponent.colorTemperature);
    7.  
     
    stephero likes this.
  3. stephero

    stephero

    Joined:
    Feb 8, 2016
    Posts:
    123
    thanks !