GlowEffect asynchronous shader loading

Hi,
there’s a _createMergeEffect method of GlowLayer:

which has a this._engine.createEffect call.

Should this call also have an extraInitializationsAsync parameter defined like:

return this._engine.createEffect(
    "glowMapMerge",
    [VertexBuffer.PositionKind],
    ["offset"],
    ["textureSampler", "textureSampler2"],
    defines,
    undefined,
    undefined,
    undefined,
    undefined,
    this.shaderLanguage,

    // extraInitializationsAsync
    this._shadersLoaded
        ? undefined
        : async () => {
            await this._importShadersAsync();
            this._shadersLoaded = true;
        },
);

the same way it’s done here? Babylon.js/packages/dev/core/src/Layers/effectLayer.ts at master · BabylonJS/Babylon.js · GitHub

I ran into an issue when this._createMergeEffect() is called before the shaders for the glow layer have been loaded/imported. Engine then tries to load shaders from http://localhost:1234/src/Shaders/glowMapMerge.vertex.fx and fails with a 404.

Can’t reproduce this in the Playground, because all shader code seems to be bundled in a single file there.

Kind regards.

Most certainly. This is an error on our end and should be fixed. Pinging @sebavan - let me know if you start, otherwise I will deal with that in an hour or two.

import shaders in createMergeEffect as well by RaananW · Pull Request #15506 · BabylonJS/Babylon.js (github.com)

2 Likes

Thank you!

1 Like