ViewportTexture
继承: Texture2D
< Texture
< Resource
< RefCounted
< Object
Provides the content of a Viewport
as a dynamic texture.
描述
A ViewportTexture provides the content of a Viewport
as a dynamic Texture2D
. This can be used to combine the rendering of Control
, Node2D
and Node3D
nodes. For example, you can use this texture to display a 3D scene inside a TextureRect
, or a 2D overlay in a Sprite3D
.
To get a ViewportTexture in code, use the Viewport.get_texture
method on the target viewport.
Note: A ViewportTexture is always local to its scene (see Resource.resource_local_to_scene
). If the scene root is not ready, it may return incorrect data (see Node.ready
).
Note: Instantiating scenes containing a high-resolution ViewportTexture may cause noticeable stutter.
Note: When using a Viewport
with Viewport.use_hdr_2d
set to true
the returned texture will be an HDR image encoded in linear space. This may look darker than normal when displayed directly on screen. To convert to gamma space, you can do the following:
img.convert(Image.FORMAT_RGBA8)
imb.linear_to_srgb()
属性
属性说明
NodePath
viewport_path = NodePath("")
The path to the Viewport
node to display. This is relative to the local scene root (see Resource.get_local_scene
), not to the nodes that use this texture.
Note: In the editor, this path is automatically updated when the target viewport or one of its ancestors is renamed or moved. At runtime, this path may not automatically update if the scene root cannot be found.
本方法通常需要用户覆盖才能生效。
本方法无副作用,不会修改该实例的任何成员变量。
本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。
本方法用于构造某个类型。
调用本方法无需实例,可直接使用类名进行调用。
本方法描述的是使用本类型作为左操作数的有效运算符。
这个值是由下列位标志构成位掩码的整数。
无返回值。