Excluding SubViewportContainer from canvas_item scaling mode

Godot Version

v4.7.1

Question

My 3D FPS game uses a couple SubViewportContainers to render the character’s viewmodel on top of the scene. I want the non-viewmodel UI to scale consistently no matter the player’s resolution, so I set Display > Window > Stretch > Mode to canvas_items. However, this causes the viewmodel to render at the lower “design” resolution then get scaled up, which makes it pixelated and ugly.

Is there any way to disable canvas_items scaling per control, or exclude SubViewportContainers? I just want these subviewports to render at the window’s resolution.

Don’t use viewports to render the guns. Change their BaseMaterial3D.z_clip_scale in their materials.

More info:

I suppose this is a fix, but rendering viewmodels separate to the scene then blitting them to the final render is well known practice, and gives more freedom such as using a different FOV for viewmodels compared to the main scene.

I dont really get why the viewports are rendering at the design resolution, according to the documentation, when the stretch mode is canvas_items, everything is rendered at the target resolution.

Ok this seems to be caused by a known issue ( SubViewportContainer does not scale Viewport properly with CanvasItems project scale mode. · Issue #77149 · godotengine/godot · GitHub ), so is not something fixable in editor.

You can override the FOV with BaseMaterial3D.fov_override