question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unreal Bloom and Renderer Transparency issue

See original GitHub issue
Description of the problem

I am currently using the Unreal Bloom post with a transparent renderer.

renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setClearColor(0xFF0000, 0);

Unfortunately, the Unreal Bloom pass doesn’t seem to take in account the alpha channel of the coming texture when doing the blur and it apparently comes from getSeperableBlurMaterial in js\postprocessing\UnrealBloomPass.js.

The fragment’s alpha channel is always set to 1.0 which results in a complete removal of the previous alpha values when doing the additive blending at the end.

This is happening in the latest version of Three.js r92 and you can experiment about this issue using the Unreal Bloom example

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:10
  • Comments:55 (9 by maintainers)

github_iconTop GitHub Comments

17reactions
robhawkescommented, Oct 14, 2018

Tidy things up a bit and it seems to work just as well:

void main() {\n\
  vec2 invSize = 1.0 / texSize;\
  float fSigma = float(SIGMA);\
  float weightSum = gaussianPdf(0.0, fSigma);\
  float alphaSum = 0.0;\
  vec3 diffuseSum = texture2D( colorTexture, vUv).rgb * weightSum;\
  for( int i = 1; i < KERNEL_RADIUS; i ++ ) {\
    float x = float(i);\
    float w = gaussianPdf(x, fSigma);\
    vec2 uvOffset = direction * invSize * x;\
    vec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\
    vec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\
    diffuseSum += (sample1.rgb + sample2.rgb) * w;\
    alphaSum += (sample1.a + sample2.a) * w;\
    weightSum += 2.0 * w;\
  }\
  gl_FragColor = vec4(diffuseSum/weightSum, alphaSum/weightSum);\n\
}

I’ve noticed some little (single pixel) artefacts that appear once in a while but seem to be random or based on something that only occurs on some frames as they disappear on the next frame. Not sure if it’s caused by the changes I made or something unrelated to this issue.

15reactions
mbalex99commented, May 23, 2021

I’ve created a full example. Thanks to help from: https://github.com/mrdoob/three.js/issues/14104#issuecomment-429664412

Disclaimer it’s in typescript:

Read more comments on GitHub >

github_iconTop Results From Across the Web

UnrealBloomPass makes background black - three.js forum
UnrealBloomPass does not support transparent backgrounds since the result is incorrect. The bloom does not blend correctly with the HTML and ...
Read more >
Bloom shaft problem - Rendering - Unreal Engine Forums
What you're looking at is a transparency sorting issue, where Unreal isn't sure where the windows are drawn in the scene in relation...
Read more >
ThreeJS- Adding bloom pass affects canvas transparency
First remark, bloomPass. exposure is useless, there is no exposure param in UnrealBloomPass code github.com/mrdoob/three.js/blob/master/ ...
Read more >
Can't Seem to Render Scene with Transparent Background
I've run into an issue trying to remove the background to a scene or setting it to be transparent. This is the CodePen...
Read more >
Three.js: Unreal Bloom Postprocessing - 8th Wall
js camera pipeline module that renders the Three.js scene with transparency and uses a shader to combine the scene with the camera feed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found