Render x passes of effectwrapper in 1 frame

I’d like to render an effectWrapper multiple times to different textures in 1 frame. I understand that the effect params are set in the onApplyObservable, but this observer only triggers once per frame. How should I set the params as needed?

My current pseudo code is:

scene.registerBeforeRender(() => {
        // 1st pass
        eRenderer.render(1stPass, tex[1]);
        // multi pass
        let sampleValue = 4;
        let currRT = 0;
        for (let i = 0; i < numPasses; i++) {
            // this doesn't work for numPasses>2!
            multiPass.onApplyObservable.add(() => {
                multiPass.effect.setTexture("texSampler", tex[1-currRT]);
                multiPass.effect.setFloat2("screenSize", engine.getRenderWidth(true), engine.getRenderHeight(true));
                multiPass.effect.setFloat("value", sampleValue);
                blah blah...
            });
            // render result to the other texture
            eRenderer.render(multiPass, tex[currRT]);
            currRT = 1 - currRT;
            sampleValue >>= 1;
        }
});

You can try addOnce instead of add, as add is probably a bug, but I’m not sure it will fix it (depends on what “blah blah” is doing). If you can provide a repro, it will be easier to debug.

Note that EffectWrapper.onApplyObservable is notified each time EffectRenderer.render is called:

and applyEffectWrapper(effectWrapper) is where onApplyObservable is notified:

Its adding more effect params. Looking at the code, it feels very weird so I tot I’d better ask.

I see, so the codes are actually correct and working…hmm…

I hope to get a rough draft of a demo out tom, thanks! Time to hit the sack, cheers!

Something for you and the team: Babylon.js Playground

A variable width outliner using the jump flood algorithm (jfa), works with instances. I have not yet tested against thin instances. Nor made a proper class for it.

I ported it from 3. Refs here:
a) The Quest for Very Wide Outlines. An Exploration of GPU Silhouette… | by Ben Golus | Medium
b) Outline Post Process - #14 by manthrax - Jobs - three.js forum

The outliner doesn’t take occluding meshes into account yet. Do you have a quick fix ? or will your frame graph help?

Its a little expensive due to size of the rtts involved so maybe half scaling the tex and then upscaling the final result would help with mem. But I’m not sure if I want to continue development if your upcoming frame graph will make this obsolete.

Or maybe its worth a spot for the repo? Shrugs…