Issues in the documentation for PostEffects


I was learning about how post processing is organized in bjs and was following the docs.

Here we find the following line:

The camera parameter specifies which camera to attach to. If you’re creating a post process that will be managed by a render pipeline, this should be set to null. See Post Process Pipeline

Though when we follow the link, the first example we see is this one:

var blackAndWhite = new BABYLON.BlackAndWhitePostProcess("bw", 1.0, null, null, engine, false);
var horizontalBlur = new BABYLON.BlurPostProcess("hb", new BABYLON.Vector2(1.0, 0), 20, 1.0, null, null, engine, false);

This constructor for the BlackAndWhitePostProcess doesn’t work as camera is a required parameter.

This makes it impossible to follow the tutorial.

Would be good to update the docs. Thank you.

1 Like

Thank you so much for reporting this. Want to submit a pull request to fix this?

I’d love to if I knew how this is supposed to be done correctly.
Should the BlackAndWhitePostProcess class allow null as camera?
I think it should as I checked the internals and it just passes the camera to the base class.

The example shows you how the camera is attached to the rendering pipeline - Basic pipeline | Babylon.js Playground ( Is there anything wrong with the example?

Oh. In fact it is.
I didn’t open this PG so when I tried it all with TypeScript in my project, null was not allowed.
I can update the types a little bit. I’ll check other PostEffects for the same problem.

1 Like

Oh, that might be a typing issue then. if null is not allowed but under the hood acceptable we might need to have a nullable camera instead of camera in the code itself.

Small Pull Request

I made camera optional in all classes derived from PostProcess except for anaglyph and multiview. I believe it is fair to leave the camera obligatory for them as otherwise it might get very ambigous.

In some places I slightly adjusted the code but judging by internals of PostProcess.ts the behavior should stay exactly the same. Everywhere where I did that the code was not updated 4 years since the introduction of postprocess library so I believe that is safe.