Hi guys, I’ve been struggling (for days) to get the effect I want:
-Transparent background (no black)
-Just particles/balls being light-up/bloomed/glowing
-Container cuboids not to be light-up/bloomed/glowing
-Resolution to be something reasonable (As as soon as I applied it become pixellated?)
Find here the outcome at the moment:
(no bloom being shown, all meshes randomly light up but with no glow
If I set this to false: bloomComposer.renderToScreen = true
All the meshes light up but the black canvas background comes back (so no transparent background)
The code I am using at the moment related to that is the following:
const bloomLayer = new THREE.Layers(),
params = {
exposure: 1,
bloomStrength: 1,
bloomThreshold: 0,
bloomRadius: 0,
scene: 'Scene with Glow',
},
ENTIRE_SCENE = 0,
BLOOM_SCENE = 1,
darkMaterial = new THREE.MeshBasicMaterial({ color: 'black' }),
materials = {},
renderScene = new RenderPass(scene, camera),
bloomPass = new UnrealBloomPass(new THREE.Vector2(width, height), 1.5, 0.4, 0.85),
bloomComposer = new EffectComposer(renderer),
finalPass = new ShaderPass(
new THREE.ShaderMaterial({
uniforms: {
baseTexture: { value: null },
bloomTexture: { value: bloomComposer.renderTarget2.texture },
},
vertexShader: document.getElementById('vertexshader').textContent,
fragmentShader: document.getElementById('fragmentshader').textContent,
defines: {},
}), 'baseTexture',
),
finalComposer = new EffectComposer(renderer)
Then I set the following properties and so forth, as per https://threejs.org/examples/?q=bloom#webgl_postprocessing_unreal_bloom_selective the following:
finalComposer.renderTarget1.texture.format = THREE.RGBAFormat
finalComposer.renderTarget2.texture.format = THREE.RGBAFormat
bloomPass.threshold = params.bloomThreshold
bloomPass.strength = params.bloomStrength
bloomPass.radius = params.bloomRadius
bloomComposer.renderToScreen = true
bloomComposer.addPass(renderScene)
bloomComposer.addPass(bloomPass)
finalComposer.addPass(renderScene)
finalComposer.addPass(finalPass)
finalPass.needsSwap = true
bloomLayer.set(BLOOM_SCENE)
and then in the animation loop:
const startAnimationLoop = () => {
bloomComposer.render()
finalComposer.render()
window.requestAnimationFrame(startAnimationLoop)
}
Would be amazing to know how to achieve the following effect https://threejs.org/examples/?q=bloom#webgl_postprocessing_unreal_bloom_selective just for the particles inside and still retain transparent background + a reasonable resolution (no antialiasing seems to apply with postprocessing?)