How to update custom PostProcess effect dynamically

I have a working PostProcess in my scene. But how can I modify the shader’s ‘threshold’ here dynamically?

var postProcess = new BABYLON.PostProcess("CustomPostProcess", "./shaders/CustomPostProcess", ["resolution", "threshold"], null, 0.25, camera);

postProcess.onApply = function (effect) {
    effect.setFloat2("resolution", c.width, c.height);
    effect.setFloat("threshold", myThreshold);
};

I have tried updating myThreshold and running onApply() again. I also tried postProcess.updateEffect(); but nothing changes. I also tried to run postProcess.dispose() and creating a new BABYLON.PostProcess

Welcome aboard!

Simply changing the value of myThreshold should work. Maybe a repro in the Playground will help understand your problem better.

1 Like