How to apply bloom only to line rendering?

Hey,

I want to apply bloom only to drawn lines from app.drawLine(). Since they can be on their own seperate layer, I thought maybe you could apply the bloom effect only on that specific layer. I tried using 2 cameras as suggested in these posts, but to no avail.

Anyone got this to work and cares to share the code?

Should I do my own thread?

This is probably the way I would implement it:

  • render the scene as normal - all the meshes and all. This usually renders some data to alpha channel that is not used, and so
  • render full screen quad to write 0 to alpha channel
  • render your lines on last layer, but make sure they render 1 or similar to alpha channel
  • run the bloom, but adjust the shader the way it does not use intensity from RGB channel, as that would bloom everything bright, but it uses intensity from the alpha channel (so lines only).
2 Likes

Hello, can you make an example please ?

thank u

  • run the bloom, but adjust the shader the way it does not use intensity from RGB channel, as that would bloom everything bright, but it uses intensity from the alpha channel (so lines only).

Where do I need to change to do this?

If I understand correctly you will be changing line 100 of the bloom effect like this (@mvaligursky can comment if this is correct):

        "    gl_FragColor = clamp((vec4(color.a, 1.0) - uBloomThreshold) / (1.0 - uBloomThreshold), 0.0, 1.0);",
1 Like