How can I render my game scene inside a visor-shaped mask/frame in Godot?

Godot Version

4.6.1 stable

Question

I’m trying to render my gameplay scene inside a visor-shaped frame (like a helmet HUD), but I can’t get the masking to work correctly.

Goal
I want the scene to only appear inside the visor area, like this:

Current Result
Right now the scene is rendered normally and the visor frame just sits on top:

What I Tried

  • TextureRect with mask

  • ViewportContainer + SubViewport

  • Shader-based texture masking

None of these produced the clipped visor-shaped render I want.

Scene Setup

  • Control
    ├─ SubViewportContainer
    │ └─ SubViewport
    │ └─ Node2D
    │ ├─ Game
    │ ├─ Game2
    │ └─ Camera2D
    └─ TextureRect

  • visor mask png:

What I Want
The game world should only be visible inside the visor opening, while the rest of the screen remains covered by the helmet frame.

Question
What is the recommended way in Godot to render a scene inside a custom shaped mask?

Should this be done with:

  • a shader mask?

  • a SubViewport texture?

  • or some other approach?

Thanks!

Why not just making the center of the visor hollow?

I removed the center in GIMP, this is the result:

And then I put in my scene, under a CanvasLayer to make sure it covers everything.


2 Likes

Thank you so much sir! It works very well!!

1 Like