Exclude glow layer

Hi guys. I need your help to achieve the following

I have a mesh with two child meshes. One for rocks and one for glow, each has PBRMaterial


In combination, it gives a following

I’m trying to play with an emissive parameter of PBR but don’t receive the glow I want. Also, I tried the Glow Layer. It works well, but it applies glow on all the glow mesh surface.

As result, my rocks are affected by a red glow, but it’s not something I want.

Here’s a playground Babylon.js Playground

I’m thinking maybe if I use the stencil buffer to draw rocks on top of glow maybe it would help. But I didn’t manage to implement this yet.

1 Like

Hi @ci4anish! I am no expert with the glow layer, but here are some pointers in case you haven’t checked them already: How to add glow effects using Node Material: Node Material Glow Effects - YouTube and of course the main documentation page: Making Meshes Glow | Babylon.js Documentation.

Thanks for the reply. Yes I checked those.
I don’t need to manipulate a node material because I already have PBRMaterial set up and glow layer supports it.

It gives me expected result if I use emissive texture.

But in the case above I can’t have emission texture. Glow is based on red hidden mesh. So what I need is to say babylon somehow to apply glow layer only on the visible parts

Just an idea, but this might help?

gl.customEmissiveColorSelector = (mesh, subMesh, material, result) => {
	if(mesh.name === 'noGlowMeshName')   result.set(red, green, blue, 1);	// rgba of glow color
}

If it is a submesh, you can use i.e. subMesh.name or subMesh.id like mesh.id.

Or prepare a array of selected meshes and use for-in.

This would help if the problem was to find out how to apply specific glow config to a particular set of meshes. But in my case I know exactly how to find mesh and apply an effect. The problem is that the glow effect mask applies to the whole area of the red mesh not just for the visible parts.

Thanks though)

Using highlightLayer gives result like in sandbox:

I was bit irritated by your first picture, because I thought all the time that is the view sandbox would give.

2 Likes

Frustrating, isn’t it? Well, we’ll get there eventually. Let us just continue to complain and share our experience :grin:

No, it’s the Unreal Engine 5 output. Sorry for confusion

Somehow I managed to fix it by setting the
emissiveLayer.material.alpha = 0

3 Likes

Unacceptable. We have to do better. :grinning:

Now there goes. :heart_eyes: That’s much more like it, isnt’it?
Bookmarked. Thanks for sharing and applause.
Have a great day,

1 Like

ahah thanks, I have no idea how did I fix it though)

Really nice look!