- Home /
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?
Answer by nockieboy · Mar 23, 2015 at 03:30 PM
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!
Do you $$anonymous$$d showing the syntax/line of code that changed the exposure?
Thanks C
Answer by grahamwell · Nov 28, 2015 at 09:28 AM
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);
}
Answer by mheavers · Aug 21, 2018 at 07:00 PM
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();
}
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613191020im_/https://answers.unity.com/themes/thub/images/avi.jpg)