Search Issue Tracker

Postponed means that the issue was either a feature request or something that requires major refactoring on our side. Since that makes the issue not actionable in the close future we choose to close it as Postponed and add it on our internal roadmaps and technical debt pages instead.

Postponed

Votes

3

Found in

2019.4

2019.4.31f1

2020.3

2021.2

2022.1

Issue ID

1374978

Regression

No

DynamicGI.UpdateEnvironment fails to update default skybox reflection in Editor in play mode

Shadows/Lights

-

How to reproduce:
1. Open the user's attached project
2. Open scene Test
3. Go to Window -> Rendering -> Lighting Settings
4. Under the Environment section, assign the Skybox Material to Default-Skybox
5. Observe the Game view
6. Assign the Skybox Material to None
7. Press the Play button
8. Assign the Skybox Material to Default-Skybox again and observe the Game view
9. Go to Tools -> Testing -> Update Dynamic GI Environment and observe the Game view

Expected result: the GameObjects reflect the environment lighting, identically to when Default-Skybox was applied before Play mode
Actual result: the GameObject on the left does not reflect the environment lighting while the Sphere appears different than before

Reproducible with: 2019.4.33f1, 2020.3.23f1, 2021.2.3f1, 2022.1.0a16

  1. Resolution Note (2022.1.X):

    This issue is caused by the default skybox reflection cubemap not being updated after the skybox material is changed. There is currently no functionality to request a rebake of said texture at runtime directly, which of course isn't ideal. We will treat the issue as a feature request and prioritize it accordingly.

    One way to work around this is to not rely on the default reflection cubemap, and instead use reflection probes to provide reflections to all renderers. Another workaround, is to bake a skybox cubemap yourself and assign as the currently active one via RenderSettings.customReflectionTexture (make sure Environment Reflections Source is set to Custom). One way to bake such a cubemap in practice is to use a realtime reflection probe with culling mask 'Nothing' and Refresh Mode 'Via Scripting'. Calling ReflectionProbe.RenderProbe() will rebake the cubemap for this probe, and that cubemap can then be assigned to the field in RenderSettings.

    See the example MonoBehaviour below for more details. One may call the UpdateEnvironment coroutine to rebake all environment lighting, for example after having changed the skybox material.

    public class UpdateSky : MonoBehaviour {
    ReflectionProbe baker;

    void Start() {
    baker = gameObject.AddComponent<ReflectionProbe>();
    baker.cullingMask = 0;
    baker.refreshMode = ReflectionProbeRefreshMode.ViaScripting;
    baker.mode = ReflectionProbeMode.Realtime;
    baker.timeSlicingMode = ReflectionProbeTimeSlicingMode.NoTimeSlicing;

    RenderSettings.defaultReflectionMode = DefaultReflectionMode.Custom;
    StartCoroutine(UpdateEnvironment());
    }

    IEnumerator UpdateEnvironment() {
    DynamicGI.UpdateEnvironment();
    baker.RenderProbe();
    yield return new WaitForEndOfFrame();
    RenderSettings.customReflectionTexture = baker.texture;
    }
    }

Comments (1)

  1. shelshok

    Oct 11, 2023 19:16

    Right but the skybox is also responsible for realtime ambient lighting, which you can't get from a reflection probe, right?

    There doesn't seem to be any way to update the skybox image for lighting purposes.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.