Async loaded scene is transparent for some reason

I am loading a scene asynchronously as shown in this example: PlayCanvas | HTML5 Game Engine

I copypasted the script, put it on an empty object in the main scene and load a scene that contains nothing but models extracted from the main scene.

To ensure the problem does not lie with my models, I also added a cube in the root of both the main and the asynchronous scene.

When loaded it looks like this:

Do note that the second cube in the center is transparent, as are the trees and hedge in the background loaded from the second scene.

My scene (Regenwasser): PlayCanvas | HTML5 Game Engine

EDIT: Once again, my issues seem to stem from the refraction.js script on my camera, but I cannot tell why loading from another scene would cause rendering issues to appear.

How do you reproduce the issue? Eg. Which scene should be loaded first, which buttons to press, etc

If you start in the Regenwasser scene, the Decorations scene should be loaded asynchronously as soon as the scene is launched. You don’t need to press any buttons.

Looks like the swiss flag is rendered as part of the refraction post effect as we can see in Spector.js here:

The reason why it’s transparent is because the material on the Rain Surface in front of camera has an opacity of 0.7. Changing the opacity of the material changes the opacity of the meshes in the decoration scene

Why this is all connected, I don’t know and unfortunately don’t have time to investigate further but hopefully this should help you get going in the right direction

As a side note, you may want to try using dynamic refraction on the Standard Material instead of a full screen shader now

Ah, I think I see the issue.

The Refraction script postUpdate only does specific logic once

Refraction.prototype.postUpdate = function(dt) {
    if (this.firstRender) {
        this.firstRender = false;
        

So what is happening is that the main scene is loaded, the Refraction does it’s only postUpdate and then the second scene is loaded which is causing the issue.

If the Refraction script is disabled on start and enabled after the second scene is loaded, you don’t get this issue.

2 Likes

Thank you for investigating this issue, you have been immensely helpful!