the_pied_shadow
the_pied_shadow

Reputation: 396

Unity World Space UI that renders in front of gameobjects but is still maskable

So here's the gyst. I'm working on creating a Head Up Display (HUD) such as is found in military jet aircraft among others. To do this, I have a world space canvas which contains the HUD display functions. All fine.

Now here's my issue. On an actual HUD, the pilot does not perceive the images he's seeing as being close to his face (as though on the glass pane it's being projected on) but actually at an infinite view distance. My plan to mimic this is essentially to put the canvas really far in front of the aircraft and make it large. However, the obvious issue with this is that it will be covered by nearly everything in front of the aircraft such as other aircraft, clouds, and even the ground itself. This won't do. It needs to render on top of EVERYTHING...except an image mask because of one other important feature...

...you can only see it if your head is in the right spot. It's as if you're looking at far off images in the sky but can only see them when looking through the small glass pane in front of you. I'm achieving this with an image mask which is on the glass pane. This is an good time to mention that this project is in VR. Thus the pilot can move their head such that the HUD is masked and thus this is just as important of a feature if not more important.

But these requirements all create a somewhat unique dilemma for me that has ruled out solutions for the basic issue of having the HUD render over everything. I can't use a screen space canvas because VR and because I need it in world space for the masking effect. I can't use a second camera as we're rendering in HDRP VR and I'm told it would get computationally expensive very quickly and I'm not even sure how it'd be achieved in the first place. And when experimenting with some shaders (of which I know next to nothing about) and have gotten a shader which renders the HUD over everything....it also renders over the masking object thus overriding my solution to the other important feature. It's like I can't have it both ways.

At this point I feel the solution may be a special shader perhaps even accompanied by a custom masking shader as well but I don't know anything about shaders myself. The quick tutorials for specific shader masking effects I've found online so far have not worked with UI objects. Any help or advice is greatly appreciated.

Upvotes: 0

Views: 595

Answers (0)

Related Questions