Base class for viewports. 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 they don't share what they draw 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. $DOCS_URL/tutorials/rendering/viewports.html $DOCS_URL/tutorials/2d/2d_transforms.html https://godotengine.org/asset-library/asset/127 https://godotengine.org/asset-library/asset/128 https://godotengine.org/asset-library/asset/129 https://godotengine.org/asset-library/asset/130 https://godotengine.org/asset-library/asset/541 https://godotengine.org/asset-library/asset/586 Returns the first valid [World2D] for this viewport, searching the [member world_2d] property of itself and any Viewport ancestor. Returns the first valid [World3D] for this viewport, searching the [member world_3d] property of itself and any Viewport ancestor. Returns the currently active 2D camera. Returns null if there are no active cameras. Returns the currently active 3D camera. Returns an individual bit on the rendering layer mask. Returns the total transform of the viewport. Returns the mouse's position in this [Viewport] using the coordinate system of this [Viewport]. Returns the [enum PositionalShadowAtlasQuadrantSubdiv] of the specified quadrant. Returns the transform from the Viewport's coordinates to the screen coordinates of the containing window manager window. Returns the viewport's texture. [b]Note:[/b] When trying to store the current texture (e.g. in a file), it might be completely black or outdated if used too early, especially when used in e.g. [method Node._ready]. To make sure the texture you get is correct, you can await [signal RenderingServer.frame_post_draw] signal. [codeblock] func _ready(): await RenderingServer.frame_post_draw $Viewport.get_texture().get_image().save_png("user://Screenshot.png") [/codeblock] Returns the viewport's RID from the [RenderingServer]. Returns the visible rectangle in global screen coordinates. Returns the drag data from the GUI, that was previously returned by [method Control._get_drag_data]. Returns the [Control] having the focus within this viewport. If no [Control] has the focus, returns null. Returns [code]true[/code] if the drag operation is successful. Returns [code]true[/code] if the viewport is currently performing a drag operation. Alternative to [constant Node.NOTIFICATION_DRAG_BEGIN] and [constant Node.NOTIFICATION_DRAG_END] when you prefer polling the value. Removes the focus from the currently focused [Control] within this viewport. If no [Control] has the focus, does nothing. Returns whether the current [InputEvent] has been handled. Input events are not handled until [method set_input_as_handled] has been called during the lifetime of an [InputEvent]. This is usually done as part of input handling methods like [method Node._input], [method Control._gui_input] or others, as well as in corresponding signal handlers. If [member handle_input_locally] is set to [code]false[/code], this method will try finding the first parent viewport that is set to handle input locally, and return its value for [method is_input_handled] instead. Triggers the given [param event] in this [Viewport]. This can be used to pass an [InputEvent] between viewports, or to locally apply inputs that were sent over the network or saved to a file. If [param in_local_coords] is [code]false[/code], the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If [param in_local_coords] is [code]true[/code], the event's position is in viewport coordinates. While this method serves a similar purpose as [method Input.parse_input_event], it does not remap the specified [param event] based on project settings like [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse]. Calling this method will propagate calls to child nodes for following methods in the given order: - [method Node._input] - [method Control._gui_input] for [Control] nodes If an earlier method marks the input as handled via [method set_input_as_handled], any later method in this list will not be called. Triggers the given [InputEvent] in this [Viewport]. This can be used to pass input events between viewports, or to locally apply inputs that were sent over the network or saved to a file. If [param in_local_coords] is [code]false[/code], the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If [param in_local_coords] is [code]true[/code], the event's position is in viewport coordinates. While this method serves a similar purpose as [method Input.parse_input_event], it does not remap the specified [param event] based on project settings like [member ProjectSettings.input_devices/pointing/emulate_touch_from_mouse]. Calling this method will propagate calls to child nodes for following methods in the given order: - [method Node._shortcut_input] - [method Node._unhandled_input] - [method Node._unhandled_key_input] If an earlier method marks the input as handled via [method set_input_as_handled], any later method in this list will not be called. If none of the methods handle the event and [member physics_object_picking] is [code]true[/code], the event is used for physics object picking. Set/clear individual bits on the rendering layer mask. This simplifies editing this [Viewport]'s layers. Stops the input from propagating further down the [SceneTree]. Sets the number of subdivisions to use in the specified quadrant. A higher number of subdivisions allows you to have more shadows in the scene at once, but reduces the quality of the shadows. A good practice is to have quadrants with a varying number of subdivisions and to have as few subdivisions as possible. Moves the mouse pointer to the specified position in this [Viewport] using the coordinate system of this [Viewport]. [b]Note:[/b] [method warp_mouse] is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web. If [code]true[/code], the viewport will process 2D audio streams. If [code]true[/code], the viewport will process 3D audio streams. The rendering layers in which this [Viewport] renders [CanvasItem] nodes. Sets the default filter mode used by [CanvasItem]s in this Viewport. See [enum DefaultCanvasItemTextureFilter] for options. Sets the default repeat mode used by [CanvasItem]s in this Viewport. See [enum DefaultCanvasItemTextureRepeat] for options. The canvas transform of the viewport, useful for changing the on-screen positions of all child [CanvasItem]s. This is relative to the global canvas transform of the viewport. The overlay mode for test rendered geometry in debug purposes. Disable 3D rendering (but keep 2D rendering). Determines how sharp the upscaled image will be when using the FSR upscaling mode. Sharpness halves with every whole number. Values go from 0.0 (sharpest) to 2.0. Values above 2.0 won't make a visible difference. To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/fsr_sharpness] project setting. The global canvas transform of the viewport. The canvas transform is relative to this. If [code]true[/code], the viewport will not receive input events. If [code]true[/code], sub-windows (popups and dialogs) will be embedded inside application window as control-like nodes. If [code]false[/code], they will appear as separate windows handled by the operating system. If [code]true[/code], the GUI controls on the viewport will lay pixel perfectly. If [code]true[/code], this viewport will mark incoming input events as handled by itself. If [code]false[/code], this is instead done by the the first parent viewport that is set to handle input locally. A [SubViewportContainer] will automatically set this property to [code]false[/code] for the [Viewport] contained inside of it. See also [method set_input_as_handled] and [method is_input_handled]. The automatic LOD bias to use for meshes rendered within the [Viewport] (this is analogous to [member ReflectionProbe.mesh_lod_threshold]). Higher values will use less detailed versions of meshes that have LOD variations generated. If set to [code]0.0[/code], automatic LOD is disabled. Increase [member mesh_lod_threshold] to improve performance at the cost of geometry detail. To control this property on the root viewport, set the [member ProjectSettings.rendering/mesh_lod/lod_change/threshold_pixels] project setting. [b]Note:[/b] [member mesh_lod_threshold] does not affect [GeometryInstance3D] visibility ranges (also known as "manual" LOD or hierarchical LOD). The multisample anti-aliasing mode for 2D/Canvas rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. This has no effect on shader-induced aliasing or texture aliasing. The multisample anti-aliasing mode for 3D rendering. A higher number results in smoother edges at the cost of significantly worse performance. A value of 2 or 4 is best unless targeting very high-end systems. See also bilinear scaling 3d [member scaling_3d_mode] for supersampling, which provides higher quality but is much more expensive. This has no effect on shader-induced aliasing or texture aliasing. If [code]true[/code], the viewport will use a unique copy of the [World3D] defined in [member world_3d]. If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process. The subdivision amount of the first quadrant on the shadow atlas. The subdivision amount of the second quadrant on the shadow atlas. The subdivision amount of the third quadrant on the shadow atlas. The subdivision amount of the fourth quadrant on the shadow atlas. The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. [b]Note:[/b] If this is set to [code]0[/code], no shadows will be visible at all (including directional shadows). Sets scaling 3d mode. Bilinear scaling renders at different resolution to either undersample or supersample the viewport. FidelityFX Super Resolution 1.0, abbreviated to FSR, is an upscaling technology that produces high quality images at fast framerates by using a spatially aware upscaling algorithm. FSR is slightly more expensive than bilinear, but it produces significantly higher image quality. FSR should be used where possible. To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/mode] project setting. Scales the 3D render buffer based on the viewport size uses an image filter specified in [member ProjectSettings.rendering/scaling_3d/mode] to scale the output image to the full viewport size. Values lower than [code]1.0[/code] can be used to speed up 3D rendering at the cost of quality (undersampling). Values greater than [code]1.0[/code] are only valid for bilinear mode and can be used to improve 3D rendering quality at a high performance cost (supersampling). See also [member ProjectSettings.rendering/anti_aliasing/quality/msaa_3d] for multi-sample antialiasing, which is significantly cheaper but only smooths the edges of polygons. When using FSR upscaling, AMD recommends exposing the following values as preset options to users "Ultra Quality: 0.77", "Quality: 0.67", "Balanced: 0.59", "Performance: 0.5" instead of exposing the entire scale. To control this property on the root viewport, set the [member ProjectSettings.rendering/scaling_3d/scale] project setting. Sets the screen-space antialiasing method used. Screen-space antialiasing works by selectively blurring edges in a post-process shader. It differs from MSAA which takes multiple coverage samples while rendering objects. Screen-space AA methods are typically faster than MSAA and will smooth out specular aliasing, but tend to make scenes appear blurry. Affects the final texture sharpness by reading from a lower or higher mipmap (also called "texture LOD bias"). Negative values make mipmapped textures sharper but grainier when viewed at a distance, while positive values make mipmapped textures blurrier (even when up close). Enabling temporal antialiasing ([member use_taa]) will automatically apply a [code]-0.5[/code] offset to this value, while enabling FXAA ([member screen_space_aa]) will automatically apply a [code]-0.25[/code] offset to this value. If both TAA and FXAA are enbled at the same time, an offset of [code]-0.75[/code] is applied to this value. [b]Note:[/b] If [member scaling_3d_scale] is lower than [code]1.0[/code] (exclusive), [member texture_mipmap_bias] is used to adjust the automatic mipmap bias which is calculated internally based on the scale factor. The formula for this is [code]log2(scaling_3d_scale) + mipmap_bias[/code]. To control this property on the root viewport, set the [member ProjectSettings.rendering/textures/default_filters/texture_mipmap_bias] project setting. If [code]true[/code], the viewport should render its background as transparent. If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible in 3D. 2D rendering is [i]not[/i] affected by debanding unless the [member Environment.background_mode] is [constant Environment.BG_CANVAS]. See also [member ProjectSettings.rendering/anti_aliasing/quality/use_debanding]. In some cases, debanding may introduce a slightly noticeable dithering pattern. It's recommended to enable debanding only when actually needed since the dithering pattern will make lossless-compressed screenshots larger. If [code]true[/code], [OccluderInstance3D] nodes will be usable for occlusion culling in 3D for this viewport. For the root viewport, [member ProjectSettings.rendering/occlusion_culling/use_occlusion_culling] must be set to [code]true[/code] instead. [b]Note:[/b] Enabling occlusion culling has a cost on the CPU. Only enable occlusion culling if you actually plan to use it, and think whether your scene can actually benefit from occlusion culling. Large, open scenes with few or no objects blocking the view will generally not benefit much from occlusion culling. Large open scenes generally benefit more from mesh LOD and visibility ranges ([member GeometryInstance3D.visibility_range_begin] and [member GeometryInstance3D.visibility_range_end]) compared to occlusion culling. Enables Temporal Anti-Aliasing for this viewport. TAA works by jittering the camera and accumulating the images of the last rendered frames, motion vector rendering is used to account for camera and object motion. [b]Note:[/b] The implementation is not complete yet, some visual instances such as particles and skinned meshes may show artifacts. If [code]true[/code], the viewport will use the primary XR interface to render XR output. When applicable this can result in a stereoscopic image and the resulting render being output to a headset. The Variable Rate Shading (VRS) mode that is used for this viewport. Note, if hardware does not support VRS this property is ignored. Texture to use when [member vrs_mode] is set to [constant Viewport.VRS_TEXTURE]. The texture [i]must[/i] use a lossless compression format so that colors can be matched precisely. The following VRS densities are mapped to various colors, with brighter colors representing a lower level of shading precision: [codeblock] - 1x1 = rgb(0, 0, 0) - #000000 - 1x2 = rgb(0, 85, 0) - #005500 - 2x1 = rgb(85, 0, 0) - #550000 - 2x2 = rgb(85, 85, 0) - #555500 - 2x4 = rgb(85, 170, 0) - #55aa00 - 4x2 = rgb(170, 85, 0) - #aa5500 - 4x4 = rgb(170, 170, 0) - #aaaa00 - 4x8 = rgb(170, 255, 0) - #aaff00 - Not supported on most hardware - 8x4 = rgb(255, 170, 0) - #ffaa00 - Not supported on most hardware - 8x8 = rgb(255, 255, 0) - #ffff00 - Not supported on most hardware [/codeblock] The custom [World2D] which can be used as 2D environment source. The custom [World3D] which can be used as 3D environment source. Emitted when a Control node grabs keyboard focus. Emitted when the size of the viewport is changed, whether by resizing of window, or some other means. This quadrant will not be used. This quadrant will only be used by one shadow map. This quadrant will be split in 4 and used by up to 4 shadow maps. This quadrant will be split 16 ways and used by up to 16 shadow maps. This quadrant will be split 64 ways and used by up to 64 shadow maps. This quadrant will be split 256 ways and used by up to 256 shadow maps. Unless the [member positional_shadow_atlas_size] is very high, the shadows in this quadrant will be very low resolution. This quadrant will be split 1024 ways and used by up to 1024 shadow maps. Unless the [member positional_shadow_atlas_size] is very high, the shadows in this quadrant will be very low resolution. Represents the size of the [enum PositionalShadowAtlasQuadrantSubdiv] enum. Use bilinear scaling for the viewport's 3D buffer. The amount of scaling can be set using [member scaling_3d_scale]. Values less then [code]1.0[/code] will result in undersampling while values greater than [code]1.0[/code] will result in supersampling. A value of [code]1.0[/code] disables scaling. Use AMD FidelityFX Super Resolution 1.0 upscaling for the viewport's 3D buffer. The amount of scaling can be set using [member scaling_3d_scale]. Values less then [code]1.0[/code] will be result in the viewport being upscaled using FSR. Values greater than [code]1.0[/code] are not supported and bilinear downsampling will be used instead. A value of [code]1.0[/code] disables scaling. Represents the size of the [enum Scaling3DMode] enum. Multisample antialiasing mode disabled. This is the default value, and is also the fastest setting. Use 2× Multisample Antialiasing. This has a moderate performance cost. It helps reduce aliasing noticeably, but 4× MSAA still looks substantially better. Use 4× Multisample Antialiasing. This has a significant performance cost, and is generally a good compromise between performance and quality. 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. Represents the size of the [enum MSAA] enum. Do not perform any antialiasing in the full screen post-process. Use fast approximate antialiasing. FXAA is a popular screen-space antialiasing method, which is fast but will make the image look blurry, especially at lower resolutions. It can still work relatively well at large resolutions such as 1440p and 4K. Represents the size of the [enum ScreenSpaceAA] enum. Amount of objects in frame. Amount of vertices in frame. Amount of draw calls in frame. Represents the size of the [enum RenderInfo] enum. Objects are displayed normally. Objects are displayed without light information. Objects are displayed semi-transparent with additive blending so you can see where they are drawing over top of one another. A higher overdraw means you are wasting performance on drawing pixels that are being hidden behind others. Objects are displayed in wireframe style. Objects are displayed with only the albedo value from [VoxelGI]s. Objects are displayed with only the lighting value from [VoxelGI]s. Objects are displayed with only the emission color from [VoxelGI]s. Draws the shadow atlas that stores shadows from [OmniLight3D]s and [SpotLight3D]s in the upper left quadrant of the [Viewport]. Draws the shadow atlas that stores shadows from [DirectionalLight3D]s in the upper left quadrant of the [Viewport]. Draws the screen-space ambient occlusion texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssao_enabled] set in your [WorldEnvironment]. Draws the screen-space indirect lighting texture instead of the scene so that you can clearly see how it is affecting objects. In order for this display mode to work, you must have [member Environment.ssil_enabled] set in your [WorldEnvironment]. Colors each PSSM split for the [DirectionalLight3D]s in the scene a different color so you can see where the splits are. In order, they will be colored red, green, blue, and yellow. Draws the decal atlas used by [Decal]s and light projector textures in the upper left quadrant of the [Viewport]. The texture filter reads from the nearest pixel only. The simplest and fastest method of filtering, but the texture will look pixelized. The texture filter blends between the nearest 4 pixels. Use this when you want to avoid a pixelated style, but do not want mipmaps. The texture filter reads from the nearest pixel in the nearest mipmap. The fastest way to read from textures with mipmaps. The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps. Max value for [enum DefaultCanvasItemTextureFilter] enum. Disables textures repeating. Instead, when reading UVs outside the 0-1 range, the value will be clamped to the edge of the texture, resulting in a stretched out look at the borders of the texture. Enables the texture to repeat when UV coordinates are outside the 0-1 range. If using one of the linear filtering modes, this can result in artifacts at the edges of a texture when the sampler filters across the edges of the texture. Flip the texture when repeating so that the edge lines up instead of abruptly changing. Max value for [enum DefaultCanvasItemTextureRepeat] enum. VRS is disabled. VRS uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view. VRS texture is supplied by the primary [XRInterface]. Represents the size of the [enum VRSMode] enum.