Struct Viewport
Creates a sub-view into the screen.
struct Viewport
;
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.
Properties
Name | Type | Description |
---|---|---|
arvr [get, set]
|
bool | If true , the viewport will be used in AR/VR process.
|
audioListenerEnable2d [get, set]
|
bool | If true , the viewport will process 2D audio streams.
|
audioListenerEnable3d [get, set]
|
bool | If true , the viewport will process 3D audio streams.
|
canvasTransform [get, set]
|
Transform2D | 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.
|
debugDraw [get, set]
|
Viewport | The overlay mode for test rendered geometry in debug purposes. |
disable3d [get, set]
|
bool | If true , the viewport will disable 3D rendering. For actual disabling use usage .
|
globalCanvasTransform [get, set]
|
Transform2D | The global canvas transform of the viewport. The canvas transform is relative to this. |
guiDisableInput [get, set]
|
bool | If true , the viewport will not receive input event.
|
guiSnapControlsToPixels [get, set]
|
bool | If true , the GUI controls on the viewport will lay pixel perfectly.
|
handleInputLocally [get, set]
|
bool | |
hdr [get, set]
|
bool | If true , 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.
|
keep3dLinear [get, set]
|
bool | If true , 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.
|
msaa [get, set]
|
Viewport | 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 targetting very high-end systems. |
ownWorld [get, set]
|
bool | If true , the viewport will use World defined in world property.
|
physicsObjectPicking [get, set]
|
bool | If true , the objects rendered by viewport become subjects of mouse picking process.
|
renderDirectToScreen [get, set]
|
bool | If true , 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 SCREEN_TEXTURE becomes unavailable. For more information see VisualServer .
|
renderTargetClearMode [get, set]
|
Viewport | The clear mode when viewport used as a render target. |
renderTargetUpdateMode [get, set]
|
Viewport | The update mode when viewport used as a render target. |
renderTargetVFlip [get, set]
|
bool | If true , the result of rendering will be flipped vertically.
|
shadowAtlasQuad0 [get, set]
|
Viewport | The subdivision amount of the first quadrant on the shadow atlas. |
shadowAtlasQuad1 [get, set]
|
Viewport | The subdivision amount of the second quadrant on the shadow atlas. |
shadowAtlasQuad2 [get, set]
|
Viewport | The subdivision amount of the third quadrant on the shadow atlas. |
shadowAtlasQuad3 [get, set]
|
Viewport | The subdivision amount of the fourth quadrant on the shadow atlas. |
shadowAtlasSize [get, set]
|
long | The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. Note: 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. |
size [get, set]
|
Vector2 | The width and height of viewport. |
sizeOverrideStretch [get, set]
|
bool | If true , the size override affects stretch as well.
|
transparentBg [get, set]
|
bool | If true , the viewport should render its background as transparent.
|
usage [get, set]
|
Viewport | The rendering mode of viewport. |
world [get, set]
|
World | The custom World which can be used as 3D environment source.
|
world2d [get, set]
|
World2D | The custom World2D which can be used as 2D environment source.
|
Methods
Name | Description |
---|---|
_guiRemoveFocus
|
|
_guiShowTooltip
|
|
_ownWorldChanged
|
|
_postGuiGrabClickFocus
|
|
_subwindowVisibilityChanged
|
|
_vpInput
|
|
_vpInputText
|
|
_vpUnhandledInput
|
|
findWorld
|
Returns the 3D world of the viewport, or if none the world of the parent viewport. |
findWorld2d
|
Returns the 2D world of the viewport. |
getCamera
|
Returns the active 3D camera. |
getCanvasTransform
|
|
getClearMode
|
|
getDebugDraw
|
|
getFinalTransform
|
Returns the total transform of the viewport. |
getGlobalCanvasTransform
|
|
getHdr
|
|
getKeep3dLinear
|
|
getModalStackTop
|
Returns the topmost modal in the stack. |
getMousePosition
|
Returns the mouse position relative to the viewport. |
getMsaa
|
|
getPhysicsObjectPicking
|
|
getRenderInfo
|
Returns information about the viewport from the rendering pipeline. |
getShadowAtlasQuadrantSubdiv
|
Returns the shadowatlasquadrantsubdiv of the specified quadrant.
|
getShadowAtlasSize
|
|
getSize
|
|
getSizeOverride
|
Returns the size override set with setSizeOverride .
|
getTexture
|
Returns the viewport's texture.
Note: Due to the way OpenGL works, the resulting ViewportTexture is flipped vertically. You can use Image on the result of Texture to flip it back, for example:
|
getUpdateMode
|
|
getUsage
|
|
getVflip
|
|
getViewportRid
|
Returns the viewport's RID from the VisualServer .
|
getVisibleRect
|
Returns the visible rectangle in global screen coordinates. |
getWorld
|
|
getWorld2d
|
|
guiGetDragData
|
Returns the drag data from the GUI, that was previously returned by Control .
|
guiHasModalStack
|
Returns true if there are visible modals on-screen.
|
guiIsDragging
|
Returns true if the viewport is currently performing a drag operation.
|
hasTransparentBackground
|
|
input
|
|
is3dDisabled
|
|
isAudioListener
|
|
isAudioListener2d
|
|
isHandlingInputLocally
|
|
isInputDisabled
|
|
isInputHandled
|
|
isSizeOverrideEnabled
|
Returns true if the size override is enabled. See setSizeOverride .
|
isSizeOverrideStretchEnabled
|
|
isSnapControlsToPixelsEnabled
|
|
isUsingOwnWorld
|
|
isUsingRenderDirectToScreen
|
|
setAsAudioListener
|
|
setAsAudioListener2d
|
|
setAttachToScreenRect
|
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.
|
setCanvasTransform
|
|
setClearMode
|
|
setDebugDraw
|
|
setDisable3d
|
|
setDisableInput
|
|
setGlobalCanvasTransform
|
|
setHandleInputLocally
|
|
setHdr
|
|
setInputAsHandled
|
Stops the input from propagating further down the SceneTree .
|
setKeep3dLinear
|
|
setMsaa
|
|
setPhysicsObjectPicking
|
|
setShadowAtlasQuadrantSubdiv
|
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. |
setShadowAtlasSize
|
|
setSize
|
|
setSizeOverride
|
Sets the size override of the viewport. If the enable parameter is true the override is used, otherwise it uses the default size. If the size parameter is (-1, -1) , it won't update the size.
|
setSizeOverrideStretch
|
|
setSnapControlsToPixels
|
|
setTransparentBackground
|
|
setUpdateMode
|
|
setUsage
|
|
setUseArvr
|
|
setUseOwnWorld
|
|
setUseRenderDirectToScreen
|
|
setVflip
|
|
setWorld
|
|
setWorld2d
|
|
unhandledInput
|
|
updateWorlds
|
Forces update of the 2D and 3D worlds. |
useArvr
|
|
warpMouse
|
Warps the mouse to a position relative to the viewport. |
Enums
Name | Description |
---|---|
ClearMode
|
|
Constants
|
|
DebugDraw
|
|
MSAA
|
|
RenderInfo
|
|
ShadowAtlasQuadrantSubdiv
|
|
UpdateMode
|
|
Usage
|