Creates a sub-view into the screen.
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 Camera 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. If a viewport is a child of a [ViewportContainer], it will automatically take up its size, otherwise it must be set manually. 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.
https://docs.godotengine.org/en/3.2/tutorials/2d/2d_transforms.html https://docs.godotengine.org/en/3.2/tutorials/viewports/index.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 3D world of the viewport, or if none the world of the parent viewport.
Returns the 2D world of the viewport.
Returns the active 3D camera.
Returns the total transform of the viewport.
Returns the topmost modal in the stack.
Returns the mouse position relative to the viewport.
Returns information about the viewport from the rendering pipeline.
Returns the [enum ShadowAtlasQuadrantSubdiv] of the specified quadrant.
Returns the size override set with [method set_size_override].
Returns the viewport's texture. [b]Note:[/b] Due to the way OpenGL works, the resulting [ViewportTexture] is flipped vertically. You can use [method Image.flip_y] on the result of [method Texture.get_data] to flip it back, for example: [codeblock] var img = get_viewport().get_texture().get_data() img.flip_y() [/codeblock]
Returns the viewport's RID from the [VisualServer].
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 [code]true[/code] if there are visible modals on-screen.
Returns [code]true[/code] if the viewport is currently performing a drag operation.
Returns [code]true[/code] if the size override is enabled. See [method set_size_override].
Attaches this [Viewport] to the root [Viewport] with the specified rectangle. This bypasses the need for another node to display this [Viewport] but makes you responsible for updating the position of this [Viewport] manually.
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.
Sets the size override of the viewport. If the [code]enable[/code] parameter is [code]true[/code] the override is used, otherwise it uses the default size. If the size parameter is [code](-1, -1)[/code], it won't update the size.
Forces update of the 2D and 3D worlds.
Warps the mouse to a position relative to the viewport.
- If [code]true[/code], the viewport will be used in AR/VR process.
- If [code]true[/code], the viewport will process 2D audio streams.
- If [code]true[/code], the viewport will process 3D audio streams.
- 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.
- If [code]true[/code], uses a fast post-processing filter to make banding significantly less visible. 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. [b]Note:[/b] Only available on the GLES3 backend. [member hdr] must also be [code]true[/code] for debanding to be effective.
- The overlay mode for test rendered geometry in debug purposes.
- If [code]true[/code], the viewport will disable 3D rendering. For actual disabling use [code]usage[/code].
- Enables 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.
- The global canvas transform of the viewport. The canvas transform is relative to this.
- If [code]true[/code], the viewport will not receive input event.
- If [code]true[/code], the GUI controls on the viewport will lay pixel perfectly.
- If [code]true[/code], the viewport rendering will receive benefits from High Dynamic Range algorithm. High Dynamic Range allows the viewport to receive values that are outside the 0-1 range. In Godot HDR uses 16 bits, meaning it does not store the full range of a floating point number. [b]Note:[/b] Requires [member usage] to be set to [constant USAGE_3D] or [constant USAGE_3D_NO_EFFECTS], since HDR is not supported for 2D.
- If [code]true[/code], the result after 3D rendering will not have a linear to sRGB color conversion applied. This is important when the viewport is used as a render target where the result is used as a texture on a 3D object rendered in another viewport. It is also important if the viewport is used to create data that is not color based (noise, heightmaps, pickmaps, etc.). Do not enable this when the viewport is used as a texture on a 2D object or if the viewport is your final output.
- The multisample anti-aliasing mode. A higher number results in smoother edges at the cost of significantly worse performance. A value of 4 is best unless targeting very high-end systems.
- If [code]true[/code], the viewport will use [World] defined in [code]world[/code] property.
- If [code]true[/code], the objects rendered by viewport become subjects of mouse picking process.
- If [code]true[/code], renders the Viewport directly to the screen instead of to the root viewport. Only available in GLES2. This is a low-level optimization and should not be used in most cases. If used, reading from the Viewport or from [code]SCREEN_TEXTURE[/code] becomes unavailable. For more information see [method VisualServer.viewport_set_render_direct_to_screen].
- The clear mode when viewport used as a render target. [b]Note:[/b] This property is intended for 2D usage.
- The update mode when viewport used as a render target.
- If [code]true[/code], the result of rendering will be flipped vertically.
- 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 0, shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually.
- The width and height of viewport.
- If [code]true[/code], the size override affects stretch as well.
- If [code]true[/code], the viewport should render its background as transparent.
- The rendering mode of viewport.
- The custom [World] which can be used as 3D environment source.
- The custom [World2D] which can be used as 2D environment source.
Emitted when a Control node grabs keyboard focus.
Emitted when the size of the viewport is changed, whether by [method set_size_override], resize of window, or some other means.
Do not update the render target.
Update the render target once, then switch to [constant UPDATE_DISABLED].
Update the render target only when it is visible. This is the default value.
Always update the render target.
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 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 shadow_atlas_size] is very high, the shadows in this quadrant will be very low resolution.
Represents the size of the [enum ShadowAtlasQuadrantSubdiv] enum.
Amount of objects in frame.
Amount of vertices in frame.
Amount of material changes in frame.
Amount of shader changes in frame.
Amount of surface changes in frame.
Amount of draw calls in frame.
Amount of items or joined items 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.
Objected are displayed semi-transparent with additive blending so you can see where they intersect.
Objects are displayed in wireframe style.
Multisample anti-aliasing mode disabled. This is the default value.
Use 2x Multisample Antialiasing.
Use 4x Multisample Antialiasing.
Use 8x Multisample Antialiasing. Likely unsupported on low-end and older hardware.
Use 16x Multisample Antialiasing. Likely unsupported on medium and low-end hardware.
Allocates all buffers needed for drawing 2D scenes. This takes less VRAM than the 3D usage modes. Note that 3D rendering effects such as glow and HDR are not available when using this mode.
Allocates buffers needed for 2D scenes without allocating a buffer for screen copy. Accordingly, you cannot read from the screen. Of the [enum Usage] types, this requires the least VRAM. Note that 3D rendering effects such as glow and HDR are not available when using this mode.
Allocates full buffers for drawing 3D scenes and all 3D effects including buffers needed for 2D scenes and effects.
Allocates buffers needed for drawing 3D scenes. But does not allocate buffers needed for reading from the screen and post-processing effects. Saves some VRAM.
Always clear the render target before drawing.
Never clear the render target.
Clear the render target next frame, then switch to [constant CLEAR_MODE_NEVER].