How to correctly dispose a DefaultRenderingPipeline

Playground:

Env: Chrome x64 on Win10
Ver: 5.46.0 WebGL2

Expected:
Disposing and recreating the DefaultRenderingPipeline makes the same result as creating first DefaultRenderingPipeline.

image

Actual:
image

I believe this is because of color space differences.
See docs - Using the Default Rendering Pipeline | Babylon.js Documentation , clearColor fix

For your second PG you may use, for example,

    let cc = scene.clearColor
    scene.clearColor = cc.toGammaSpace()

Example - https://playground.babylonjs.com/#5CX9XL#2

Or convert your first PG color space to linear color as shown here - https://playground.babylonjs.com/#08A2BS#15

scene.clearColor = new BABYLON.Color3(0.5, 0.5, 0.75).toLinearSpace();

If skybox is used instead of clearcolor:

Expected:

Actual:

If you do something like this:
image
On the second one.

It renders correctly. Which makes me want to look at the setter for samples and see what is that process doing that fixes the result?

Update
image
So it looks like we need to look in _buildPipeline and see now if there is something that helps there.

UPDATE UPDATE
Drum rolll pllllllleeeaase.
The answer is:

pipeline.prepare()

Will fix all your woes on the second pipeline initialization. I’m not digging any farther then that to the causality because this will do the trick.

I also don’t know if destroying and recreating pipelines is the thing to do… but I guess go for it until something says no? Can you explain your use case so I can ensure this will really take care of you?

1 Like

There is indeed a problem with the ImageProcessing post-process not being released correctly in that case. Here’s the PR:

2 Likes

This problem will also occur if the image post-processing of the material is not the same as that of the scene.
thank you for your reply

Would you be able to setup a small repro of the problem in that case?

Thank you in advance!

Create a new scene, import a model, enable image post-processing and then export.
Create a new scene to import the exported model
At this time, the post-processing of the material image is not the same as that of the scene.
Compare the two post-processing

Would be great if you can set it up in the playground in order to help us help you :slight_smile: