EnvironmentHelper issue with enableGroundMirror in 5.x

I believe this is a bug, although I have been unable to figure out why it is happening. The issue is visible with this simple PG:

The entire environment seems “darker” when ground mirror is first enabled. That darker effect goes away if EnvironmentHelper is disposed and then recreated. It is not darker on 4.x.

I have stepped through the code of EnvironmentHelper and I’m still unable to see why this is happening.

(Fwiw, I am running in to this due to trying to have multiple logical “scenes” in a WebXR setup. Per a couple previous forum posts, the seemingly most efficient approach is to have a single babylon.js scene, and use AssetContainers to manually remove/add assets when changing logical scenes. That has been tricky to accomplish and I would recommend trying to uncouple WebXRDefaultExperience from a single scene if possible. I believe that has/is being considered, although I suspect has a number of complications. As it is currently though, I almost have things working per the recommended approach (with some caveats) except for this minor ground mirroring issue. I would prefer if each logical scene could have its own environment setup using it’s own EnvironmentHelper, but that means disposing/recreating upon logical scene changes.)

I am on it and will fix it by tonight.

This will be in the next nightly

1 Like

Confirming that with nightly, the ground mirror no longer changes when recreated. Thanks.

Though not overly important, I’m still trying to fully understand. Looking at the commit, it appears to me that the change was to stop using linear color space for the ground mirror. The sky and ground textures still do use linear color space though (by default).

I am now wondering if the underlying issue was/is actually in MirrorTexture. Specifically, something about the sequencing of events for how/when it determines gamma vs linear color space based on scene image processing. Before this commit, the first time it was created it seemingly correctly used gamma space, but in subsequent creations it seemingly used linear. That’s just a guess though. I’ve been playing with it locally, but I don’t understand everything around scene image processing.

Fwiw, I noticed that if the IEnvironmentHelperOptions.setupImageProcessing is false, then there not an issue even before this commit.

It was actually a bug before as the rendering was in gamma in the mirror but flagged as linear. The other colors are shader inputs expected to be in linear space so it should be all good now :slight_smile: