# How do I dispose a rendering pipeline?

**URL:** <https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203>\
**Category:** Questions\
**Tags:** pipeline\
**Created:** [June 27, 2025, 4:00pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203 "2025-06-27T16:00:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 27, 2025, 4:00pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/1 "2025-06-27T16:00:53Z")

</div>

```auto
      manager.detachCamerasFromAllPipelines();
      scene.postProcessRenderPipelineManager.pipelines.forEach(p => p.dispose());

```

This code is not working. Any idea why?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 27, 2025, 4:29pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/2 "2025-06-27T16:29:56Z")

</div>

probably because the code iterates over a list you are changing with each calls to dispose ?

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 27, 2025, 4:37pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/3 "2025-06-27T16:37:43Z")

</div>

Can you explain? I don’t get it.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 27, 2025, 4:48pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/4 "2025-06-27T16:48:51Z")

</div>

p.dispose() removes the pipeline from scene.postProcessRenderPipelineManager.pipelines

so if you have 3 pipelines after the first iteration in the foreach the list has changed.

you could try:

```auto
while (scene.postProcessRenderPipelineManager.pipelines.length) {
  scene.postProcessRenderPipelineManager.pipelines[0].dispose();
}

```

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 27, 2025, 7:28pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/5 "2025-06-27T19:28:30Z")

</div>

It says that`scene.postProcessRenderPipelineManager.pipelines.length`  
`Uncaught TypeError: Cannot read properties of undefined (reading 'length')`

---

<div class="post-metadata">

**Author:** ![georgie](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/georgie/32/46049_2.png) [@georgie](https://forum.babylonjs.com/u/georgie)\
**Post date:** [June 27, 2025, 7:57pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/6 "2025-06-27T19:57:50Z")

</div>

@TadKing42 try using postProcessRenderPipelineManager.supportedPipelines (there is no property called pipelines)

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 28, 2025, 7:07pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/7 "2025-06-28T19:07:42Z")

</div>

```
  while (scene.postProcessRenderPipelineManager.supportedPipelines) {
    scene.postProcessRenderPipelineManager[0].dispose();
  }

```

So what is wrong with this now?  
It’s saying `Cannot read properties of undefined (reading 'dispose')`

---

<div class="post-metadata">

**Author:** ![AlitarSemiramis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alitarsemiramis/32/49920_2.png) [@AlitarSemiramis](https://forum.babylonjs.com/u/AlitarSemiramis)\
**Post date:** [June 28, 2025, 9:46pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/8 "2025-06-28T21:46:30Z")

</div>

It should be:

```auto
while (scene.postProcessRenderPipelineManager.supportedPipelines.length > 0) {
    scene.postProcessRenderPipelineManager.supportedPipelines[0].dispose();
  }

```

PostProcessRenderPipelineManager contains the array of supported render pipelines.

> **[Babylon.js docs](https://doc.babylonjs.com/typedoc/classes/BABYLON.PostProcessRenderPipelineManager#supportedpipelines)**

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 28, 2025, 10:47pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/9 "2025-06-28T22:47:29Z")

</div>

That works, but after running my app for the second time, depth of field seems to just turn into a blur effect. It’s not blurring stuff based on distance… It’s just blurring stuff?

---

<div class="post-metadata">

**Author:** ![AlitarSemiramis](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/alitarsemiramis/32/49920_2.png) [@AlitarSemiramis](https://forum.babylonjs.com/u/AlitarSemiramis)\
**Post date:** [June 29, 2025, 5:07am UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/10 "2025-06-29T05:07:57Z")

</div>

Could you share a playground reproducing the issue you are having?

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 29, 2025, 8:45am UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/11 "2025-06-29T08:45:49Z")

</div>

My workspace isn’t really a standalone project but an extension for Turbowarp, meaning that I can’t really share it. I will try though

---

<div class="post-metadata">

**Author:** ![TadKing42](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tadking42/32/44248_2.png) [@TadKing42](https://forum.babylonjs.com/u/TadKing42)\
**Post date:** [June 29, 2025, 8:59am UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/12 "2025-06-29T08:59:45Z")

</div>

This is what is happening.

I will share code snippets that I can.

```auto
    test(){
      pipelines.forEach((name) => {
        scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(name, camera);
      });
      pipelines.clear();
      while (scene.postProcessRenderPipelineManager.supportedPipelines.length > 0) {
        scene.postProcessRenderPipelineManager.supportedPipelines[0].dispose();
      }
      camera._postProcesses = [];
      console.log(camera)
    }

```

```auto
    async initializescene() {
      scene.meshes.slice().forEach(mesh => mesh.dispose());

      scene.lights.slice().forEach(light => light.dispose());

      scene.cameras.slice().forEach(camera => {
        if (camera !== scene.activeCamera) camera.dispose();
      });

      scene.particleSystems.slice().forEach(system => system.dispose());

      scene.textures.slice().forEach(texture => texture.dispose());

      scene.materials.slice().forEach(material => material.dispose());

      objects.clear();
      particlesystems.clear();
      lights = [];
      shadowGenerators = [];
      const light = new BABYLON.HemisphericLight("light", new BABYLON.Vector3(0, 1, 0));
      console.log(scene.postProcessRenderPipelineManager.supportedPipelines);
    }

```

```auto
    addrenderingpipeline(args){
      pipelines.set(args.name, new BABYLON.DefaultRenderingPipeline(args.name, true, scene, [camera]));
      const defaultPipeline = pipelines.get(args.name)
      if (defaultPipeline.isSupported) {
        /* MSAA */
        defaultPipeline.samples = 1; // 1 by default
        /* imageProcessing */
        defaultPipeline.imageProcessingEnabled = true; //true by default
        if (defaultPipeline.imageProcessingEnabled) {
          defaultPipeline.imageProcessing.contrast = 1; // 1 by default
          defaultPipeline.imageProcessing.exposure = 1; // 1 by default
          /* color grading */
          //defaultPipeline.imageProcessing.colorGradingEnabled = false; // false by default
          //if (defaultPipeline.imageProcessing.colorGradingEnabled) {
            //defaultPipeline.imageProcessing.colorGradingTexture = new BABYLON.ColorGradingTexture("textures/LateSunset.3dl", scene);
          //}
          /* color curves */
          defaultPipeline.imageProcessing.colorCurvesEnabled = false; // false by default
          if (defaultPipeline.imageProcessing.colorCurvesEnabled) {
            var curve = new BABYLON.ColorCurves();
            curve.globalDensity = 0; // 0 by default
            curve.globalExposure = 0; // 0 by default
            curve.globalHue = 30; // 30 by default
            curve.globalSaturation = 0; // 0 by default
            curve.highlightsDensity = 0; // 0 by default
            curve.highlightsExposure = 0; // 0 by default
            curve.highlightsHue = 30; // 30 by default
            curve.highlightsSaturation = 0; // 0 by default
            curve.midtonesDensity = 0; // 0 by default
            curve.midtonesExposure = 0; // 0 by default
            curve.midtonesHue = 30; // 30 by default
            curve.midtonesSaturation = 0; // 0 by default
            curve.shadowsDensity = 0; // 0 by default
            curve.shadowsExposure = 0; // 0 by default
            curve.shadowsHue = 30; // 30 by default
            curve.shadowsDensity = 80;
            curve.shadowsSaturation = 0; // 0 by default;
            defaultPipeline.imageProcessing.colorCurves = curve;
          }
        }

        defaultPipeline.bloomEnabled = false;

        defaultPipeline.chromaticAberrationEnabled = false;

        defaultPipeline.depthOfFieldEnabled = false;

        defaultPipeline.fxaaEnabled = false;

        defaultPipeline.glowLayerEnabled = false;

        defaultPipeline.grainEnabled = false;

        defaultPipeline.sharpenEnabled = false;

      }
      console.log(scene.postProcessRenderPipelineManager.supportedPipelines);
    }

```

P.S. Don’t look at imageProcessing, look at other postprocesses.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 30, 2025, 8:08am UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/13 "2025-06-30T08:08:56Z")

</div>

We need a playground to investigate further, this would really help

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [June 30, 2025, 4:05pm UTC](https://forum.babylonjs.com/t/how-do-i-dispose-a-rendering-pipeline/59203/14 "2025-06-30T16:05:43Z")

</div>

a simpler way is to call dispose on the scene.postProcessRenderPipelineManager cause this simply disposes the render pipelines it contains.
