Muiti scene & PBRMaterial

PBRMaterial is very strange in Multiple Scenes when I add a picese of program.

for(var i=0;i<10;i++){
var s = new BABYLON.Scene(engine);
var envir = new BABYLON.PBRMaterial(“envir_”+i, s);

I found metallic and roughness has failed and mesh surrounded by a white edge.

1 Like

Could you please explain what you would like to achieve with this piece of code?

We are developing a 3D slide application,similar to power point. We define a page corresponding to a scene, as the picture shows. So I create a slide with ten pages, these pages each contain an PBRMaterial.

For some reason, the environmentBrdfSampler texture of the material is wrong when you create additional scenes (I compared a snapshot with Spector of both cases).

After comparing a JSON.stringify() of environmentBrdfSampler in both cases, the only notable difference is that glass.environmentBRDFTexture._texture.onLoadedObservable._observers array has 11 elements in the wrong case and 1 in the other case, meaning as many elements than there are scenes.

If you do:


to retain only first element in the wrong case, you get the right display.

Now, why is that, only people knowing inner working of the engine will be able to answer.

Note: of course, you should not tamper with private properties, I have only done it to show my point.


Thank you, wait for official answer

Pinging @sebavan to check what can be wrong here (Please be patient as seb is off for the week)

Issue created to track the fix: Fix issue when multiple scene creates multiple env data · Issue #7031 · BabylonJS/Babylon.js · GitHub

Thank you

I will try to look into it tonight and in the worst case over the week end, sorry for the delay, my vacation connectivity is the worst I have had in a long time :wink:

PR is up, this will be in the next nightly: Fix multi scene BRDF texture by sebavan · Pull Request #7049 · BabylonJS/Babylon.js · GitHub


Lol the point of being on vacations is to be disconnected :smiley: