Different depth-test-functions

Hello,
I was looking for a way to change the z-test-function from (GREATER_OR_EQUAL) to (GREATER).

It would look somewhat like this:

material.getAdditionalRenderState().setDepthTestFunction(RenderState.TestFunction.Greater);

This would give me two layers for equal-z fragments.
I’m trying to write some text on a box - both have the same z-values, but the text will have (GREATER_OR_EQUAL) while the box behind it will only have (GREATER), so that the pixels written by the text will always win the z-fight against the pixels written by the box.

What is the solution to this problem?

Why not use a custom comparator on the bucket and force the text to always be rendered first?

Lemur has an example of doing that in it if you take a look.

1 Like

The function already exists, actually. I think it’s only in the nightlies maybe. Our online javadocs also seem to be pretty ancient by now… maybe related to the lack of a working automated build.

Also we recently added that feature in last svn.I guess it shoul dbe in the last nightly (I mean the last one being actually uploaded to the repo).
material.getAdditionalRenderState().setDepthFunc(TestFunction function);

https://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/core/com/jme3/material/RenderState.java#765

1 Like
@zarch said: Why not use a custom comparator on the bucket and force the text to always be rendered first?

Lemur has an example of doing that in it if you take a look.

Thanks for the hint, I did not know about this feature.
Actually the text must be rendered after the box, thus last and not first.
Is it possible to have more than 2 such layers when using this feature?
This would be great, because my previous idea only gives me 2 such layers.

@pspeed said: The function already exists, actually. I think it's only in the nightlies maybe. Our online javadocs also seem to be pretty ancient by now... maybe related to the lack of a working automated build.

No automated build system, that’s not good.
But I understand that no one likes to setup things that are so boring like build systems.

@nehon said: Also we recently added that feature in last svn.I guess it shoul dbe in the last nightly (I mean the last one being actually uploaded to the repo). material.getAdditionalRenderState().setDepthFunc(TestFunction function);

Google Code Archive - Long-term storage for Google Code Project Hosting.

Okay, good.
This functionality has been part of OpenGL since version 1.0 - so I think it’s a must-have.

By the way:
Another cool thing is the EQUALS function for z-tests - it allows for such cool effects like “laser scanners” or “contour lines”.

@Ogli said: No automated build system, that's not good. But I understand that no one likes to setup things that are so boring like build systems.

We have an automated build system. We’ve had it for a long time. It is dutifully recompling the nightlies every night and then failing to upload them to the server. Unfortunately, the people who can fix it don’t have any JME time lately.