How to enable/disable Bloom Effect at runtime?

Same as title, is there any way to enable/disable the Bloom Effect at runtime?

Hi there! I’m an AI-powered assistant here to help you. I can assist with questions about Needle Engine, three.js, and basic Unity or Blender help. Please reply with your specific question, including your OS and relevant versions for further assistance!

2 replies left - GPT 4O
thread_22sNuCXa3nFUVaKMBCJmqJNH
Reply to this message to continue the conversation

Yes, get a reference to the volume component, it has a effect list, there deactivate bloom and mark the postprocessing volume dirty (the removeEffect method currently doesnt check effects in the sharedVolume which is the case for you i believe, this will be fixed in a future version)

    await delay(100);
    const pp = findObjectOfType(Volume);
    if (pp) {
        const bloom = pp.effects.find(e => e.typeName == "Bloom");
        if (bloom) {
            console.log("Found bloom");

            await delay(1000); // for demonstration
            bloom.active = false;
            pp.markDirty();
            
            // this will be fixed for effects in the shared volume:
            // pp.removeEffect(bloom);
        }
    }
});

Thanks I will test this now, will it work the same for enabling it again? I’ll test and feed back here

is the fix in 3.48.0?

yes it is

The script doesn’t find Volume in the scene - I am using BloomEffect.ts

however just finding the bloomeffect end enable/disable on it works fine!

Volume is what is managing all the postprocessing effects so it must be in the scene

I’m only using the BloomEffect.ts component in this scene which is odd, no Volume component I have manually added either.

Aaah got it, sorry I was assuming you had the Volume component in the scene.

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.