#Bloom with shaders
36 messages · Page 1 of 1 (latest)
this custom shaders creating fake glow looks like an implementation of what @buoyant anvil is describing
https://fake-glow-material-threejs.vercel.app/
it works best with round geometry too but it's a cool trick
Oh hey I need to implement this week, too
Might post my findings/process here in case it's mutually beneficial and I welcome you to do the same!
these red blocks are kill blocks, I'm hoping a glow effect will make it more obvious that they are dangerous/"lava"
in lieu of post processing, yeah?
instead of *
oh ok
i know nothing about shaders so this'll be interesting
looks like it uses "layers"
and an object that is and isnt on a particular "layer" has the bloom applied
A common trick for this in mobile/VR dev is to add additively-blended sprites.
I like this approach better @vast dawn
so you already have it working, how's it look?
gotcha
Reading up on the thread, if this isn't about performance (like you aren't hellbent on those platforms), use selective bloom with post-processing.
Note that tone-mapping clamps [0-1] and should be applied after bloom.
A previous trick for this was to multiply colors so they're uniformly out of [0-1] range in the fragment shader, and set the bloom luminance threshold to >1. Only meshes/materials who have been multiplied this way should be picked up by the luminance filter.
Render Pass => Bloom => Tonemapping
Previous versions of three.js both didn't clamp during tonemapping, and allowed tonemapping to run during the render pass.
This was changed in https://github.com/mrdoob/three.js/pull/26130 and https://github.com/mrdoob/three.js/pull/26371, respectively.
Yeah, bloom is an effect that occurs in the optical device (camera, eye, etc...), so post-processing is probably the best way to emulate it.
Here's a video you probably want to watch that discusses the physics and mathematics behind bloom. Definitely watch to the end because he progresses from first principles to a fully fledged bloom simulation that is pretty accurate.
https://www.youtube.com/watch?v=QWqb5Gewbx8
Most people know that lights tend to bloom out when they become very bright, but why is this the case and why with this pattern? In this video I explain why it happens and how it can be simulated in a physically realistic way.
This is a C++ Fraunhofer diffraction simulation that uses the infrastructure in my open-source path-tracer. This techni...
TLDR; bloom is a luminance filter and then a blur, it composites the blurred result on top of the rendered scene.
It's a bit more complicated than that done accurately. I recommend watching that video.
I'd try out the mipmap blur option from the BloomEffect https://github.com/pmndrs/postprocessing for quality/performance.
My study is light transport, but I don't require anyone to know how that works to understand my answer.
So when I give a TLDR for what is relevant for how this should work in three.js for the sake of testing and experimentation, please do not bar me from doing so.
We are adding or complimenting each other in this thread, not competing.
I will grow very tired if this becomes purely contrarian.
Your fragment shader should look like this for a color-managed workflow. Note that the second shader chunk has no effect when rendering to a render target or using post-processing, so you'll need a separate tone-mapping effect (if you have this configured, three has it disabled by default). In your case, this should come after bloom.
gl_FragColor = vec4(...);
#include <colorspace_fragment>
#include <tonemapping_fragment>
React example, but demonstrates this trick specifically. https://vxtwitter.com/0xca0a/status/1525083552672632833
super interesting discussion about selective bloom @ pmndrs discord. i would have paid for this years back. you can push colors out of their 0-1 range and you get it almost for free.
demo: https://codesandb…
💖 264 🔁 24
basically this:
1- set up bloom with a threshold of 1 (nothing gets bloomed)
2- push material colors into hd range
3- disable tonemapping
done 🙂
This is abusing bloom, which usually works over the entire view, but works fine for this use-case.
I didn't know you were aware of the rigorous definition and thought the TL;DR was a bit oversimplified. I will accept accusations of pedantry, but I wasn't trying to be contrarian or compete with you.