Documentation
¶
Overview ¶
A graphics.gd/classdb/Viewport creates a different view into the screen, or a sub-view inside another viewport. Child 2D nodes will display on it, and child 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.
Index ¶
- type Advanced
- type AnisotropicFiltering
- type Any
- type DebugDraw
- type DefaultCanvasItemTextureFilter
- type DefaultCanvasItemTextureRepeat
- type Expanded
- type Extension
- type ID
- type Instance
- func (self Instance) AnisotropicFilteringLevel() AnisotropicFiltering
- func (self Instance) AsNode() Node.Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsViewport() Instance
- func (self Instance) AudioListenerEnable2d() bool
- func (self Instance) AudioListenerEnable3d() bool
- func (self Instance) CanvasCullMask() int
- func (self Instance) CanvasItemDefaultTextureFilter() DefaultCanvasItemTextureFilter
- func (self Instance) CanvasItemDefaultTextureRepeat() DefaultCanvasItemTextureRepeat
- func (self Instance) CanvasTransform() Transform2D.OriginXY
- func (self Instance) DebugDraw() DebugDraw
- func (self Instance) Disable3d() bool
- func (self Instance) FindWorld2d() World2D.Instance
- func (self Instance) FindWorld3d() World3D.Instance
- func (self Instance) FsrSharpness() Float.X
- func (self Instance) GetAudioListener2d() AudioListener2D.Instance
- func (self Instance) GetAudioListener3d() AudioListener3D.Instance
- func (self Instance) GetCamera2d() Camera2D.Instance
- func (self Instance) GetCamera3d() Camera3D.Instance
- func (self Instance) GetCanvasCullMaskBit(layer int) bool
- func (self Instance) GetFinalTransform() Transform2D.OriginXY
- func (self Instance) GetMousePosition() Vector2.XY
- func (self Instance) GetRenderInfo(atype RenderInfoType, info RenderInfo) int
- func (self Instance) GetScreenTransform() Transform2D.OriginXY
- func (self Instance) GetStretchTransform() Transform2D.OriginXY
- func (self Instance) GetTexture() ViewportTexture.Instance
- func (self Instance) GetViewportRid() RID.Viewport
- func (self Instance) GetVisibleRect() Rect2.PositionSize
- func (self Instance) GlobalCanvasTransform() Transform2D.OriginXY
- func (self Instance) GuiCancelDrag()
- func (self Instance) GuiDisableInput() bool
- func (self Instance) GuiEmbedSubwindows() bool
- func (self Instance) GuiGetDragData() any
- func (self Instance) GuiGetFocusOwner() Control.Instance
- func (self Instance) GuiGetHoveredControl() Control.Instance
- func (self Instance) GuiIsDragSuccessful() bool
- func (self Instance) GuiIsDragging() bool
- func (self Instance) GuiReleaseFocus()
- func (self Instance) GuiSnapControlsToPixels() bool
- func (self Instance) HandleInputLocally() bool
- func (self Instance) ID() ID
- func (self Instance) IsInputHandled() bool
- func (self Instance) MeshLodThreshold() Float.X
- func (self Instance) Msaa2d() MSAA
- func (self Instance) Msaa3d() MSAA
- func (self Instance) NotifyMouseEntered()
- func (self Instance) NotifyMouseExited()
- func (self Instance) OnGuiFocusChanged(cb func(node Control.Instance), flags ...Signal.Flags)
- func (self Instance) OnSizeChanged(cb func(), flags ...Signal.Flags)
- func (self Instance) OwnWorld3d() bool
- func (self Instance) PhysicsObjectPicking() bool
- func (self Instance) PhysicsObjectPickingFirstOnly() bool
- func (self Instance) PhysicsObjectPickingSort() bool
- func (self Instance) PositionalShadowAtlas16Bits() bool
- func (self Instance) PositionalShadowAtlasQuad0() PositionalShadowAtlasQuadrantSubdiv
- func (self Instance) PositionalShadowAtlasQuad1() PositionalShadowAtlasQuadrantSubdiv
- func (self Instance) PositionalShadowAtlasQuad2() PositionalShadowAtlasQuadrantSubdiv
- func (self Instance) PositionalShadowAtlasQuad3() PositionalShadowAtlasQuadrantSubdiv
- func (self Instance) PositionalShadowAtlasSize() int
- func (self Instance) PushInput(event InputEvent.Instance)
- func (self Instance) PushTextInput(text string)
- func (self Instance) PushUnhandledInput(event InputEvent.Instance)
- func (self Instance) Scaling3dMode() Scaling3DMode
- func (self Instance) Scaling3dScale() Float.X
- func (self Instance) ScreenSpaceAa() ScreenSpaceAA
- func (self Instance) SdfOversize() SDFOversize
- func (self Instance) SdfScale() SDFScale
- func (self Instance) SetAnisotropicFilteringLevel(value AnisotropicFiltering)
- func (self Instance) SetAudioListenerEnable2d(value bool)
- func (self Instance) SetAudioListenerEnable3d(value bool)
- func (self Instance) SetCanvasCullMask(value int)
- func (self Instance) SetCanvasCullMaskBit(layer int, enable bool)
- func (self Instance) SetCanvasItemDefaultTextureFilter(value DefaultCanvasItemTextureFilter)
- func (self Instance) SetCanvasItemDefaultTextureRepeat(value DefaultCanvasItemTextureRepeat)
- func (self Instance) SetCanvasTransform(value Transform2D.OriginXY)
- func (self Instance) SetDebugDraw(value DebugDraw)
- func (self Instance) SetDisable3d(value bool)
- func (self Instance) SetFsrSharpness(value Float.X)
- func (self Instance) SetGlobalCanvasTransform(value Transform2D.OriginXY)
- func (self Instance) SetGuiDisableInput(value bool)
- func (self Instance) SetGuiEmbedSubwindows(value bool)
- func (self Instance) SetGuiSnapControlsToPixels(value bool)
- func (self Instance) SetHandleInputLocally(value bool)
- func (self Instance) SetInputAsHandled()
- func (self Instance) SetMeshLodThreshold(value Float.X)
- func (self Instance) SetMsaa2d(value MSAA)
- func (self Instance) SetMsaa3d(value MSAA)
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetOwnWorld3d(value bool)
- func (self Instance) SetPhysicsObjectPicking(value bool)
- func (self Instance) SetPhysicsObjectPickingFirstOnly(value bool)
- func (self Instance) SetPhysicsObjectPickingSort(value bool)
- func (self Instance) SetPositionalShadowAtlas16Bits(value bool)
- func (self Instance) SetPositionalShadowAtlasQuad0(value PositionalShadowAtlasQuadrantSubdiv)
- func (self Instance) SetPositionalShadowAtlasQuad1(value PositionalShadowAtlasQuadrantSubdiv)
- func (self Instance) SetPositionalShadowAtlasQuad2(value PositionalShadowAtlasQuadrantSubdiv)
- func (self Instance) SetPositionalShadowAtlasQuad3(value PositionalShadowAtlasQuadrantSubdiv)
- func (self Instance) SetPositionalShadowAtlasSize(value int)
- func (self Instance) SetScaling3dMode(value Scaling3DMode)
- func (self Instance) SetScaling3dScale(value Float.X)
- func (self Instance) SetScreenSpaceAa(value ScreenSpaceAA)
- func (self Instance) SetSdfOversize(value SDFOversize)
- func (self Instance) SetSdfScale(value SDFScale)
- func (self Instance) SetSnap2dTransformsToPixel(value bool)
- func (self Instance) SetSnap2dVerticesToPixel(value bool)
- func (self Instance) SetTextureMipmapBias(value Float.X)
- func (self Instance) SetTransparentBg(value bool)
- func (self Instance) SetUseDebanding(value bool)
- func (self Instance) SetUseHdr2d(value bool)
- func (self Instance) SetUseOcclusionCulling(value bool)
- func (self Instance) SetUseTaa(value bool)
- func (self Instance) SetUseXr(value bool)
- func (self Instance) SetVrsMode(value VRSMode)
- func (self Instance) SetVrsTexture(value Texture2D.Instance)
- func (self Instance) SetVrsUpdateMode(value VRSUpdateMode)
- func (self Instance) SetWorld2d(value World2D.Instance)
- func (self Instance) SetWorld3d(value World3D.Instance)
- func (self Instance) Snap2dTransformsToPixel() bool
- func (self Instance) Snap2dVerticesToPixel() bool
- func (self Instance) TextureMipmapBias() Float.X
- func (self Instance) TransparentBg() bool
- func (self Instance) UpdateMouseCursorState()
- func (self Instance) UseDebanding() bool
- func (self Instance) UseHdr2d() bool
- func (self Instance) UseOcclusionCulling() bool
- func (self Instance) UseTaa() bool
- func (self Instance) UseXr() bool
- func (self Instance) Virtual(name string) reflect.Value
- func (self Instance) VrsMode() VRSMode
- func (self Instance) VrsTexture() Texture2D.Instance
- func (self Instance) VrsUpdateMode() VRSUpdateMode
- func (self Instance) WarpMouse(position Vector2.XY)
- func (self Instance) World2d() World2D.Instance
- func (self Instance) World3d() World3D.Instance
- type MSAA
- type PositionalShadowAtlasQuadrantSubdiv
- type RenderInfo
- type RenderInfoType
- type SDFOversize
- type SDFScale
- type Scaling3DMode
- type ScreenSpaceAA
- type VRSMode
- type VRSUpdateMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type AnisotropicFiltering ¶
type AnisotropicFiltering int //gd:Viewport.AnisotropicFiltering
const ( // Anisotropic filtering is disabled. AnisotropyDisabled AnisotropicFiltering = 0 // Use 2× anisotropic filtering. Anisotropy2x AnisotropicFiltering = 1 // Use 4× anisotropic filtering. This is the default value. Anisotropy4x AnisotropicFiltering = 2 // Use 8× anisotropic filtering. Anisotropy8x AnisotropicFiltering = 3 // Use 16× anisotropic filtering. Anisotropy16x AnisotropicFiltering = 4 // Represents the size of the [AnisotropicFiltering] enum. AnisotropyMax AnisotropicFiltering = 5 )
type DebugDraw ¶
type DebugDraw int //gd:Viewport.DebugDraw
const ( // Objects are displayed normally. DebugDrawDisabled DebugDraw = 0 // Objects are displayed without light information. DebugDrawUnshaded DebugDraw = 1 // Objects are displayed without textures and only with lighting information. DebugDrawLighting DebugDraw = 2 // 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. DebugDrawOverdraw DebugDraw = 3 // Objects are displayed as wireframe models. // // Note: [graphics.gd/classdb/RenderingServer.SetDebugGenerateWireframes] must be called before loading any meshes for wireframes to be visible when using the Compatibility renderer. DebugDrawWireframe DebugDraw = 4 // Objects are displayed without lighting information and their textures replaced by normal mapping. DebugDrawNormalBuffer DebugDraw = 5 // Objects are displayed with only the albedo value from [graphics.gd/classdb/VoxelGI]s. DebugDrawVoxelGiAlbedo DebugDraw = 6 // Objects are displayed with only the lighting value from [graphics.gd/classdb/VoxelGI]s. DebugDrawVoxelGiLighting DebugDraw = 7 // Objects are displayed with only the emission color from [graphics.gd/classdb/VoxelGI]s. DebugDrawVoxelGiEmission DebugDraw = 8 // Draws the shadow atlas that stores shadows from [graphics.gd/classdb/OmniLight3D]s and [graphics.gd/classdb/SpotLight3D]s in the upper left quadrant of the [graphics.gd/classdb/Viewport]. DebugDrawShadowAtlas DebugDraw = 9 // Draws the shadow atlas that stores shadows from [graphics.gd/classdb/DirectionalLight3D]s in the upper left quadrant of the [graphics.gd/classdb/Viewport]. DebugDrawDirectionalShadowAtlas DebugDraw = 10 // Draws the scene luminance buffer (if available) in the upper left quadrant of the [graphics.gd/classdb/Viewport]. DebugDrawSceneLuminance DebugDraw = 11 // 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 [graphics.gd/classdb/Environment.Instance.SsaoEnabled] set in your [graphics.gd/classdb/WorldEnvironment]. DebugDrawSsao DebugDraw = 12 // 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 [graphics.gd/classdb/Environment.Instance.SsilEnabled] set in your [graphics.gd/classdb/WorldEnvironment]. DebugDrawSsil DebugDraw = 13 // Colors each PSSM split for the [graphics.gd/classdb/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. DebugDrawPssmSplits DebugDraw = 14 // Draws the decal atlas used by [graphics.gd/classdb/Decal]s and light projector textures in the upper left quadrant of the [graphics.gd/classdb/Viewport]. DebugDrawDecalAtlas DebugDraw = 15 // Draws the cascades used to render signed distance field global illumination (SDFGI). // // Does nothing if the current environment's [graphics.gd/classdb/Environment.Instance.SdfgiEnabled] is false or SDFGI is not supported on the platform. DebugDrawSdfgi DebugDraw = 16 // Draws the probes used for signed distance field global illumination (SDFGI). // // Does nothing if the current environment's [graphics.gd/classdb/Environment.Instance.SdfgiEnabled] is false or SDFGI is not supported on the platform. DebugDrawSdfgiProbes DebugDraw = 17 // Draws the buffer used for global illumination (GI). DebugDrawGiBuffer DebugDraw = 18 // Draws all of the objects at their highest polycount, without low level of detail (LOD). DebugDrawDisableLod DebugDraw = 19 // Draws the cluster used by [graphics.gd/classdb/OmniLight3D] nodes to optimize light rendering. DebugDrawClusterOmniLights DebugDraw = 20 // Draws the cluster used by [graphics.gd/classdb/SpotLight3D] nodes to optimize light rendering. DebugDrawClusterSpotLights DebugDraw = 21 // Draws the cluster used by [graphics.gd/classdb/Decal] nodes to optimize decal rendering. DebugDrawClusterDecals DebugDraw = 22 // Draws the cluster used by [graphics.gd/classdb/ReflectionProbe] nodes to optimize decal rendering. DebugDrawClusterReflectionProbes DebugDraw = 23 // Draws the buffer used for occlusion culling. DebugDrawOccluders DebugDraw = 24 // Draws vector lines over the viewport to indicate the movement of pixels between frames. DebugDrawMotionVectors DebugDraw = 25 // Draws the internal resolution buffer of the scene before post-processing is applied. DebugDrawInternalBuffer DebugDraw = 26 )
type DefaultCanvasItemTextureFilter ¶
type DefaultCanvasItemTextureFilter int //gd:Viewport.DefaultCanvasItemTextureFilter
const ( // The texture filter reads from the nearest pixel only. This makes the texture look pixelated from up close, and grainy from a distance (due to mipmaps not being sampled). DefaultCanvasItemTextureFilterNearest DefaultCanvasItemTextureFilter = 0 // The texture filter blends between the nearest 4 pixels. This makes the texture look smooth from up close, and grainy from a distance (due to mipmaps not being sampled). DefaultCanvasItemTextureFilterLinear DefaultCanvasItemTextureFilter = 1 // The texture filter blends between the nearest 4 pixels and between the nearest 2 mipmaps (or uses the nearest mipmap if [graphics.gd/classdb/ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true). This makes the texture look smooth from up close, and smooth from a distance. // // Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [graphics.gd/classdb/Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels. DefaultCanvasItemTextureFilterLinearWithMipmaps DefaultCanvasItemTextureFilter = 2 // The texture filter reads from the nearest pixel and blends between the nearest 2 mipmaps (or uses the nearest mipmap if [graphics.gd/classdb/ProjectSettings] "rendering/textures/default_filters/use_nearest_mipmap_filter" is true). This makes the texture look pixelated from up close, and smooth from a distance. // // Use this for non-pixel art textures that may be viewed at a low scale (e.g. due to [graphics.gd/classdb/Camera2D] zoom or sprite scaling), as mipmaps are important to smooth out pixels that are smaller than on-screen pixels. DefaultCanvasItemTextureFilterNearestWithMipmaps DefaultCanvasItemTextureFilter = 3 // Represents the size of the [DefaultCanvasItemTextureFilter] enum. DefaultCanvasItemTextureFilterMax DefaultCanvasItemTextureFilter = 4 )
type DefaultCanvasItemTextureRepeat ¶
type DefaultCanvasItemTextureRepeat int //gd:Viewport.DefaultCanvasItemTextureRepeat
const ( // 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. DefaultCanvasItemTextureRepeatDisabled DefaultCanvasItemTextureRepeat = 0 // 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. DefaultCanvasItemTextureRepeatEnabled DefaultCanvasItemTextureRepeat = 1 // Flip the texture when repeating so that the edge lines up instead of abruptly changing. DefaultCanvasItemTextureRepeatMirror DefaultCanvasItemTextureRepeat = 2 // Represents the size of the [DefaultCanvasItemTextureRepeat] enum. DefaultCanvasItemTextureRepeatMax DefaultCanvasItemTextureRepeat = 3 )
type Expanded ¶
func (Expanded) PushInput ¶
func (self Expanded) PushInput(event InputEvent.Instance, in_local_coords bool)
Triggers the given 'event' in this graphics.gd/classdb/Viewport. This can be used to pass an graphics.gd/classdb/InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If 'in_local_coords' is false, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If 'in_local_coords' is true, the event's position is in viewport coordinates.
While this method serves a similar purpose as graphics.gd/classdb/Input.ParseInputEvent, it does not remap the specified 'event' based on project settings like graphics.gd/classdb/ProjectSettings "input_devices/pointing/emulate_touch_from_mouse".
Calling this method will propagate calls to child nodes for following methods in the given order:
- graphics.gd/classdb/Node.Instance.Input
- graphics.gd/classdb/Control.Instance.GuiInput for graphics.gd/classdb/Control nodes
- graphics.gd/classdb/Node.Instance.ShortcutInput
- graphics.gd/classdb/Node.Instance.UnhandledKeyInput
- graphics.gd/classdb/Node.Instance.UnhandledInput
If an earlier method marks the input as handled via Instance.SetInputAsHandled, any later method in this list will not be called.
If none of the methods handle the event and Instance.PhysicsObjectPicking is true, the event is used for physics object picking.
func (Expanded) PushUnhandledInput ¶
func (self Expanded) PushUnhandledInput(event InputEvent.Instance, in_local_coords bool)
Triggers the given 'event' in this graphics.gd/classdb/Viewport. This can be used to pass an graphics.gd/classdb/InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If 'in_local_coords' is false, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If 'in_local_coords' is true, the event's position is in viewport coordinates.
Calling this method will propagate calls to child nodes for following methods in the given order:
- graphics.gd/classdb/Node.Instance.ShortcutInput
- graphics.gd/classdb/Node.Instance.UnhandledKeyInput
- graphics.gd/classdb/Node.Instance.UnhandledInput
If an earlier method marks the input as handled via Instance.SetInputAsHandled, any later method in this list will not be called.
If none of the methods handle the event and Instance.PhysicsObjectPicking is true, the event is used for physics object picking.
Note: This method doesn't propagate input events to embedded [graphics.gd/classdb/Window]s or [graphics.gd/classdb/SubViewport]s.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsViewport ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func Get ¶
Returns the node's closest [Viewport] ancestor, if the node is inside the tree. Otherwise, returns [code]null[/code].
func (Instance) AnisotropicFilteringLevel ¶
func (self Instance) AnisotropicFilteringLevel() AnisotropicFiltering
func (Instance) AsViewport ¶
func (Instance) AudioListenerEnable2d ¶
func (Instance) AudioListenerEnable3d ¶
func (Instance) CanvasCullMask ¶
func (Instance) CanvasItemDefaultTextureFilter ¶
func (self Instance) CanvasItemDefaultTextureFilter() DefaultCanvasItemTextureFilter
func (Instance) CanvasItemDefaultTextureRepeat ¶
func (self Instance) CanvasItemDefaultTextureRepeat() DefaultCanvasItemTextureRepeat
func (Instance) CanvasTransform ¶
func (self Instance) CanvasTransform() Transform2D.OriginXY
func (Instance) FindWorld2d ¶
Returns the first valid graphics.gd/classdb/World2D for this viewport, searching the Instance.World2d property of itself and any Viewport ancestor.
func (Instance) FindWorld3d ¶
Returns the first valid graphics.gd/classdb/World3D for this viewport, searching the Instance.World3d property of itself and any Viewport ancestor.
func (Instance) FsrSharpness ¶
func (Instance) GetAudioListener2d ¶
func (self Instance) GetAudioListener2d() AudioListener2D.Instance
Returns the currently active 2D audio listener. Returns null if there are no active 2D audio listeners, in which case the active 2D camera will be treated as listener.
func (Instance) GetAudioListener3d ¶
func (self Instance) GetAudioListener3d() AudioListener3D.Instance
Returns the currently active 3D audio listener. Returns null if there are no active 3D audio listeners, in which case the active 3D camera will be treated as listener.
func (Instance) GetCamera2d ¶
Returns the currently active 2D camera. Returns null if there are no active cameras.
func (Instance) GetCamera3d ¶
Returns the currently active 3D camera.
func (Instance) GetCanvasCullMaskBit ¶
Returns an individual bit on the rendering layer mask.
func (Instance) GetFinalTransform ¶
func (self Instance) GetFinalTransform() Transform2D.OriginXY
Returns the transform from the viewport's coordinate system to the embedder's coordinate system.
func (Instance) GetMousePosition ¶
Returns the mouse's position in this graphics.gd/classdb/Viewport using the coordinate system of this graphics.gd/classdb/Viewport.
func (Instance) GetRenderInfo ¶
func (self Instance) GetRenderInfo(atype RenderInfoType, info RenderInfo) int
Returns rendering statistics of the given type. See RenderInfoType and RenderInfo for options.
func (Instance) GetScreenTransform ¶
func (self Instance) GetScreenTransform() Transform2D.OriginXY
Returns the transform from the Viewport's coordinates to the screen coordinates of the containing window manager window.
func (Instance) GetStretchTransform ¶
func (self Instance) GetStretchTransform() Transform2D.OriginXY
Returns the automatically computed 2D stretch transform, taking the graphics.gd/classdb/Viewport's stretch settings into account. The final value is multiplied by graphics.gd/classdb/Window.Instance.ContentScaleFactor, but only for the root viewport. If this method is called on a graphics.gd/classdb/SubViewport (e.g., in a scene tree with graphics.gd/classdb/SubViewportContainer and graphics.gd/classdb/SubViewport), the scale factor of the root window will not be applied. Using graphics.gd/classdb/Transform2D.Instance.GetScale on the returned value, this can be used to compensate for scaling when zooming a graphics.gd/classdb/Camera2D node, or to scale down a graphics.gd/classdb/TextureRect to be pixel-perfect regardless of the automatically computed scale factor.
Note: Due to how pixel scaling works, the returned transform's X and Y scale may differ slightly, even when graphics.gd/classdb/Window.Instance.ContentScaleAspect is set to a mode that preserves the pixels' aspect ratio. If graphics.gd/classdb/Window.Instance.ContentScaleAspect is [Window.ContentScaleAspectIgnore], the X and Y scale may differ significantly.
func (Instance) GetTexture ¶
func (self Instance) GetTexture() ViewportTexture.Instance
Returns the viewport's texture.
Note: 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. graphics.gd/classdb/Node.Instance.Ready. To make sure the texture you get is correct, you can await [Instance.OnRenderingserver.FramePostDraw] signal.
Note: When Instance.UseHdr2d is true the returned texture will be an HDR image encoded in linear space.
func (Instance) GetViewportRid ¶
Returns the viewport's RID from the graphics.gd/classdb/RenderingServer.
func (Instance) GetVisibleRect ¶
func (self Instance) GetVisibleRect() Rect2.PositionSize
Returns the visible rectangle in global screen coordinates.
func (Instance) GlobalCanvasTransform ¶
func (self Instance) GlobalCanvasTransform() Transform2D.OriginXY
func (Instance) GuiCancelDrag ¶
func (self Instance) GuiCancelDrag()
Cancels the drag operation that was previously started through graphics.gd/classdb/Control.Instance.GetDragData or forced with graphics.gd/classdb/Control.Instance.ForceDrag.
func (Instance) GuiDisableInput ¶
func (Instance) GuiEmbedSubwindows ¶
func (Instance) GuiGetDragData ¶
Returns the drag data from the GUI, that was previously returned by graphics.gd/classdb/Control.Instance.GetDragData.
func (Instance) GuiGetFocusOwner ¶
Returns the currently focused graphics.gd/classdb/Control within this viewport. If no graphics.gd/classdb/Control is focused, returns null.
func (Instance) GuiGetHoveredControl ¶
Returns the graphics.gd/classdb/Control that the mouse is currently hovering over in this viewport. If no graphics.gd/classdb/Control has the cursor, returns null.
Typically the leaf graphics.gd/classdb/Control node or deepest level of the subtree which claims hover. This is very useful when used together with graphics.gd/classdb/Node.Instance.IsAncestorOf to find if the mouse is within a control tree.
func (Instance) GuiIsDragSuccessful ¶
Returns true if the drag operation is successful.
func (Instance) GuiIsDragging ¶
Returns true if a drag operation is currently ongoing and where the drop action could happen in this viewport.
Alternative to [Node.NotificationDragBegin] and [Node.NotificationDragEnd] when you prefer polling the value.
func (Instance) GuiReleaseFocus ¶
func (self Instance) GuiReleaseFocus()
Removes the focus from the currently focused graphics.gd/classdb/Control within this viewport. If no graphics.gd/classdb/Control has the focus, does nothing.
func (Instance) GuiSnapControlsToPixels ¶
func (Instance) HandleInputLocally ¶
func (Instance) IsInputHandled ¶
Returns whether the current graphics.gd/classdb/InputEvent has been handled. Input events are not handled until Instance.SetInputAsHandled has been called during the lifetime of an graphics.gd/classdb/InputEvent.
This is usually done as part of input handling methods like graphics.gd/classdb/Node.Instance.Input, graphics.gd/classdb/Control.Instance.GuiInput or others, as well as in corresponding signal handlers.
If Instance.HandleInputLocally is set to false, this method will try finding the first parent viewport that is set to handle input locally, and return its value for Instance.IsInputHandled instead.
func (Instance) MeshLodThreshold ¶
func (Instance) NotifyMouseEntered ¶
func (self Instance) NotifyMouseEntered()
Inform the Viewport that the mouse has entered its area. Use this function before sending an graphics.gd/classdb/InputEventMouseButton or graphics.gd/classdb/InputEventMouseMotion to the graphics.gd/classdb/Viewport with graphics.gd/classdb/Viewport.Instance.PushInput. See also Instance.NotifyMouseExited.
Note: In most cases, it is not necessary to call this function because graphics.gd/classdb/SubViewport nodes that are children of graphics.gd/classdb/SubViewportContainer are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in graphics.gd/classdb/TextureRect or with an graphics.gd/classdb/Area3D that forwards input events.
func (Instance) NotifyMouseExited ¶
func (self Instance) NotifyMouseExited()
Inform the Viewport that the mouse has left its area. Use this function when the node that displays the viewport notices the mouse has left the area of the displayed viewport. See also Instance.NotifyMouseEntered.
Note: In most cases, it is not necessary to call this function because graphics.gd/classdb/SubViewport nodes that are children of graphics.gd/classdb/SubViewportContainer are notified automatically. This is only necessary when interacting with viewports in non-default ways, for example as textures in graphics.gd/classdb/TextureRect or with an graphics.gd/classdb/Area3D that forwards input events.
func (Instance) OnGuiFocusChanged ¶
func (Instance) OnSizeChanged ¶
func (Instance) OwnWorld3d ¶
func (Instance) PhysicsObjectPicking ¶
func (Instance) PhysicsObjectPickingFirstOnly ¶
func (Instance) PhysicsObjectPickingSort ¶
func (Instance) PositionalShadowAtlas16Bits ¶
func (Instance) PositionalShadowAtlasQuad0 ¶
func (self Instance) PositionalShadowAtlasQuad0() PositionalShadowAtlasQuadrantSubdiv
func (Instance) PositionalShadowAtlasQuad1 ¶
func (self Instance) PositionalShadowAtlasQuad1() PositionalShadowAtlasQuadrantSubdiv
func (Instance) PositionalShadowAtlasQuad2 ¶
func (self Instance) PositionalShadowAtlasQuad2() PositionalShadowAtlasQuadrantSubdiv
func (Instance) PositionalShadowAtlasQuad3 ¶
func (self Instance) PositionalShadowAtlasQuad3() PositionalShadowAtlasQuadrantSubdiv
func (Instance) PositionalShadowAtlasSize ¶
func (Instance) PushInput ¶
func (self Instance) PushInput(event InputEvent.Instance)
Triggers the given 'event' in this graphics.gd/classdb/Viewport. This can be used to pass an graphics.gd/classdb/InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If 'in_local_coords' is false, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If 'in_local_coords' is true, the event's position is in viewport coordinates.
While this method serves a similar purpose as graphics.gd/classdb/Input.ParseInputEvent, it does not remap the specified 'event' based on project settings like graphics.gd/classdb/ProjectSettings "input_devices/pointing/emulate_touch_from_mouse".
Calling this method will propagate calls to child nodes for following methods in the given order:
- graphics.gd/classdb/Node.Instance.Input
- graphics.gd/classdb/Control.Instance.GuiInput for graphics.gd/classdb/Control nodes
- graphics.gd/classdb/Node.Instance.ShortcutInput
- graphics.gd/classdb/Node.Instance.UnhandledKeyInput
- graphics.gd/classdb/Node.Instance.UnhandledInput
If an earlier method marks the input as handled via Instance.SetInputAsHandled, any later method in this list will not be called.
If none of the methods handle the event and Instance.PhysicsObjectPicking is true, the event is used for physics object picking.
func (Instance) PushTextInput ¶
Helper method which calls the set_text() method on the currently focused graphics.gd/classdb/Control, provided that it is defined (e.g. if the focused Control is graphics.gd/classdb/Button or graphics.gd/classdb/LineEdit).
func (Instance) PushUnhandledInput ¶
func (self Instance) PushUnhandledInput(event InputEvent.Instance)
Triggers the given 'event' in this graphics.gd/classdb/Viewport. This can be used to pass an graphics.gd/classdb/InputEvent between viewports, or to locally apply inputs that were sent over the network or saved to a file.
If 'in_local_coords' is false, the event's position is in the embedder's coordinates and will be converted to viewport coordinates. If 'in_local_coords' is true, the event's position is in viewport coordinates.
Calling this method will propagate calls to child nodes for following methods in the given order:
- graphics.gd/classdb/Node.Instance.ShortcutInput
- graphics.gd/classdb/Node.Instance.UnhandledKeyInput
- graphics.gd/classdb/Node.Instance.UnhandledInput
If an earlier method marks the input as handled via Instance.SetInputAsHandled, any later method in this list will not be called.
If none of the methods handle the event and Instance.PhysicsObjectPicking is true, the event is used for physics object picking.
Note: This method doesn't propagate input events to embedded [graphics.gd/classdb/Window]s or [graphics.gd/classdb/SubViewport]s.
func (Instance) Scaling3dMode ¶
func (self Instance) Scaling3dMode() Scaling3DMode
func (Instance) Scaling3dScale ¶
func (Instance) ScreenSpaceAa ¶
func (self Instance) ScreenSpaceAa() ScreenSpaceAA
func (Instance) SdfOversize ¶
func (self Instance) SdfOversize() SDFOversize
func (Instance) SetAnisotropicFilteringLevel ¶
func (self Instance) SetAnisotropicFilteringLevel(value AnisotropicFiltering)
func (Instance) SetAudioListenerEnable2d ¶
func (Instance) SetAudioListenerEnable3d ¶
func (Instance) SetCanvasCullMask ¶
func (Instance) SetCanvasCullMaskBit ¶
Set/clear individual bits on the rendering layer mask. This simplifies editing this graphics.gd/classdb/Viewport's layers.
func (Instance) SetCanvasItemDefaultTextureFilter ¶
func (self Instance) SetCanvasItemDefaultTextureFilter(value DefaultCanvasItemTextureFilter)
func (Instance) SetCanvasItemDefaultTextureRepeat ¶
func (self Instance) SetCanvasItemDefaultTextureRepeat(value DefaultCanvasItemTextureRepeat)
func (Instance) SetCanvasTransform ¶
func (self Instance) SetCanvasTransform(value Transform2D.OriginXY)
func (Instance) SetDebugDraw ¶
func (Instance) SetDisable3d ¶
func (Instance) SetFsrSharpness ¶
func (Instance) SetGlobalCanvasTransform ¶
func (self Instance) SetGlobalCanvasTransform(value Transform2D.OriginXY)
func (Instance) SetGuiDisableInput ¶
func (Instance) SetGuiEmbedSubwindows ¶
func (Instance) SetGuiSnapControlsToPixels ¶
func (Instance) SetHandleInputLocally ¶
func (Instance) SetInputAsHandled ¶
func (self Instance) SetInputAsHandled()
Stops the input from propagating further down the graphics.gd/classdb/SceneTree.
Note: This does not affect the methods in graphics.gd/classdb/Input, only the way events are propagated.
func (Instance) SetMeshLodThreshold ¶
func (Instance) SetOwnWorld3d ¶
func (Instance) SetPhysicsObjectPicking ¶
func (Instance) SetPhysicsObjectPickingFirstOnly ¶
func (Instance) SetPhysicsObjectPickingSort ¶
func (Instance) SetPositionalShadowAtlas16Bits ¶
func (Instance) SetPositionalShadowAtlasQuad0 ¶
func (self Instance) SetPositionalShadowAtlasQuad0(value PositionalShadowAtlasQuadrantSubdiv)
func (Instance) SetPositionalShadowAtlasQuad1 ¶
func (self Instance) SetPositionalShadowAtlasQuad1(value PositionalShadowAtlasQuadrantSubdiv)
func (Instance) SetPositionalShadowAtlasQuad2 ¶
func (self Instance) SetPositionalShadowAtlasQuad2(value PositionalShadowAtlasQuadrantSubdiv)
func (Instance) SetPositionalShadowAtlasQuad3 ¶
func (self Instance) SetPositionalShadowAtlasQuad3(value PositionalShadowAtlasQuadrantSubdiv)
func (Instance) SetPositionalShadowAtlasSize ¶
func (Instance) SetScaling3dMode ¶
func (self Instance) SetScaling3dMode(value Scaling3DMode)
func (Instance) SetScaling3dScale ¶
func (Instance) SetScreenSpaceAa ¶
func (self Instance) SetScreenSpaceAa(value ScreenSpaceAA)
func (Instance) SetSdfOversize ¶
func (self Instance) SetSdfOversize(value SDFOversize)
func (Instance) SetSdfScale ¶
func (Instance) SetSnap2dTransformsToPixel ¶
func (Instance) SetSnap2dVerticesToPixel ¶
func (Instance) SetTextureMipmapBias ¶
func (Instance) SetTransparentBg ¶
func (Instance) SetUseDebanding ¶
func (Instance) SetUseHdr2d ¶
func (Instance) SetUseOcclusionCulling ¶
func (Instance) SetVrsMode ¶
func (Instance) SetVrsTexture ¶
func (Instance) SetVrsUpdateMode ¶
func (self Instance) SetVrsUpdateMode(value VRSUpdateMode)
func (Instance) SetWorld2d ¶
func (Instance) SetWorld3d ¶
func (Instance) Snap2dTransformsToPixel ¶
func (Instance) Snap2dVerticesToPixel ¶
func (Instance) TextureMipmapBias ¶
func (Instance) TransparentBg ¶
func (Instance) UpdateMouseCursorState ¶
func (self Instance) UpdateMouseCursorState()
Force instantly updating the display based on the current mouse cursor position. This includes updating the mouse cursor shape and sending necessary [Instance.OnControl.MouseEntered], [Instance.OnCollisionobject2d.MouseEntered], [Instance.OnCollisionobject3d.MouseEntered] and [Instance.OnWindow.MouseEntered] signals and their respective mouse_exited counterparts.
func (Instance) UseDebanding ¶
func (Instance) UseOcclusionCulling ¶
func (Instance) VrsTexture ¶
func (Instance) VrsUpdateMode ¶
func (self Instance) VrsUpdateMode() VRSUpdateMode
func (Instance) WarpMouse ¶
Moves the mouse pointer to the specified position in this graphics.gd/classdb/Viewport using the coordinate system of this graphics.gd/classdb/Viewport.
Note: Instance.WarpMouse is only supported on Windows, macOS and Linux. It has no effect on Android, iOS and Web.
type MSAA ¶
type MSAA int //gd:Viewport.MSAA
const ( // Multisample antialiasing mode disabled. This is the default value, and is also the fastest setting. MsaaDisabled MSAA = 0 // Use 2× Multisample Antialiasing. This has a moderate performance cost. It helps reduce aliasing noticeably, but 4× MSAA still looks substantially better. Msaa2x MSAA = 1 // Use 4× Multisample Antialiasing. This has a significant performance cost, and is generally a good compromise between performance and quality. Msaa4x MSAA = 2 // 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. Msaa8x MSAA = 3 // Represents the size of the [MSAA] enum. MsaaMax MSAA = 4 )
type PositionalShadowAtlasQuadrantSubdiv ¶
type PositionalShadowAtlasQuadrantSubdiv int //gd:Viewport.PositionalShadowAtlasQuadrantSubdiv
const ( // This quadrant will not be used. ShadowAtlasQuadrantSubdivDisabled PositionalShadowAtlasQuadrantSubdiv = 0 // This quadrant will only be used by one shadow map. ShadowAtlasQuadrantSubdiv1 PositionalShadowAtlasQuadrantSubdiv = 1 // This quadrant will be split in 4 and used by up to 4 shadow maps. ShadowAtlasQuadrantSubdiv4 PositionalShadowAtlasQuadrantSubdiv = 2 // This quadrant will be split 16 ways and used by up to 16 shadow maps. ShadowAtlasQuadrantSubdiv16 PositionalShadowAtlasQuadrantSubdiv = 3 // This quadrant will be split 64 ways and used by up to 64 shadow maps. ShadowAtlasQuadrantSubdiv64 PositionalShadowAtlasQuadrantSubdiv = 4 // This quadrant will be split 256 ways and used by up to 256 shadow maps. Unless the [Instance.PositionalShadowAtlasSize] is very high, the shadows in this quadrant will be very low resolution. ShadowAtlasQuadrantSubdiv256 PositionalShadowAtlasQuadrantSubdiv = 5 // This quadrant will be split 1024 ways and used by up to 1024 shadow maps. Unless the [Instance.PositionalShadowAtlasSize] is very high, the shadows in this quadrant will be very low resolution. ShadowAtlasQuadrantSubdiv1024 PositionalShadowAtlasQuadrantSubdiv = 6 // Represents the size of the [PositionalShadowAtlasQuadrantSubdiv] enum. ShadowAtlasQuadrantSubdivMax PositionalShadowAtlasQuadrantSubdiv = 7 )
type RenderInfo ¶
type RenderInfo int //gd:Viewport.RenderInfo
const ( // Amount of objects in frame. RenderInfoObjectsInFrame RenderInfo = 0 // Amount of vertices in frame. RenderInfoPrimitivesInFrame RenderInfo = 1 // Amount of draw calls in frame. RenderInfoDrawCallsInFrame RenderInfo = 2 // Represents the size of the [RenderInfo] enum. RenderInfoMax RenderInfo = 3 )
type RenderInfoType ¶
type RenderInfoType int //gd:Viewport.RenderInfoType
const ( // Visible render pass (excluding shadows). RenderInfoTypeVisible RenderInfoType = 0 // Shadow render pass. Objects will be rendered several times depending on the number of amounts of lights with shadows and the number of directional shadow splits. RenderInfoTypeShadow RenderInfoType = 1 // Canvas item rendering. This includes all 2D rendering. RenderInfoTypeCanvas RenderInfoType = 2 // Represents the size of the [RenderInfoType] enum. RenderInfoTypeMax RenderInfoType = 3 )
type SDFOversize ¶
type SDFOversize int //gd:Viewport.SDFOversize
const ( // The signed distance field only covers the viewport's own rectangle. SdfOversize100Percent SDFOversize = 0 // The signed distance field is expanded to cover 20% of the viewport's size around the borders. SdfOversize120Percent SDFOversize = 1 // The signed distance field is expanded to cover 50% of the viewport's size around the borders. SdfOversize150Percent SDFOversize = 2 // The signed distance field is expanded to cover 100% (double) of the viewport's size around the borders. SdfOversize200Percent SDFOversize = 3 // Represents the size of the [SDFOversize] enum. SdfOversizeMax SDFOversize = 4 )
type SDFScale ¶
type SDFScale int //gd:Viewport.SDFScale
const ( // The signed distance field is rendered at full resolution. SdfScale100Percent SDFScale = 0 // The signed distance field is rendered at half the resolution of this viewport. SdfScale50Percent SDFScale = 1 // The signed distance field is rendered at a quarter the resolution of this viewport. SdfScale25Percent SDFScale = 2 // Represents the size of the [SDFScale] enum. SdfScaleMax SDFScale = 3 )
type Scaling3DMode ¶
type Scaling3DMode int //gd:Viewport.Scaling3DMode
const ( // Use bilinear scaling for the viewport's 3D buffer. The amount of scaling can be set using [Instance.Scaling3dScale]. 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. Scaling3dModeBilinear Scaling3DMode = 0 // Use AMD FidelityFX Super Resolution 1.0 upscaling for the viewport's 3D buffer. The amount of scaling can be set using [Instance.Scaling3dScale]. 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. Scaling3dModeFsr Scaling3DMode = 1 // Use AMD FidelityFX Super Resolution 2.2 upscaling for the viewport's 3D buffer. The amount of scaling can be set using [graphics.gd/classdb/Viewport.Instance.Scaling3dScale]. 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. Scaling3dModeFsr2 Scaling3DMode = 2 // Use the [MetalFX spatial upscaler] for the viewport's 3D buffer. // // The amount of scaling can be set using [Instance.Scaling3dScale]. // // Values less than 1.0 will be result in the viewport being upscaled using MetalFX. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 disables scaling. // // More information: [MetalFX]. // // Note: Only supported when the Metal rendering driver is in use, which limits this scaling mode to macOS and iOS. // // [MetalFX]: https://developer.apple.com/documentation/metalfx // [MetalFX spatial upscaler]: https://developer.apple.com/documentation/metalfx/mtlfxspatialscaler#overview Scaling3dModeMetalfxSpatial Scaling3DMode = 3 // Use the [MetalFX temporal upscaler] for the viewport's 3D buffer. // // The amount of scaling can be set using [Instance.Scaling3dScale]. To determine the minimum input scale, use the [graphics.gd/classdb/RenderingDevice.Instance.LimitGet] method with [Renderingdevice.LimitMetalfxTemporalScalerMinScale]. // // Values less than 1.0 will be result in the viewport being upscaled using MetalFX. Values greater than 1.0 are not supported and bilinear downsampling will be used instead. A value of 1.0 will use MetalFX at native resolution as a TAA solution. // // More information: [MetalFX]. // // Note: Only supported when the Metal rendering driver is in use, which limits this scaling mode to macOS and iOS. // // [MetalFX]: https://developer.apple.com/documentation/metalfx // [MetalFX temporal upscaler]: https://developer.apple.com/documentation/metalfx/mtlfxtemporalscaler#overview Scaling3dModeMetalfxTemporal Scaling3DMode = 4 // Represents the size of the [Scaling3DMode] enum. Scaling3dModeMax Scaling3DMode = 5 )
type ScreenSpaceAA ¶
type ScreenSpaceAA int //gd:Viewport.ScreenSpaceAA
const ( // Do not perform any antialiasing in the full screen post-process. ScreenSpaceAaDisabled ScreenSpaceAA = 0 // 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. ScreenSpaceAaFxaa ScreenSpaceAA = 1 // Represents the size of the [ScreenSpaceAA] enum. ScreenSpaceAaMax ScreenSpaceAA = 2 )
type VRSMode ¶
type VRSMode int //gd:Viewport.VRSMode
const ( // Variable Rate Shading is disabled. VrsDisabled VRSMode = 0 // Variable Rate Shading uses a texture. Note, for stereoscopic use a texture atlas with a texture for each view. VrsTexture VRSMode = 1 // Variable Rate Shading's texture is supplied by the primary [graphics.gd/classdb/XRInterface]. VrsXr VRSMode = 2 // Represents the size of the [VRSMode] enum. VrsMax VRSMode = 3 )
type VRSUpdateMode ¶
type VRSUpdateMode int //gd:Viewport.VRSUpdateMode
const ( // The input texture for variable rate shading will not be processed. VrsUpdateDisabled VRSUpdateMode = 0 // The input texture for variable rate shading will be processed once. VrsUpdateOnce VRSUpdateMode = 1 // The input texture for variable rate shading will be processed each frame. VrsUpdateAlways VRSUpdateMode = 2 // Represents the size of the [VRSUpdateMode] enum. VrsUpdateMax VRSUpdateMode = 3 )