Using Post Effects Bloom with World UI causes depth issues

I’m struggling with this exact same issue but theres on thing I don’t understand. Why does the z break when moving the ui elements to the world layer when they didn’t when the are on the ui layer? Like op I find the may text disappears underneath my buttons when placing the camera at certain angles but its solid when leaving it on the ui layer without bloom. From experience offsetting things slightly doesn’t usually work (only delaying the problem). I believe unreal engine gets round these issues by rendering them to texture, is that something that can be done?

That can be done as we have a general render to texture method but you do lose input and can costly in VRAM usage.

The other thing that could be done is have it on a layer above the world with a manual sorting logic setting and have a script that sets the render order on the elements based on the hierarchy. I wonder if the screen component in world space does that for you :thinking:

So as I understand it, because enabling postprocessing causes the world to be drawn to a texture its losing the depth when being written back to the screen. What I’ve got so far is I’ve got the depth texture of the world in the post process shader and I’m writing it back to the screen via gl_FragDepth. This unfortunately hasn’t made a difference yet, what else do I need to do to restore the old functionality?

Can you post a simple public repo to show this issue for people to take a closer look at please?

Its the same issue as everyone else is experiencing. as soon as you use post effects (e.g. bloom) depth rendering breaks on ui layer, changing the layer back to world just introduces more issues (z fighting).

heres a simple example with a cube in front of some text, if you fork it and disable to bloom it works as expected

I also take it that you don’t want the UI to be affect by bloom?

Does this work better for you?

(also worth mentioning that the UI render layer clears the depth buffer too so thats not helping that World UI elements are on the UI layer)

If I can avoid it yes!

Looks like you would need to do something along the lines of this: Apply Bloom only to specific Materials - #8 by mvaligursky

thanks I’ll take a look

Unfortunately that has the other issue that I mentioned layers bug disappearing text - PLAYCANVAS
If you rotate the texture the text disappears. An issue that doesn’t occur when using it on the UI layer without bloom

Can you send a link to the project please?

hang on I think I might have found the problem, your example had sort mode manual set. Now I just need to figure out how to do this engine only

1 Like

Unfortunately it turns out this fix doesn’t work, even without bloom z-ordering with 3d ui elements doesn’t work correctly and depends on order of insertion. Setting them all to the world layer introduces new issues. After some digging I’ve discovered that its because the materials have depthWrite set to false. Is there a public way to update the material of a text element because this is not great but it does appear to allow correct depth sampling on the ui elements

entity.element._text._material.depthWrite = true;
entity.element._text._material.alphaToCoverage = true;

Not for text, it really should be something we expose as we do so on the image element

Issue created:

Thanks mate. using the above code doesn’t work directly as the change seems to get overwritten somehow (wrapping it in a setTimeout proves this). Its obviously a private api so fair enough, look forward to a correct way.

Better still would be for 3d ui elements to work out of the box without having to mess with the layers + materials. Feels to me it should only be treated differently when part of a screen element, otherwise it feels completely inconsistent with other scene objects

Do you change the text content itself? If so, I think when it generates the mesh for new text, it reassigns the default material

no, once its created I don’t think its changed again