Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Viewport

Inherits: Node < Object

Inherited By: SubViewport, Window

Abstract base class for viewports. Encapsulates drawing and interaction with a game world.

Description

A Viewport creates a different view into the screen, or a sub-view inside another viewport. Children 2D Nodes will display on it, and children Camera3D 3D nodes will render on it too.

Optionally, a viewport can have its own 2D or 3D world, so it doesn't share what it draws with other viewports.

Viewports can also choose to be audio listeners, so they generate positional audio depending on a 2D or 3D camera child of it.

Also, viewports can be assigned to different screens in case the devices have multiple screens.

Finally, viewports can also behave as render targets, in which case they will not be visible unless the associated texture is used to draw.

Tutorials

Properties

bool

audio_listener_enable_2d

false

bool

audio_listener_enable_3d

false

int

canvas_cull_mask

4294967295

DefaultCanvasItemTextureFilter

canvas_item_default_texture_filter

1

DefaultCanvasItemTextureRepeat

canvas_item_default_texture_repeat

0

Transform2D

canvas_transform

DebugDraw

debug_draw

0

bool

disable_3d

false

float

fsr_sharpness

0.2

Transform2D

global_canvas_transform

bool

gui_disable_input

false

bool

gui_embed_subwindows

false

bool

gui_snap_controls_to_pixels

true

bool

handle_input_locally

true

float

mesh_lod_threshold

1.0

MSAA

msaa_2d

0

MSAA

msaa_3d

0

bool

own_world_3d

false

bool

physics_object_picking

false

bool

physics_object_picking_sort

false

bool

positional_shadow_atlas_16_bits

true

PositionalShadowAtlasQuadrantSubdiv

positional_shadow_atlas_quad_0

2

PositionalShadowAtlasQuadrantSubdiv

positional_shadow_atlas_quad_1

2

PositionalShadowAtlasQuadrantSubdiv

positional_shadow_atlas_quad_2

3

PositionalShadowAtlasQuadrantSubdiv

positional_shadow_atlas_quad_3

4

int

positional_shadow_atlas_size

2048

Scaling3DMode

scaling_3d_mode

0

float

scaling_3d_scale

1.0

ScreenSpaceAA

screen_space_aa

0

SDFOversize

sdf_oversize

1

SDFScale

sdf_scale

1

bool

snap_2d_transforms_to_pixel

false

bool

snap_2d_vertices_to_pixel

false

float

texture_mipmap_bias

0.0

bool

transparent_bg

false

bool

use_debanding

false

bool

use_hdr_2d

false

bool

use_occlusion_culling

false

bool

use_taa

false

bool

use_xr

false

VRSMode

vrs_mode

0

Texture2D

vrs_texture

World2D

world_2d

World3D

world_3d

Methods

World2D

find_world_2d ( ) const

World3D

find_world_3d ( ) const

Camera2D

get_camera_2d ( ) const

Camera3D

get_camera_3d ( ) const

bool

get_canvas_cull_mask_bit ( int layer ) const

Window[]

get_embedded_subwindows ( ) const

Transform2D

get_final_transform ( ) const

Vector2

get_mouse_position ( ) const

PositionalShadowAtlasQuadrantSubdiv

get_positional_shadow_atlas_quadrant_subdiv ( int quadrant ) const

int

get_render_info ( RenderInfoType type, RenderInfo info )

Transform2D

get_screen_transform ( ) const

ViewportTexture

get_texture ( ) const

RID

get_viewport_rid ( ) const

Rect2

get_visible_rect ( ) const

Variant

gui_get_drag_data ( ) const

Control

gui_get_focus_owner ( ) const

bool

gui_is_drag_successful ( ) const

bool

gui_is_dragging ( ) const

void

gui_release_focus ( )

bool

is_input_handled ( ) const

void

push_input ( InputEvent event, bool in_local_coords=false )

void

push_text_input ( String text )

void

push_unhandled_input ( InputEvent event, bool in_local_coords=false )

void

set_canvas_cull_mask_bit ( int layer, bool enable )

void

set_input_as_handled ( )

void

set_positional_shadow_atlas_quadrant_subdiv ( int quadrant, PositionalShadowAtlasQuadrantSubdiv subdiv )

void

update_mouse_cursor_state ( )

void

warp_mouse ( Vector2 position )


Signals

gui_focus_changed ( Control node )

Emitted when a Control node grabs keyboard focus.


size_changed ( )

Emitted when the size of the viewport is changed, whether by resizing of window, or some other means.


Enumerations

enum PositionalShadowAtlasQuadrantSubdiv:

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_DISABLED = 0

This quadrant will not be used.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_1 = 1

This quadrant will only be used by one shadow map.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_4 = 2

This quadrant will be split in 4 and used by up to 4 shadow maps.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_16 = 3

This quadrant will be split 16 ways and used by up to 16 shadow maps.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_64 = 4

This quadrant will be split 64 ways and used by up to 64 shadow maps.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_256 = 5

This quadrant will be split 256 ways and used by up to 256 shadow maps. Unless the positional_shadow_atlas_size is very high, the shadows in this quadrant will be very low resolution.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_1024 = 6

This quadrant will be split 1024 ways and used by up to 1024 shadow maps. Unless the positional_shadow_atlas_size is very high, the shadows in this quadrant will be very low resolution.

PositionalShadowAtlasQuadrantSubdiv SHADOW_ATLAS_QUADRANT_SUBDIV_MAX = 7

Represents the size of the PositionalShadowAtlasQuadrantSubdiv enum.


enum Scaling3DMode:

Scaling3DMode SCALING_3D_MODE_BILINEAR = 0

Use bilinear scaling for the viewport's 3D buffer. The amount of scaling can be set using scaling_3d_scale. Values less than 1.0 will result in undersampling while values greater than 1.0 will result in supersampling. A value of 1.0 disables scaling.

Scaling3DMode SCALING_3D_MODE_FSR = 1

Use AMD FidelityFX Super Resolution 1.0 upscaling for the viewport's 3D buffer. The amount of scaling can be set using scaling_3d_scale. Values less than 1.0 will be result in the viewport being upscaled using FSR. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 disables scaling.

Scaling3DMode SCALING_3D_MODE_FSR2 = 2

Use AMD FidelityFX Super Resolution 2.2 upscaling for the viewport's 3D buffer. The amount of scaling can be set using scaling_3d_scale. Values less than 1.0 will be result in the viewport being upscaled using FSR2. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 will use FSR2 at native resolution as a TAA solution.

Scaling3DMode SCALING_3D_MODE_MAX = 3

Represents the size of the Scaling3DMode enum.


enum MSAA:

MSAA MSAA_DISABLED = 0

Multisample antialiasing mode disabled. This is the default value, and is also the fastest setting.

MSAA MSAA_2X = 1

Use 2× Multisample Antialiasing. This has a moderate performance cost. It helps reduce aliasing noticeably, but 4× MSAA still looks substantially better.

MSAA MSAA_4X = 2

Use 4× Multisample Antialiasing. This has a significant performance cost, and is generally a good compromise between performance and quality.

MSAA MSAA_8X = 3

Use 8× Multisample Antialiasing. This has a very high performance cost. The difference between 4× and 8× MSAA may not always be visible in real gameplay conditions. Likely unsupported on low-end and older hardware.

MSAA MSAA_MAX = 4

Represents the size of the MSAA enum.


enum ScreenSpaceAA:

Scree