Hi everyone,
I have a program where I have several groups of meshes. I want exactly one of these mesh groups to glow. For that, I am able to target the one mesh in that group that makes up most of its area. I do not really know much about the bloom filter as I was not able to find the code for UnrealBloomPass.
Anyway, after looking at the examples and at forum posts especially by @ drcmda, I have written this code
(stencil buffer is true because I am using a stencil buffer elsewhere in the code)
const renderer = new THREE.WebGLRenderer({antialias:true, stencil:true});
renderer.sortObjects = false;
renderer.setSize( window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
renderer.outputEncoding = THREE.sRGBEncoding
renderer.toneMapping = THREE.ACESFilmicToneMapping
...
const renderTarget = new THREE.WebGLRenderTarget(window.innerWidth, window.innerHeight, {
type: THREE.HalfFloatType,
format: THREE.RGBAFormat,
encoding: THREE.sRGBEncoding,
stencilBuffer:true
})
renderTarget.samples = 8;
const composer = new EffectComposer( renderer, renderTarget );
composer.addPass(new RenderPass(scene, camera));
composer.addPass(new ShaderPass(GammaCorrectionShader));
composer.addPass(new UnrealBloomPass( undefined, 6, 8, 1))
The group of meshes is created in its own separate function. There, I have this code after its creation so that one mesh that makes up most of the group is set to the values that should make it glow.
group.toneMapped = false;
red_plane_group.children[0].material.color= new THREE.Color(10, 0, 0);
Then, I am using this function to animate everything
function animate(){
requestAnimationFrame(animate);
composer.render();
}
So now, I have several questions:
- Can I leave out the renderer’s toneMapping? It is included in many examples, but I dislike how it looks.
- Currently, every non-red group of meshes is a grey-ish white on every single group when they had more distinctive colors before so that they cannot be told apart and a lot of the recognizable lines have disappeared, even though none of their RGB values should be above 1 and I already set the luminance threshold to 6 so that only the mesh in the group with the RGB value 10 glows. Why is that? Is it working different because I am using groups of meshes instead of single meshes?
Also, the glow works on the group where I wanted it to work although it seems to more a sort of aura around the group rather than directly emanating from it. Also, the glow seems to go out that when I drag the group to the lower part of the screen (which is only visible after everything gets resized when I open the console for debugging but still).
Thanks in advance