Highlight objects behind other objets - Shader

I’m just a beginner on Shaders (I followed this tutorial series) but I would like to use something more complex (highlight objects behind others). I’ve looked here too but it isn’t there.

There are much examples for unity so I decided to “translate” them to JME3 but, before I started to try it by my self, I wanted to know if it is already done here or someone can translate it just faster than me. If not, I’ll post here the solution once I have it.

Thanks in advance for any help.

You might not have to mess with shaders at all. Off the top of my head, if I were trying to do this effect then I think I would render the mesh twice. Once normally as part of the scene and a second time in the translucent bucket with a different material. That different material would set the color to the funky blue or whatever… but also set the depth test function to “greater than”, ie: would only render in places where the depth was already nearer, ie: the occluded parts.

Based on the online docs, it seems like the ability to set the depth test function on the RenderState might have been added after 3.0.x… but it would be the easiest way.

@pspeed Thanks, I’ll try your solution. By the way, is there a way to set the depth test function on the shader?, just like the “ZTest” on Unity?, I’ve been looking for it but I can’t find it.

EDIT: Thinking it better, if I draw my “player” (object that I want to be seen from anywhere) in the translucent bucket, it won’t be seen at all if it is in the back of other objects, is it?

@NemesisMate said: @pspeed Thanks, I'll try your solution. By the way, is there a way to set the depth test function on the shader?, just like the "ZTest" on Unity?, I've been looking for it but I can't find it.

EDIT: Thinking it better, if I draw my “player” (object that I want to be seen from anywhere) in the translucent bucket, it won’t be seen at all if it is in the back of other objects, is it?

To the first, Material.getAdditionalRenderState()… it has nothing to do with the shader itself.

To the second, translucent bucket is just drawn last… which is presumably what you want if you want to draw the highlighting over everything else.