How to occlude glow effect

Recommended Posts

Hello everyone,

I am trying to find a way to properly occlude the glow effect. Consider:


from the other side:


The glow effects are not occluded by the walls and other opaque objects.

Related code:

const lamps = scene.getMeshByName("hotel_lower_lamp");
const glow = new BABYLON.GlowLayer("glow", scene);

Just to be sure, I have also set opaque materials:

material.transparencyMode = 0;

Hope someone can point me to the right direction.

Thanks alot!

Share this post

Link to post
Share on other sites

As you only include the lamps, the occluder are not rendered in the layer. In order to add the occluder, and therefore glow occlusion, you either need to simply call add vs add includedonlymesh or you also need to addIncludedOnlyMesh for the occluders.

Share this post

Link to post
Share on other sites


As shown in PG: https://playground.babylonjs.com/#QLBNSV#2

1. Include sphere1 in the glow layer, and set its material's emmissiveColor to black. Then sphere1 will occlude sphere2's glow effect.

If you want both spheres to glow, consider setting their emmissiveColor to different colors or intensities. Don't over-blow the exposure so you can see the "occluded" effect.

PG: https://playground.babylonjs.com/#QLBNSV#3

2. You can use the sphere materials' emmissiveColor to control the glow color, or use "gl.customEmissiveColorSelector" on the glow layer.

Doc: https://doc.babylonjs.com/how_to/glow_layer#controlling-glow-color-per-mesh

Hope this solves your problems. Please let me know if there are any further questions.


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.