I’ve been trying to do my homework on this but having a lot of difficulty for what seems like such a fundamental 3d game engine feature. I appreciate the z-buffer issues and that it can only be accurate to a certain precision but for objects that are static and always guaranteed to be one behind the other it seems like there should be a simpler solution. First I tried to even figure out what alpha discard was and it seems like it’s a material parameter that can be set like this:
Material material = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
material.getAdditionalRenderState().setBlendMode(BlendMode.Alpha);
material.setFloat("AlphaDiscardThreshold", .5f);
text.setMaterial(material);
text.setQueueBucket(Bucket.Transparent);
But the text in the BitmapText doesn’t have a way to set the material from what I can gather. The only reference to material that BitmapText has is the method setMaterial() but in my testing and other forum threads it seems to only affect the quad behind the text, not the text itself. I couldn’t find any specific code examples in the threads I was looking at so I took a shot in the dark with these settings but they didn’t work.
Next you mentioned and I saw multiple other threads where people suggested to set a custom geometry comparator. I never saw any code examples for that either really but I tried to do it like this:
RenderQueue rq = vm.app.getViewPort().getQueue();
rq.setGeometryComparator(Bucket.Transparent, new TransparentComparator() {
@Override
public int compare(Geometry o1, Geometry o2) {
return Float.compare(o1.getWorldTranslation().getZ(), o2.getWorldTranslation().getZ());
}
});
I also tried to use Lemur with these pom settings in maven:
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
...
<dependency>
<groupId>com.simsilica</groupId>
<artifactId>lemur</artifactId>
<version>1.9.1</version>
<type>pom</type>
</dependency>
It pulled in guava and sl4j but none of the references to Lemur classes (ie Button or TextField) are resolvable in my code like it doesn’t see the jar correctly. Looking at the Lemur documentation and API I also don’t see a text component. You mentioned specifically loading the font through Lemur so I looked for a utility like that but didn’t find it either. Any further steering?
Edit: I just set the opaque comparator in addition to the transparent comparator like this:
rq.setGeometryComparator(Bucket.Opaque, new OpaqueComparator() {
@Override
public int compare(Geometry o1, Geometry o2) {
return Float.compare(o1.getWorldTranslation().getZ(), o2.getWorldTranslation().getZ());
}
});
and now the text no longer has the black background bleeding through. Why would changing the opaque comparator make the items in the transparent bucket resolve their z-order correctly?