Three.js Postprocessing Multiple RenderPasses

Demonstrating a problem with multiple RenderPasses

by QuisIsHere

HTML

<!-- Import maps polyfill -->
<!-- Remove this when import maps will be widely supported -->
<script async src="https://unpkg.com/es-module-shims@1.3.6/dist/es-module-shims.js"></script>
<script type="importmap">
	{
		"imports": {
			"three": "https://unpkg.com/three/build/three.module.js",
      "three/addons/": "https://unpkg.com/three/examples/jsm/",
      "postprocessing": "https://cdn.jsdelivr.net/npm/postprocessing@6.33.2/+esm"
		}
	}
</script>

CSS

body {
	margin: 0px;
}

JavaScript

// Simple three.js example

import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { BloomEffect, EffectComposer, EffectPass, RenderPass, BrightnessContrastEffect, Selection, DepthCopyPass } from "postprocessing";

let mesh, renderer, scene, camera, controls, composer, composer2;

init();
animate();

function init() {

    // renderer
    renderer = new THREE.WebGLRenderer({
	powerPreference: "high-performance",
	antialias: false,
	depth: true
});
    renderer.setSize( window.innerWidth, window.innerHeight );
    renderer.setPixelRatio( window.devicePixelRatio );
    document.body.appendChild( renderer.domElement );

    // scene
    scene = new THREE.Scene();
    
    // camera
    camera = new THREE.PerspectiveCamera( 40, window.innerWidth / window.innerHeight, 1, 10000 );
    camera.position.set( 20, 20, 20 );

    // controls
    controls = new OrbitControls( camera, renderer.domElement );
    
    // ambient
    scene.add( new THREE.AmbientLight( 0x222222 ) );
    
    // light
    const light = new THREE.DirectionalLight( 0xffffff,5 );
    light.position.set( 20,20, 0 );
    light.layers.enable(1)
    scene.add( light );
    
    // axes
    scene.add( new THREE.AxesHelper( 20 ) );

    // geometry
    const geometry = new THREE.SphereGeometry( 5, 12, 8 );
    
    // material
    const material = new THREE.MeshStandardMaterial( {
        color: 0x00ffff, 
        flatShading: false,
        transparent: false,
        opacity: 1.0,
    } );
    // material
    const material2 = new THREE.MeshStandardMaterial( {
        color: 0x0000ff, 
        flatShading: false,
        transparent: false,
        opacity: 1.0,
    } );
    const effectPass = new BrightnessContrastEffect({
			brightness: 0.75
		});
    const effectPass2 = new BrightnessContrastEffect({
			brightness: 0.0
		});
    // mesh
    mesh = new THREE.Mesh( geometry, material );
    scene.add( mesh );
    mesh = new THREE.Mesh( geometry,...