How to prevent hide a model behind others?

how to prevent hide a model behind others?

I’m not sure what you are asking.

A picture is worth 1000 words.

1 Like

You should expand on your question but probably you mean something like a gun in FPS where it is rendered always on top of object and doesnt collide with them? It is tricky and wouldnt work like you want it to look due to shadows. But… experiment with this sollution

modelMaterial.getAdditionalRenderState().setDepthFunc(TestFunction.Always);
model.setQueueBucket(RenderQueue.Bucket.Transparent); 
1 Like

Isn’t that basically the same as turning depth test to false?

1 Like

:man_shrugging:

Disabling depth test in opengl causes the depth write to be disabled aswell, the result might be the same in this case, unless there is some postprocesing that needs the depth information.

1 Like

Hmmm… I always remember it being the other way around. Like, you have to write if you want to test but you don’t have to test if you want to write. I can never remember without trying it.

I did make a full screen quad that forced the depth to a certain distance once but it’s possible that I had a depth function (though back when I did that, JME’s depth test function stuff was kind of broken.)

1 Like

Yeah, it’s weird and counterintuitive but from the khronos wiki:

When depth testing is disabled, writes to the depth buffer are also disabled.
Depth Test - OpenGL Wiki

1 Like