Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make three.js bloom effect similar to Babylon.js #621

Open
cx20 opened this issue Sep 22, 2022 · 10 comments
Open

Make three.js bloom effect similar to Babylon.js #621

cx20 opened this issue Sep 22, 2022 · 10 comments

Comments

@cx20
Copy link
Owner

cx20 commented Sep 22, 2022

I added a bloom effect to the three.js sample.
However, the display result is slightly different from Babylon.js.
If possible, I would like to make adjustments so that the display results are the same.

Library result
Babylon.js + EmissiveStrengthTest image
three.js + EmissiveStrengthTest.gltf image

Edit 2022-09-23
I fixed it because the link destination was localhost.

@emackey
Copy link
Contributor

emackey commented Sep 22, 2022

@elalish Any thoughts here? It looks like ThreeJS is blooming the clamped white color, not the original emission color. Is there a way to do otherwise?

@elalish
Copy link

elalish commented Sep 22, 2022

Interesting; I haven't played with three's bloom shader yet, but I would hazard a guess that perhaps tone mapping is being applied before the bloom pass instead of after? That might also explain why the right two cubes look almost the same. Perhaps it just isn't using a floating-point framebuffer for the intermediate draw, so all the values are getting clamped? @mrdoob in case he has any pointers.

@cx20
Copy link
Owner Author

cx20 commented Sep 23, 2022

I used the following example as a reference for Bloom's implementation.

https://threejs.org/examples/webgl_postprocessing_unreal_bloom.html
https://github.com/mrdoob/three.js/blob/master/examples/webgl_postprocessing_unreal_bloom.html

However, I didn't know how to use toneMapping correctly, so now I use THREE.NoToneMapping.

renderer.toneMapping = THREE.NoToneMapping;
//renderer.toneMapping = THREE.LinearToneMapping;
//renderer.toneMapping = THREE.ReinhardToneMapping;
//renderer.toneMapping = THREE.CineonToneMapping;
//renderer.toneMapping = THREE.ACESFilmicToneMapping;
//renderer.toneMapping = THREE.CustomToneMapping;

@cx20
Copy link
Owner Author

cx20 commented Sep 23, 2022

I tried changing the toneMapping to use THREE.ReinhardToneMapping.

const params = {
    exposure: 1,
    bloomStrength: 1.0,
    bloomThreshold: 0.6,
    bloomRadius: 0.5
};

renderer.toneMapping = THREE.ReinhardToneMapping; 
Library result
before image
after image

@elalish
Copy link

elalish commented Sep 23, 2022

Ah, that makes sense; without tone mapping you lose all this HDR info to clamping. One note: ACESFilmicToneMapping has become a bit of an industry standard, so you might want to go with that.

Using tone mapping is quite important for PBR rendering generally, not just for bloom. Take a look at my article.

@cx20
Copy link
Owner Author

cx20 commented Sep 24, 2022

@elalish Thanks for all the advice. I'm experimenting with ACESFilmicToneMapping now.
I am trying different parameters but Bloom's emission color seems to be white. Any advice?

ToneMapping result
NoToneMapping
bloomStrength: 0.5,
bloomThreshold: 0.9,
bloomRadius: 0.5
image
ReinhardToneMapping
bloomStrength: 1.0,
bloomThreshold: 0.6,
bloomRadius: 0.5
image
ACESFilmicToneMapping
bloomStrength: 0.6,
bloomThreshold: 0.9,
bloomRadius: 0.0
image

@cx20
Copy link
Owner Author

cx20 commented Sep 24, 2022

I have created the following sample to facilitate comparison of the effects of Tonemapping and Bloom.
three.js Bloom Test
https://jsfiddle.net/cx20/x1g2j07y/
image

ToneMapping Bloom Off Bloom On
No image image
Reinhard image image
ACES Filmic image image

@cx20
Copy link
Owner Author

cx20 commented Sep 25, 2022

I have tried the same combination of tone mapping and Bloom in Babylon.js as well.
Babylon.js Bloom Test
https://jsfiddle.net/cx20/ky0tcgr6/
image

ToneMapping Bloom Off Bloom On
None image image
Standard image image
ACES image image

@elalish
Copy link

elalish commented Sep 26, 2022

I'd say Babylon looks more like I'd expect here; this looks like enough info to file a bug on three.js, especially if you include a link to your code. ACES pulls bright colors toward white, but the fact that the whole bloom looks white makes me think it doesn't have the right shape of exponential fall-off in intensity.

@cx20
Copy link
Owner Author

cx20 commented May 31, 2023

When I upgraded three.js from r152 to r153, the effect of Bloom became dazzling. It might be a usage issue, but I haven't found a solution yet.

model three.js r152 three.js r153
EmissiveStrengthTest image image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants