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:
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.
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.