Clipping issues with BitmapText in 3D

Hm, I cannot find anything on custom comparators / own geometry sorters in the Wiki pages. Any short hint for me?
The other things you mentioned worked just fine on my BitmapFont and BitmapText.

http://hub.jmonkeyengine.org/javadoc/com/jme3/renderer/queue/GeometryComparator.html

…and if you want to see an example that handles more complex use-cases you can look for LayerCompartor in Lemur’s source repo.

Sorry for necroing this thread, again! :smiley:

I am playing with TestBitmapText3D and it works great, but it breaks when I add this line:
g.setQueueBucket(Bucket.Transparent);

So in principle, I put the background quad to the transparent bucket, to achieve some kind of tinted window with text effect. Since the Z coordinate of the background quad is set to be behind the BitmapText, I don’t understand why the text quads suddenly get black backgrounds. There is no Z fighting (or maybe I don’t understand it, sorry) and I have read the page about transparencies and I don’t see how to map this problem there. The problem is only visible on some camera angles.

It just looks broken. Can anyone look into this or explain to me why that happens?
BTW I am using JME 3.1.

Thanks. :smile:

And here is the screenshot:

Is that red quad also in the transparent bucket?

Did you set the blend mode on the text to alpha?

And note: it’s almost impossible to get 3D sorting to work right in this case unless the two objects are exactly the same size. (If they are both in the transparent bucket.) It’s because objects in the same bucket may sort differently at different angles… for example if the red box is bigger than the text then at certain angles it will sort ‘closer’ to the camera even though visually it isn’t. (It is literally impossible for sorting to be right in many cases.)

Yes, the red quad is the background in this test case. All I did was put it in the transparent queue.

I am not sure what you mean to set the blend mode on text. I should probably iterate over all text quads to do that?

Why would it sort closer to the camera on some cases, isn’t translation taken into account?

Thanks for your reply. :smile:

Why is the red quad in the transparent queue if it’s not transparent. If it were in the opaque bucket then you wouldn’t have any issues.

There is no right answer the works in all cases. In fact, there is no right answer the works in much more than half the cases.

If you want specific sorting then you have to add your own geometry comparator to the queue. Lemur has one that allows you to set layers to force certain things to sort in front of others. So you could set the red background to layer 1 and the text to layer 2 and the red layer would always sort behind.

1 Like

Also, Lemur has a method to fix font rendering in some cases where sorting would still be intermittently bad:

    public void fixFont( BitmapFont font ) {
        for( int i = 0; i < font.getPageSize(); i++ ) {
            Material m = font.getPage(i);
            m.getAdditionalRenderState().setAlphaTest(true);
            m.getAdditionalRenderState().setAlphaFallOff(0.1f);
            m.setFloat("AlphaDiscardThreshold", 0.1f);
        }
    }

This is to work around the fact that JME for some inexplicable reason doesn’t load the font material from a J3m or anything overridable by the application.

1 Like

Interesting point … something that I now added to my todo list: let BitmapText2 read from .j3m. :chimpanzee_smile:

I think for BitmapText (original) it is because he made a 1-to-1 mapping of BitmapFontLoader to .fnt files. And these files don’t contain references to .j3m files, but only texture names and glyph positions. Of course there must be a way to adapt it to do that .j3m loading.

Yeah, load the j3m… set the texture.

It’s already loading a j3md, after all.

Whoa, awesome representation, thanks! :smile:
Ok so it is sorted depending on the distance to the camera.
The thing that bothers me is that I made some test of my own and things are not correctly sorted even when I don’t even move the camera - it is static.
I will check your geometry comparators anyway.
Thanks again! :smile: