Creates a sub-view into the screen.
    public class Viewport : Node

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.

Inheritance Chain

Constructors

    public Viewport()

Signals

    "size_changed" ()

Emitted when the size of the viewport is changed, whether by SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?), resize of window, or some other means.

Properties

    public bool Arvr { get; set; }

If true the viewport will be used in AR/VR process. Default value: false.

    public bool AudioListenerEnable2d { get; set; }

If true the viewport will process 2D audio streams. Default value: false.

    public bool AudioListenerEnable3d { get; set; }

If true the viewport will process 3D audio streams. Default value: false.

    public Transform2D CanvasTransform { get; set; }

The canvas transform of the viewport, useful for changing the on-screen positions of all child CanvasItems. This is relative to the global canvas transform of the viewport.

    public DebugDrawEnum DebugDraw { get; set; }

The overlay mode for test rendered geometry in debug purposes. Default value: DEBUG_DRAW_DISABLED.

    public bool Disable3d { get; set; }

If true the viewport will disable 3D rendering. For actual disabling use usage. Default value: false.

    public Transform2D GlobalCanvasTransform { get; set; }

The global canvas transform of the viewport. The canvas transform is relative to this.

    public bool GuiDisableInput { get; set; }

If true the viewport will not receive input event. Default value: false.

    public bool GuiSnapControlsToPixels { get; set; }

If true the GUI controls on the viewport will lay pixel perfectly. Default value: true.

    public bool Hdr { get; set; }

If true the viewport rendering will receive benefits from High Dynamic Range algorithm. Default value: true.

    public MSAA Msaa { get; set; }

The multisample anti-aliasing mode. Default value: MSAA_DISABLED.

    public bool OwnWorld { get; set; }

If true the viewport will use World defined in world property. Default value: false.

    public bool PhysicsObjectPicking { get; set; }

If true the objects rendered by viewport become subjects of mouse picking process. Default value: false.

    public ClearMode RenderTargetClearMode { get; set; }

The clear mode when viewport used as a render target. Default value: CLEAR_MODE_ALWAYS.

    public UpdateMode RenderTargetUpdateMode { get; set; }

The update mode when viewport used as a render target. Default value: UPDATE_WHEN_VISIBLE.

    public bool RenderTargetVFlip { get; set; }

If true the result of rendering will be flipped vertically. Default value: false.

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad0 { get; set; }

The subdivision amount of first quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_4.

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad1 { get; set; }

The subdivision amount of second quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_4.

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad2 { get; set; }

The subdivision amount of third quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_16.

    public ShadowAtlasQuadrantSubdiv ShadowAtlasQuad3 { get; set; }

The subdivision amount of fourth quadrant on shadow atlas. Default value: SHADOW_ATLAS_QUADRANT_SUBDIV_64.

    public int ShadowAtlasSize { get; set; }

The resolution of shadow atlas. Both width and height is equal to one value.

    public Vector2 Size { get; set; }

The width and height of viewport.

    public bool TransparentBg { get; set; }

If true the viewport should render its background as transparent. Default value: false.

    public UsageEnum Usage { get; set; }

The rendering mode of viewport. Default value: USAGE_3D.

    public World World { get; set; }

The custom World which can be used as 3D environment source.

    public World2D World2d { get; set; }

The custom World2D which can be used as 2D environment source.

Methods

    public World FindWorld()

Return the 3D world of the viewport, or if no such present, the one of the parent viewport.

    public World2D FindWorld2d()

Return the 2D world of the viewport.

    public Camera GetCamera()

Return the active 3D camera.

    public Transform2D GetCanvasTransform()

Getter for CanvasTransform

    public ClearMode GetClearMode()

Getter for RenderTargetClearMode

    public DebugDrawEnum GetDebugDraw()

Getter for DebugDraw

    public Transform2D GetFinalTransform()

Get the total transform of the viewport.

    public Transform2D GetGlobalCanvasTransform()

Getter for GlobalCanvasTransform

    public bool GetHdr()

Getter for Hdr

    public Vector2 GetMousePosition()

Get the mouse position, relative to the viewport.

    public MSAA GetMsaa()

Getter for Msaa

    public bool GetPhysicsObjectPicking()

Getter for PhysicsObjectPicking

    public int GetRenderInfo(RenderInfo info)

Get the specific information about the viewport from rendering pipeline.

    public ShadowAtlasQuadrantSubdiv GetShadowAtlasQuadrantSubdiv(int quadrant)

    public int GetShadowAtlasSize()

Getter for ShadowAtlasSize

    public Vector2 GetSize()

Getter for Size

    public Vector2 GetSizeOverride()

Get the size override set with SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?).

    public ViewportTexture GetTexture()

Get the viewport’s texture, for use with various objects that you want to texture with the viewport.

    public UpdateMode GetUpdateMode()

Getter for RenderTargetUpdateMode

    public UsageEnum GetUsage()

Getter for Usage

    public bool GetVflip()

Getter for RenderTargetVFlip

    public RID GetViewportRid()

Get the viewport RID from the VisualServer.

    public Rect2 GetVisibleRect()

Return the final, visible rect in global screen coordinates.

    public World GetWorld()

Getter for World

    public World2D GetWorld2d()

Getter for World2d

    public object GuiGetDragData()

Returns the drag data from the GUI, that was previously returned by Control.GetDragData(Godot.Vector2).

    public bool GuiHasModalStack()

Returns whether there are shown modals on-screen.

    public bool HasTransparentBackground()

Getter for TransparentBg

    public void Input(InputEvent localEvent)

    public bool Is3dDisabled()

Getter for DebugDrawEnum.Disabled

    public bool IsAudioListener()

Getter for AudioListenerEnable2d

    public bool IsAudioListener2d()

Getter for AudioListenerEnable2d

    public bool IsInputDisabled()

Getter for GuiDisableInput

    public bool IsSizeOverrideEnabled()

Get the enabled status of the size override set with SetSizeOverride(bool, Godot.Vector2?, Godot.Vector2?).

    public bool IsSizeOverrideStretchEnabled()

Get the enabled status of the size stretch override set with SetSizeOverrideStretch(bool).

    public bool IsSnapControlsToPixelsEnabled()

Getter for GuiSnapControlsToPixels

    public bool IsUsingOwnWorld()

Getter for OwnWorld

    public void SetAsAudioListener(bool enable)

Setter for AudioListenerEnable2d

    public void SetAsAudioListener2d(bool enable)

Setter for AudioListenerEnable2d

    public void SetAttachToScreenRect(Rect2 rect)

    public void SetCanvasTransform(Transform2D xform)

Setter for CanvasTransform

    public void SetClearMode(ClearMode mode)

Setter for RenderTargetClearMode

    public void SetDebugDraw(DebugDrawEnum debugDraw)

Setter for DebugDraw

    public void SetDisable3d(bool disable)

Setter for DebugDrawEnum.Disabled

    public void SetDisableInput(bool disable)

Setter for GuiDisableInput

    public void SetGlobalCanvasTransform(Transform2D xform)

Setter for GlobalCanvasTransform

    public void SetHdr(bool enable)

Setter for Hdr

    public void SetMsaa(MSAA msaa)

Setter for Msaa

    public void SetPhysicsObjectPicking(bool enable)

Setter for PhysicsObjectPicking

    public void SetShadowAtlasQuadrantSubdiv(int quadrant, ShadowAtlasQuadrantSubdiv subdiv)

    public void SetShadowAtlasSize(int size)

Setter for ShadowAtlasSize

    public void SetSize(Vector2 size)

Setter for Size

    public void SetSizeOverride(bool enable, Vector2? size = default(Vector2?), Vector2? margin = default(Vector2?))

Set the size override of the viewport. If the enable parameter is true, it would use the override, otherwise it would use the default size. If the size parameter is equal to (-1, -1), it won’t update the size.

    public void SetSizeOverrideStretch(bool enabled)

Set whether the size override affects stretch as well.

    public void SetSnapControlsToPixels(bool enabled)

Setter for GuiSnapControlsToPixels

    public void SetTransparentBackground(bool enable)

Setter for TransparentBg

    public void SetUpdateMode(UpdateMode mode)

Setter for RenderTargetUpdateMode

    public void SetUsage(UsageEnum usage)

Setter for Usage

    public void SetUseArvr(bool use)

Setter for Arvr

    public void SetUseOwnWorld(bool enable)

Setter for OwnWorld

    public void SetVflip(bool enable)

Setter for RenderTargetVFlip

    public void SetWorld(World world)

Setter for World

    public void SetWorld2d(World2D world2d)

Setter for World2d

    public void UnhandledInput(InputEvent localEvent)

    public void UpdateWorlds()

Force update of the 2D and 3D worlds.

    public bool UseArvr()

Getter for Arvr

    public void WarpMouse(Vector2 toPosition)

Warp the mouse to a position, relative to the viewport.

Inner Types

ClearMode

Name Value Description
Always 0 Always clear the render target before drawing.
Never 1 Never clear the render target.
OnlyNextFrame 2 Clear the render target next frame, then switch to [code]CLEAR_MODE_NEVER[/code].

DebugDrawEnum

Name Value Description
Disabled 0 Objects are displayed normally.
Unshaded 1 Objects are displayed without light information.
Overdraw 2 Objected are displayed semi-transparent with additive blending so you can see where they intersect.
Wireframe 3 Objects are displayed in wireframe style.

MSAA

Name Value Description
Disabled 0 Multisample anti-aliasing mode disabled. This is the default value.
Msaa2x    
Msaa4x    
Msaa8x    
Msaa16x    

RenderInfo

Name Value Description
ObjectsInFrame 0 Amount of objects in frame.
VerticesInFrame 1 Amount of vertices in frame.
MaterialChangesInFrame 2 Amount of material changes in frame.
ShaderChangesInFrame 3 Amount of shader changes in frame.
SurfaceChangesInFrame 4 Amount of surface changes in frame.
DrawCallsInFrame 5 Amount of draw calls in frame.
Max 6 Enum limiter. Do not use it directly.

ShadowAtlasQuadrantSubdiv

Name Value Description
Disabled 0  
Subdiv1    
Subdiv4    
Subdiv16    
Subdiv64    
Subdiv256    
Subdiv1024    
Max 7 Enum limiter. Do not use it directly.

UpdateMode

Name Value Description
Disabled 0 Do not update the render target.
Once 1 Update the render target once, then switch to [code]UPDATE_DISABLED[/code].
WhenVisible 2 Update the render target only when it is visible. This is the default value.
Always 3 Always update the render target.

UsageEnum

Name Value Description
Usage2d    
Usage2dNoSampling    
Usage3d    
Usage3dNoEffects    
Tags: