I’m troubleshooting this weird thing that happens to my text boxes (made with UI text component) when zooming and orbiting around them looking in different angles. Sometimes they go dark, as if they end up behind the background element in their rendering.
This is the setup:
Some languages like chinese or japanese even have individual characters behave like this.
That’s a common issue with big objects that are positioned closely. Basically the engine is trying to find the correct render order based on the aabb of that model bug in extreme angles it doesn’t have enough precision.
Common solutions are:
Further increase the distance between the two models
Decrease the far/near range of the active camera clipping planes
Use a custom mesh instance sorting callback to override and set the correct order (that can be advanced):
I see, sounds familiar. First solutions I’ve been fiddling with and managed to solve a few. The second one sounded intriguing and I did indeed have an unnecessary large span between 0.05 and 1000 on my camera. I lowered the far plane to 100 instead but unfortunately, it did no difference.
Last solutions suggested might be harder. I’m not sure, I’m using UI Elements here, are they MeshInstances deep inside?
Yes, element components ultimately render using mesh instances as well. Normally UI elements are being ordered from top/bottom in the entity hierarchy, but that holds true I think only when using a 2D screen.
You can try using drawOrder, assign these entities to a layer that has pc.SORTMODE_MANUAL as sorting mode and then use the drawOrder property to set the order. I haven’t done this specifically before but it seems it’d work.
Ok, interesting. Can’t get this to work immediately in my setup. What layer is your btn background on @Leonidas?
My background and text WAS on layer world. I removed world from text only but then it dissappears entirely. I replaced it to have only layer Text. Layer sorting is as in your picture. It does show up in editor but not in launched.
I’m still struggling a little bit with this. Seems our solution the last time forcing the texts to render in a layer on top, also made any texts being physically behind a blue background, would render on top of that one aswell.
I’m looking into the possibility to calculate my own sort distances, but documentation is sparse. I’m using UI Elements. I can’t even find a reference to the meshInstance their using behind the scenes?
Thanks I did consider that, but there is no way I could have draw orders hard coded like that, it’s always going to be dependent on the camera - which sign who currently is behind another.
ah, yes that’s a thought. I already have scripts calculating for distance to camera in about 2fps because I want to cull these textboxes when camera is to near or too far away, so using that I suppose I could create an index based on the distance to camera to sort them in relation to eachother! I’ll see if I get time to try that route. thanks both of you!