Selective UnrealBloomPass issues

I seem to keep needing selective bloom recently and using multiple composers is pretty messy, so I updated the UnrealBloomPass to do it directly. I was planning to spend some time to see if there’s a more performant way of excluding the non-bloomed objects, but so far it seems to be OK. You can try it out if you like.

https://pastebin.com/jtk5d30f

Used exactly like the old bloom pass, it will bloom the whole scene:

const pass = new UnrealBloomPass( resolution, strength, radius, threshold );

But there’s some extra params you can pass in:

const pass = new UnrealBloomPass( resolution, strength, radius, threshold, selectedObjects, scene, camera );

Pass in your main scene and camera, and selectedObjects is an array of objects from your scene that you want to bloom.

You may also need to update UnrealBloomPass.changeVisibilityOfNonSelectedObjects() to get the effect you need, try switching between color write and visible:

 changeVisibilityOfNonSelectedObjects: function ( bVisible ) {
 
        var self = this;
 
        this.scene.traverse( function( child ) {
 
            if( child.isMesh && ! self.selectedObjects.includes( child )) {
 
                child.visible = bVisible;
                // child.material.colorWrite = bVisible;
 
            }
 
        } );
 
    },

@MelMacaluso note that this is based on the ES6 module version of the bloom pass, while you’re using the old UMD version in the fiddle you linked above. You’ll need to update your code to use modules for this work. See any of the examples for how to do that, for example: https://threejs.org/examples/#webgl_postprocessing_unreal_bloom_selective

6 Likes