Setting Skybox Exposure through script

Hi all,

Anyone know how to do this? I am dimming my scene the usual manner, by dimming the lights in it, but the procedural skybox is staying bright and vibrant as ever. I need to dim it (doing so via a lerp in a coroutine) but I can’t figure out how to change the Exposure parameter. I’ve tried SetFloat(“exposure”,…) and SetFloat(“Exposure”,…) but neither work.

Can anyone point me in the right direction?

Here’s an example - fading in the Skybox

for (int i = 0; i < 10; i++)
        {
            yield return new WaitForSeconds(interval);
            exposure += 0.3f;
            RenderSettings.skybox.SetFloat("_Exposure", exposure);

        }

Found the problem. It was the keyword I was using - instead of “exposure” or “Exposure”, I needed to use “_Exposure” as the keyword name. D’oh!

I did it with a coroutine:

float exposureStart = 0.6f;
float exposureEnd = 0.2f;
float currentExposure { get; private set; }
float fadeTiming = 0.5f;

private void fadeDown(){
  StartCoroutine(Fade(exposureStart,exposureEnd));
}

IEnumerator Fade(float startAlpha, float endAlpha)
{
    float elapsedTime = 0.0f;
    while (elapsedTime < fadeTiming)
    {
        elapsedTime += Time.deltaTime;
        currentAlpha = Mathf.Lerp(startAlpha, endAlpha, Mathf.Clamp01(elapsedTime / fadeTiming));
        RenderSettings.skybox.SetFloat("_Exposure", currentExposure);
        yield return new WaitForEndOfFrame();
    }
}