Clarification on Render Priority - keeping a 3D asset at the forefront

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ian_Kovich

I believe I read somewhere that Render Priority isn’t implemented yet. Just to make sure and to know if I’m thinking of the right term, let me explain what I’m trying to accomplish:

I’m making a boxing game where the player’s character (blue) is in front. To make my life easier when animating the opponents, I want to make sure that their attacks and animations don’t clip into the player character. I could accomplish this using forced perspective since the camera doesn’t move, but I’m certain there’s an easier way to do this.

Like how in first person shooters where the player’s hands and weapon never clip into walls or any other asset, I want the player character in my game to always be rendered on top. I’ve tried changing render priority but that doesn’t seem to change anything, and turning on ‘no depth test’ sort of works, but it makes complex meshes like characters have see-through body parts, so I don’t think that’s the setting I’m looking for. Turning on ‘no depth test’ sometimes doesn’t change anything at all other than affect the mesh itself.

I’m certain that I’m missing an option that I need to turn on or maybe the solution is something else altogether. Any help that I can get or clarification would be greatly appreciated. Thank you in advance!

:bust_in_silhouette: Reply From: MysteryGM

To prevent models from clipping math and physics is used instead of shaders. Two things are used widely in games.

1.)The first is collision checking, often implemented on a per joint bases, this is an example from Unreal:
enter image description here
Notice how the basic collisions shapes are used together to create a rough simulation of what the model will collide like.

2.)The second thing used is Inverse Kinematics, in Linear Algebra there is a lot of easy ways to implement IK.
Godot has IK for 3D, or at least I noticed a class for it.
This tutorial is for Unreal but explains the concept well:

Hey MysteryGM, thanks for the link. I’ve been meaning to look into IK for games, so I’ll be sure to check it out.

Unfortunately, that’s not the answer I’m looking for. It’s my fault, though, I thought explaining my game would make my question more clear, but I think it just had the opposite effect, so allow me to ask my question once more without all the fluff:

Is there a way to set a 3D asset in Godot so it always appears on top of everything else? If so, how do I go about doing that?

Sorry for the confusion, and thank you again.

Ian_Kovich | 2018-10-20 06:44

A cheat you could use is to flag the shader as transparent, then use the render priority.

If both materials are flagged transparent then the one with the highest render priority is rendered ontop.

MysteryGM | 2018-10-20 20:59

:bust_in_silhouette: Reply From: Zylann

Changing drawing order changes the order in which the surface is drawn, but that doesn’t mean it will not care about the depth buffer.

Making it ignore the depth buffer won’t cut all cases because the object is still drawn with some random order, and when it’s not a cube it will indeed cause self-see-through issues anyways, so you need the depth test.

One of the remaining solutions could be to render your model on an offscreen texture (using a Viewport), and draw that on top of the game, so it will really be on top of everything with no visual intersection possible. Though everytime I think about a solution involving viewports (and that happens a lot) I often find out it takes some time to make it work right^^"

There are other ways but I don’t see how to do them with the somewhat-fixed rendering pipeline exposed by the engine, like:

Or simply don’t care about clipping since it should be minimal if animations are properly interpolated? In a boxing game I would not expect an animation to always play the same way, it could “bend” so that a “punch” animation can target a defined point in space (3.1 supports blend spaces so you can blend animations to target a moving point so it should not miss or clip too much). This is a bit related to MysteryGM’s answer.

Hi Zylann, thank you for your help. I had thought that what I was inquiring about was much simpler to accomplish than it was and all I needed was to tick the right checkboxes, but it helps to know that it’s much more involved than that. This is fine, because I have workarounds to achieve the result I’m looking for, and this will be handy to know for the future. Again, thank you and MysteryGM for all your help!

Ian_Kovich | 2018-10-20 23:26