What would be the best way to depth sort this specific glow effect?

https://playground.babylonjs.com/#R0H3IN#14

I started trying to deploy my specific glow effect and I realized its going to be a pain to sort this.

So I guess, I need to pass the depth information as well and do the same blur effects as the glow? I’m not sure how this would actually work because that will totally shift the depth information.

This is kind of scary, I need this effect to work but did not consider any of this.

This is why we rely on stencil in the highlight layer to only render where this is not the model itself, also we use depth on the main glow texture to occlude before blurring.

What you are doing sounds actually more like the highlight layer than the glow ?

Do you think that would accommodate the visual I need? Basically we have a bunch of shimmering sequins that need glow around them, but if we use the emissive then we lose our sheen and shimmer which is needed for the final.

I need to make them glow and retain their shimmer and reflections while not tanking performance.

The mesh is a sps mesh with multimaterials, and I need the glow to be associated with specific materials on that multimat.

Yup not sure in this case :frowning: If you could share a visual we could try to help thinking about the best approach

I wish I could, but the client might not like that.

Will give the highlight layer a shot and see if I cant use that instead.

@sebavan with the highlight layer they have to have an emissiveTexture for the setup to work for me. Is there a easy way to make it reference the emissiveColor instead as this will be the only way for me to accomplish this correctly unless I want to bind an emissive Texture to all my sub materials.

Prehaps just spinning up a 1 by 1 DynamicTexture for each one that I know will need the info and fill it with the emissiveColor of the material then bind that to the emissiveTexture channel before I add it to the highlight layer?

UPDATE
Yeah that worked, but now I need to figure out how to make the materials that have no emissiveData to not render any highlight.

The mesh is a SPS mesh with a bunch of different materials on it, so I need the highlight not to render if the emissiveColor is black. Which means I might need to change the merge shader perhaps, and just discard the black data?

https://playground.babylonjs.com/#25MZY3#3

Got it, thank you for pointing me in the right direction @sebavan

1 Like

Eeeek, what do I do if the object has a transparency?

What is the sorting setup?

Do you need more information than found here Troubleshooting Solid Particle System Transparency Issues | Babylon.js Documentation ?

Naw its not the mesh, actually I’m thinking of going back to the cutout glow layer. Any ides though are nice so ill take a look to make sure Im not missing anything.

You may try to read pixels from HighlightLayerBlurRTT and HighlightLayerMainRTT textures and change white pixels into needed color.

Ok, now I need to figure out how to apply vertex displacements to the shader that is responsible for rendering the emissive data before the rtt capture.

Is there a way to pass a custom material to that, or should I just step in and hyjack that as well?

https://playground.babylonjs.com/#R0H3IN#16
Basically need to make sure this moves with the fragment updates

Latest @Evgeni_Popov changes in PR will help with that. They will be available at max tomorrow in the nightly.

https://playground.babylonjs.com/#R0H3IN#17

XD… I hate asking so many questions.

This is closer to what I want, but it does not work because the colors go wonky. Trying to fight that now.

Also it looks like I will need to extend the effectLayer to include uv3 data and then update some stuff here:

to have the effectLayer have the same displacement happening?

UPDATE
I have a plan to action now and will have to extend the glowMapGeneration.vertex.fx and the EffectLayer in order to get my final effect. Like 95% sure its figured out now, thanks for talking it through with me.

It will help but the code to support a different material from the default one for the highlight pass won’t be there yet. I will need a little time to add it.

1 Like

I can do that part for my purposes.

https://playground.babylonjs.com/#R0H3IN#22

1 Like

Really cool effect! :slight_smile: